CallbackOnCollectedDelegate exception from GstSharp - possible bug?

KrzychuZ krzys95 at gmail.com
Tue Sep 25 17:59:06 UTC 2018


Im using the code from
https://github.com/centricular/gstwebrtc-demos/blob/master/sendrecv/gst-sharp/WebRTCSendRecv.cs
The problematic piece is straight from there and not modified at all (code
at the bottom). 
I'm getting the following exception:

/'CallbackOnCollectedDelegate' : 'A callback was made on a garbage collected
delegate of type 'gstreamer-sharp!GstSharp.PromiseChangeFuncNative::Invoke'.
This may cause application crashes, corruption and data loss. When passing
delegates to unmanaged code, they must be kept alive by the managed
application until it is guaranteed that they will never be called.'/

It is thrown from libgstwebrtc.dll.

It is happening on PromiseChangeFuncNative and not on PromiseChangeFunc that
is created from the first parameter of the Promise constructor like here
/Promise promise = new Promise(OnOfferCreated, webrtc.Handle, null)/
and holding reference to the PromiseChangeFunc (also code below) does not
solve the problem, so I suspect it is a bug in GstSharp itself. Can anyone
confirm or deny?


Functions that use the Promise around which the exception occurs:

void OnNegotiationNeeded(object o, GLib.SignalArgs args)
{
    var webRtc = o as Element;
    Assert(webRtc != null, "not a webrtc object");
    Promise promise = new Promise(OnOfferCreated, webrtc.Handle, null); //
webRtc.Handle, null);
    Structure structure = new Structure("struct");
    webrtc.Emit("create-offer", structure, promise);
}

void OnOfferCreated(Promise promise)
{
    promise.Wait();
    var reply = promise.RetrieveReply();
    var gval = reply.GetValue("offer");
    WebRTCSessionDescription offer = (WebRTCSessionDescription)gval.Val;
    promise = new Promise();
    webrtc.Emit("set-local-description", offer, promise);
    promise.Interrupt();
    SendSdpOffer(offer);
}


Rewriting it like this to hold the reference also doesn't help:

private PromiseChangeFunc pcf;

void OnNegotiationNeeded(object o, GLib.SignalArgs args)
{
    var webRtc = o as Element;
    Assert(webRtc != null, "not a webrtc object");
    pcf = new PromiseChangeFunc(OnOfferCreated);
    Promise promise = new Promise(pcf, webrtc.Handle, null); //
webRtc.Handle, null);
    Structure structure = new Structure("struct");
    webrtc.Emit("create-offer", structure, promise);
}

Any feedback will be appreciated. Thanks! 



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list