[libnice] Confusion about running threads of signal callbacks
Olivier Crête
olivier.crete at collabora.com
Thu May 13 14:49:33 UTC 2021
Hi,
Yes, the signals come from random threads. They come from the thread
where the code that caused it to be emitted was running. I think
changing that would be an API break, and I think it's not trivial to do
it right and guarantee the right ordering.
I guess ideally, one would move the entire state machine of libnice
onto the main thread to make this easier.
Out of curiosity, what kind of thread races are you seeing?
Olivier
On Thu, 2021-05-13 at 11:49 +0200, Juan Navarro wrote:
> On 13/05/2021 11.34, Lorenzo Miniero wrote:
>
> >
> > In our case, it was caused by the wrong assumption that the
> > selected-pair callback would always be fired by the same thread as
> > the other libnice events, which turned out not to be true
>
> Correct, that's exactly what I've observed. I asked here but after
> some days, I've been thinking to file a bug report, because my code
> is receiving signals such as "new-candidate-full" from the thread of
> a "nicesrc" element in the GStreamer pipeline, which seems
> nonsensical.
>
>
>
> > As a consequence, we had to refactor the code a bit, so that some
> > things we were doing in place would be performed as a result on
> > messaging on the same loop libnice uses
>
> I did something in the same vein; instead of handling the signals
> directly in a callback, under my original assumption that callbacks
> would run from the same thread than the NiceAgent's GMainContext, I'm
> now using "g_main_context_invoke_full()" to push their processing as
> a second order callback that, this time, does actually run in the
> mentioned context.
>
> However, this didn't solve all thread races. ThreadSanitizer still
> detects races in the signal emission, but this time the whole stack
> trace is within glib and libnice code, not passing through any of my
> code.
>
>
> Thank you very much for the links! I'll have a look to see if there
> is some idea I didn't think of. And thanks for sharing some feedback,
> too :)
>
>
> Regards,
> Juan
>
> _______________________________________________
> nice mailing list
> nice at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nice
--
Olivier Crête
olivier.crete at collabora.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/nice/attachments/20210513/41c68bc6/attachment.htm>
More information about the nice
mailing list