After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 768630 - CGLCreateContext hangs on a lock with context sharing and java (maybe CFRunLoop issues?)
CGLCreateContext hangs on a lock with context sharing and java (maybe CFRunLo...
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
1.8.1
Other Mac OS
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-07-10 11:13 UTC by gohai
Modified: 2018-11-03 11:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Trace with GDB_DEBUG=*:5 (gzipped for size) (386.33 KB, application/x-gzip)
2016-07-10 11:17 UTC, gohai
Details
Backtrace of all threads (15.73 KB, text/plain)
2016-07-10 15:17 UTC, gohai
Details
Backtrace of all threads w/ lldb (49.29 KB, text/plain)
2016-07-11 12:12 UTC, gohai
Details
GST_DEBUG for seek before second stream has a frame ready (725.97 KB, application/zip)
2016-10-08 13:49 UTC, Andres Colubri
Details
GST_DEBUG for seek after second stream has a frame ready (2.66 MB, application/zip)
2016-10-08 13:50 UTC, Andres Colubri
Details
GST_DEBUG using seek before second stream has frame ready (690.64 KB, application/zip)
2016-10-08 15:05 UTC, Andres Colubri
Details
GST_DEBUG using seek after second stream has frame ready (2.98 MB, application/zip)
2016-10-08 15:06 UTC, Andres Colubri
Details

Description gohai 2016-07-10 11:13:15 UTC
I have a playbin-pipeline of a local file, which is initially being set to paused to allow for seeking etc. When I call gst_element_get_state() afterwards, to wait for the asynchronous state change to succeed this hangs forever.

My application uses GL context sharing. Marcin spotted the following line in the logs, which he thought was suspicious "pad_query:<glcolorconvertelement0:src> pad peer query failed". Indeed, when I remove the glcolorconvert from the pipeline, the problem (hang) disappears.


You find the setup of the application's pipeline here:
https://github.com/gohai/processing-glvideo/blob/b8bc94f59630b010e52fe25846e1c5423c8398dd/src/native/impl.c#L240

I am attaching a GST_DEBUG=*:5 trace. When I gdb the process as it hangs I find the following two threads that are gstreamer-related:


Comment 1 gohai 2016-07-10 11:17:24 UTC
Created attachment 331155 [details]
Trace with GDB_DEBUG=*:5 (gzipped for size)
Comment 2 Matthew Waters (ystreet00) 2016-07-10 13:08:23 UTC
So, CGLCreateContext () is the most likely cause of this which would require that you are pumping the CFRunLoop to be able to continue.

1. It seems from the log you're using the binaries from the GStreamer project correct?
2. I also need a backtrace of all the threads to see what's happening on the main thread.
Comment 3 gohai 2016-07-10 15:17:03 UTC
1. Yes, I am using the binaries provided.
2. Attaching output of "thread apply all backtrace" below.

Is there anything I can do to pump CFRunLoop myself? (e.g. by timing out the wait every couple of ms to do so)
Comment 4 gohai 2016-07-10 15:17:34 UTC
Created attachment 331162 [details]
Backtrace of all threads
Comment 5 Matthew Waters (ystreet00) 2016-07-11 01:48:44 UTC
That backtrace isn't all that useful.  Can you get one using lldb instead?

For CFRunLoop, look at the documentation: https://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFRunLoopRef/

You'll probably also have to figure out what Java is doing with the CFRunloop in order to integrate them properly.
Comment 6 gohai 2016-07-11 12:11:08 UTC
I am attaching a backtrace with lldb below.
Comment 7 gohai 2016-07-11 12:12:08 UTC
Created attachment 331211 [details]
Backtrace of all threads w/ lldb
Comment 8 gohai 2016-07-12 12:19:01 UTC
I haven't found code that would let me believe that CFRunLoop is somehow used within the JOGL NEWT windowing toolkit, or within OpenJDK.

Calling CFRunLoopGetCurrent() and CFRunLoopGetMain() before I wait for the state change hands me two different, non-NULL pointers back.

I also tried calling CFRunLoopRunInMode() myself, but so far this hasn't made a difference.

(see https://github.com/gohai/processing-glvideo/commit/d31ca59732b463d4745b8dacce065bae9dce0a35)
Comment 9 Matthew Waters (ystreet00) 2016-07-14 07:15:45 UTC
(In reply to gohai from comment #8)
> I haven't found code that would let me believe that CFRunLoop is somehow
> used within the JOGL NEWT windowing toolkit, or within OpenJDK.

It does because it's in your backtrace. Look at thread 1 in the lldb backtrace.

> Calling CFRunLoopGetCurrent() and CFRunLoopGetMain() before I wait for the
> state change hands me two different, non-NULL pointers back.

That could be problematic.

> I also tried calling CFRunLoopRunInMode() myself, but so far this hasn't
> made a difference.

I doubt this would achieve anything.  You probably need to make the main CFRunLoop iterate somehow.

http://stackoverflow.com/questions/8750690/osx-javavm-awt-swing-and-possibly-a-deadlock sounds very similar to what may happen in your case.
Comment 10 gohai 2016-07-14 08:55:26 UTC
You're right about the other CFRunLoop. It seems to be created by the Java launcher, specifically CreateExecutionEnvironment inside java_md.c. Unfortunately I haven't been able to find a the source for the very implementation (Darwin on Oracle's JRE).

I tried to wake up the main run loop instead, to no avail: https://github.com/gohai/processing-glvideo/commit/eb6cd587e9254dee6735a24601c5c324d0b0f496
Comment 11 gohai 2016-08-02 23:21:38 UTC
Anything else that I can provide to move this bug off NEEDINFO?
Comment 12 Sebastian Dröge (slomo) 2016-08-03 05:27:49 UTC
Can you try to create an Obj-C testcase that reproduces exactly the situation that happens with Java? That would make it easier for someone to look into this and think of possible solutions.
Comment 13 gohai 2016-08-03 10:59:06 UTC
Hi Sebastian. Unfortunately I haven't done any Obj-C or OS X development so far, so it's unlikely I'll be able to put together a test-case for that, sorry.
Comment 14 Andres Colubri 2016-10-08 13:47:23 UTC
Hi guys, it turns our that if you run the seek operation AFTER the second stream has an available frame, then there is no hang.

Matt (sitting with me at the same table) suggested that I generate the GST_DEBUG outputs for the after and before situations, which I did. I'm attaching those two files.
Comment 15 Andres Colubri 2016-10-08 13:49:59 UTC
Created attachment 337223 [details]
GST_DEBUG for seek before second stream has a frame ready

This one hangs
Comment 16 Andres Colubri 2016-10-08 13:50:59 UTC
Created attachment 337224 [details]
GST_DEBUG for seek after second stream has a frame ready

This one does not hang
Comment 17 Andres Colubri 2016-10-08 15:05:32 UTC
Created attachment 337228 [details]
GST_DEBUG using seek before second stream has frame ready
Comment 18 Andres Colubri 2016-10-08 15:06:23 UTC
Created attachment 337229 [details]
GST_DEBUG using seek after second stream has frame ready
Comment 19 Andres Colubri 2016-10-11 08:04:45 UTC
Tested GLVideo using a global gst_display object (https://github.com/gohai/processing-glvideo/commit/2ad5b1fe2c7aba112e254e6f343c8a983038c3ce), and a build of GStreamer 1.9.90 with GSTREAMER_GLIB_COCOA_NSAPPLICATION disabled in the recipe for gst-plugins-bad, but the two video tesst case still hangs after performing a seek operation before the stream being ready.
Comment 20 GStreamer system administrator 2018-11-03 11:47:44 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/275.