GNOME Bugzilla – Bug 615655
[camerabin] shouldn't rely on running GLib main loop
Last modified: 2011-04-05 17:41:24 UTC
Subject says it all. gstcamerabin.c-3283- /* Calling callback directly will deadlock in gstcamerabin.c-3284- imagebin state change functions */ gstcamerabin.c:3285: g_idle_add_full (G_PRIORITY_HIGH, gst_camerabin_imgbin_finished, camera, gstcamerabin.c-3286- NULL); Elements shouldn't rely on a running GLib main loop iterating the default main context.
Right now the best way to solve this would be to detach imgbin from the rest using appsrc/appsink. Then we can even have a pool of imagebins and we can control the states without g_idle_add. For the record, if we just remove the g_idle_add as it is now and make a direct call, we get stuck in. gstbasesink.c:4741 GST_PAD_PREROLL_LOCK (basesink->sinkpad);
+ Trace 221384
Thread 3 (Thread 0x7f34d925b910 (LWP 3144))
Maybe there is a easier fix then then appsrc/appsink change.
Right, you can't do a state change from within the streaming thread. Another alternative would be a helper thread iterating a custom GMainContext (or just a one-shot start-thread, do state change, exit thread approach without any main context / main loop iteration) - depends how often this is needed I guess.
I'm working on the detaching with appsink/appsrc.
Created attachment 185155 [details] [review] tentative patch, causes problems still
Created attachment 185211 [details] [review] camerabin: don't rely on the application running the default GLib main loop Improved patch, no more failures. Now it checks if the pad still exists when trying to unblock it.
commit 9c5863ad3548cec9064b1b3edf04ddded70f1846 Author: Tim-Philipp Müller <tim.muller@collabora.co.uk> Date: Wed Dec 15 10:39:24 2010 +0000 camerabin: don't rely on the application running the default GLib main loop Don't use g_idle_add() and friends to schedule things we can't do from the streaming thread in another thread. The app may not be running the default GLib main loop. Instead, just spawn a thread. Also, we need to care for when acessing a pad variable, as another thread might have taken camerabin to NULL while this gst_camerabin_imgbin_finished didn't run. https://bugzilla.gnome.org/show_bug.cgi?id=615655