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 727843 - glimagesink: shows only a black screen
glimagesink: shows only a black screen
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other other
: Normal normal
: 1.3.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-04-08 16:05 UTC by Andoni Morales
Modified: 2014-04-12 20:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
just prepare next patch (2.38 KB, patch)
2014-04-11 09:00 UTC, Julien Isorce
none Details | Review
init GstContext GObject in the main thread (1.72 KB, patch)
2014-04-11 09:01 UTC, Julien Isorce
none Details | Review

Description Andoni Morales 2014-04-08 16:05:57 UTC
glimagkesink shows only a black screen in Android. This can be reproduced with videotestsrc ! glimagesink
Comment 1 Sebastian Dröge (slomo) 2014-04-08 17:04:09 UTC
Sounds like what I had on iOS with EAGL too: bug #703341
Comment 2 Julien Isorce 2014-04-08 22:39:56 UTC
(In reply to comment #0)
> glimagkesink shows only a black screen in Android. This can be reproduced with
> videotestsrc ! glimagesink

Matthew pointed that gstgl uses vertex attributes  whereas eglglessink uses VBO. Have you tried thoses gstgl checks http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/tests/check/libs ?

Also try other formats, videotestsrc !  "video/x-raw, format=f" ! glimagesink
for RGB, RGBA, YV12, NV12, I420, YUY2, UYVY .

You could also try  videotestsrc num-buffers=1 ! glcolorscale ! pngenc ! filesink location=res.png

I wonder if on Android there are  global env vars to turn on gl debug like with mesa: http://www.mesa3d.org/envvars.html
Comment 3 Andoni Morales 2014-04-09 09:16:22 UTC
I  tried all the formats and none of them worked.
It's a bit complicated to run the tests in Android, my device is not rooted and I can't run the tests.
This pipeline generated a file with 0 size.
videotestsrc num-buffers=1 ! glcolorscale ! pngenc ! filesink location=res.png
Comment 4 Matthew Waters (ystreet00) 2014-04-10 05:43:43 UTC
git bisect says:

commit 82b7c915bb02a9790d256d599452e5a54afda633
Author: Sebastian Dröge <sebastian@centricular.com>
Date:   Sun Apr 6 11:57:12 2014 +0200

    glimagesink: Create GL context and set up window from the streaming thread
    
    gst_gl_context_create() might need to dispatch some operations to the
    application's main thread, and calling this in the change_state function
    can cause deadlocks.

So it would seem that there's some funky thread affinity going on here.

What was the reason you needed this for the EAGL stuff Sebastian?
Comment 5 Sebastian Dröge (slomo) 2014-04-10 06:49:37 UTC
Hmm, that change works for me on my laptop.


The reason for that change is that glimagesink's state change function is called from the application thread, creates the GL context and waits for it to be created in another thread. For EAGL I will need to call something in the application thread during the GL context creation, so would deadlock because of that. The GL context thread is waiting for stuff to be done on the application thread, the application thread is waiting for the GL context thread is waiting for the application thread to do something.
Comment 6 Matthew Waters (ystreet00) 2014-04-10 06:55:01 UTC
It works on my laptop also.  Not on my android device though.
Comment 7 Sebastian Dröge (slomo) 2014-04-10 07:36:13 UTC
Right, I was wondering how you reproduced it :) Ok, so that is likely the problem on EAGL too... now just need to find the reason and a way to fix that without breaking EAGL even more ;)
Comment 8 Julien Isorce 2014-04-11 09:00:52 UTC
Created attachment 274069 [details] [review]
just prepare next patch
Comment 9 Julien Isorce 2014-04-11 09:01:45 UTC
Created attachment 274070 [details] [review]
init GstContext GObject in the main thread
Comment 10 Julien Isorce 2014-04-11 09:08:52 UTC
please try those 2 patches, it at least fixes a regression introduced by "glimagesink: Create GL context and set up window from the streaming thread" on OSX when running videotestsrc ! glimagesink. I could not click on the window close cross anymore or do any resizing. 

When debugging and trying to find a solution I found that just initializing the GObject/GstGLContext in the main thread makes it work again. But at this time I cannot explain correctly why.  I have just some guess.
Comment 11 Sebastian Dröge (slomo) 2014-04-11 09:32:18 UTC
Looks ok from an EAGL point of view. As long as _create() is called not from the app thread (state change thread) and the app thread is not blocked during _create() it should work.

Will test on iOS this evening.
Comment 12 Sebastian Dröge (slomo) 2014-04-11 09:32:31 UTC
Also before merging that we should understand why :)
Comment 13 Andoni Morales 2014-04-11 10:38:51 UTC
In android I have the following errors now with these patches and current master

04-11 12:37:13.562: I/GStreamer+glupload(7603): 0:00:00.272685469 0x75758180 gstglupload.c:1025:_init_upload_fbo Context, EXT_framebuffer_object supported: yes
04-11 12:37:13.562: W/Adreno-ES20(7603): <core_glRenderbufferStorage:637>: GL_INVALID_VALUE
04-11 12:37:13.562: E/GStreamer+default(7603): 0:00:00.274935729 0x75758180 gstglutils.c:72:gst_gl_context_check_framebuffer_status GL_FRAMEBUFFER_UNSUPPORTED
04-11 12:37:13.562: W/GStreamer+default(7603): 0:00:00.275088281 0x75758180 gstglutils.c:520:gst_gl_context_set_error GL framebuffer status incomplete
04-11 12:37:13.562: W/GStreamer+glimagesink(7603): 0:00:00.275298541 0x7574dd20 gstglimagesink.c:456:_ensure_gl_setup:<glimagesink0> error: Failed to init upload
Comment 14 Andoni Morales 2014-04-11 10:47:38 UTC
My libgstgl.a was not up-to-date, testing again
Comment 15 Andoni Morales 2014-04-11 11:03:44 UTC
I get the same results of a black window with the new patches in android
Comment 16 Julien Isorce 2014-04-12 14:56:39 UTC
(In reply to comment #15)
> I get the same results of a black window with the new patches in android
Ok thx for trying, also that make senses it did not resolve the problem :)  The magic thing around initializing GstGLContext in the main thread or not was actually because it was calling [NSApplication sharedApplication] in GstGLContextCocoaClass :)
Comment 17 Sebastian Dröge (slomo) 2014-04-12 15:09:44 UTC
This here maybe fixes it:

commit 0bd53c9ccbb71f33e48bb90a7ae3587a1fae49c4
Author: Sebastian Dröge <sebastian@centricular.com>
Date:   Sat Apr 12 17:01:09 2014 +0200

    glimagesink: First handle GL window setup, then create the context and its thread


Currently rebuilding the EAGL backend for testing...
Comment 18 Sebastian Dröge (slomo) 2014-04-12 19:36:13 UTC
Yes, works now.