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 728514 - glimagesink fails with gst-sdk android tutorial-5 / tutorial-4
glimagesink fails with gst-sdk android tutorial-5 / tutorial-4
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal blocker
: 1.3.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-04-18 15:51 UTC by Jan Schmidt
Modified: 2014-05-27 13:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
logcat output (67.93 KB, text/x-c)
2014-04-18 15:51 UTC, Jan Schmidt
  Details
gl/context: test eglTerminate needed for egl_destroy_context (1.17 KB, patch)
2014-05-23 07:16 UTC, Matthew Waters (ystreet00)
needs-work Details | Review

Description Jan Schmidt 2014-04-18 15:51:16 UTC
Created attachment 274681 [details]
logcat output

I was trying android tutorial-5 and the new glimagesink egl support, and I get:

D/GStreamer+glimagesink(20877): 0:00:15.210321675 0x59c3c430 gstglimagesink.c:680:gst_glimage_sink_set_caps keeping video height
D/GStreamer+glimagesink(20877): 0:00:15.210401175 0x59c3c430 gstglimagesink.c:698:gst_glimage_sink_set_caps scaling to 854x366
I/GStreamer+glcontext(20877): 0:00:15.210481633 0x59c3c430 gstglcontext.c:209:gst_gl_context_new creating a context, user choice:(null)
I/GStreamer+glwindow(20877): 0:00:15.210578050 0x59c3c430 gstglwindow.c:158:gst_gl_window_new creating a window, user choice:(null)
D/GStreamer+glwindow(20877): 0:00:15.210648425 0x59c3c430 gstglwindow_android_egl.c:90:gst_gl_window_android_egl_new creating Android EGL window
I/GStreamer+glcontext(20877): 0:00:15.211040258 0x59967200 gstglcontext.c:750:gst_gl_context_create_thread Attempting to create opengl context. user chosen api(s) (any), compiled api support (gles2)
E/BufferQueue( 2134): [SurfaceView] connect: already connected (cur=1, req=1)
E/libEGL  (20877): EGLNativeWindowType 0x5b244808 already connected to another API
E/libEGL  (20877): eglCreateWindowSurface:376 error 300b (EGL_BAD_NATIVE_WINDOW)
I/GStreamer+glcontext(20877): 0:00:15.211670925 0x59c3c430 gstglcontext.c:555:gst_gl_context_create gl thread created
W/GStreamer+glimagesink(20877): 0:00:15.211783925 0x59c3c430 gstglimagesink.c:459:_ensure_gl_setup:<glimagesink0> error: Failed to create window surface: EGL_BAD_NATIVE_WINDOW
D/GStreamer+tutorial-5(20877): 0:00:15.212146258 0x59621a60 jni/tutorial-5.c:105:set_ui_message Setting message to: Error received from element glimagesink0: Failed to create window surface: EGL_BAD_NATIVE_WINDOW

Tutorial-3 works OK. There are other relevant errors earlier in the log. Attaching a full log
Comment 1 Jan Schmidt 2014-04-21 13:22:18 UTC
I tested some more, and glimagesink works on Android 4.2, and fails on 4.3 and 4.4.

eglglessink definitely worked on Android 4.3. I didn't get a chance to test it on Android 4.4
Comment 2 Sebastian Dröge (slomo) 2014-04-21 13:55:44 UTC
eglglessink also worked on Android 4.4.
Comment 3 Sebastian Dröge (slomo) 2014-04-21 14:37:37 UTC
Also tutorial 4/5 seem to have some more problems, especially around buffering. And even when using local files, it sometimes deadlocks e.g. when seeking. Definitely something to investigate before we can release 1.4.0.
Comment 4 Matthew Waters (ystreet00) 2014-05-23 07:06:56 UTC
The obvious thing that stands out is that it attempts to set_window_handle() with the same window id across multiple contexts.  The second one results in a BAD_NATIVE_WINDOW error with it complaining that the window is already connected to 'another API'.

Just a stab in the dark but this might be due to us not calling eglTerminate () at the end of the first context.  Could someone test by adding eglTerminate() to the end of gst_gl_context_egl_destroy_context() ?
Comment 5 Matthew Waters (ystreet00) 2014-05-23 07:16:24 UTC
Created attachment 277033 [details] [review]
gl/context: test eglTerminate needed for egl_destroy_context

You'll also need to get an eglDisplay in create_context like so.
Comment 6 Sebastian Dröge (slomo) 2014-05-23 07:46:04 UTC
Hmm I don't think we destroy the context here, do we? We just set the same window handle again
Comment 7 Sebastian Dröge (slomo) 2014-05-23 07:47:41 UTC
Review of attachment 277033 [details] [review]:

::: gst-libs/gst/gl/egl/gstglcontext_egl.c
@@ +456,2 @@
   eglReleaseThread ();
+  eglTerminate ();

It takes a display as parameter :) I'm not sure if this is 100% correct though, shouldn't this be just called when destroying the display?
Comment 8 Matthew Waters (ystreet00) 2014-05-23 07:55:57 UTC
(In reply to comment #6)
> Hmm I don't think we destroy the context here, do we? We just set the same
> window handle again

The full log shows that the context was destroyed and recreated but the display was not destroyed and existed through the whole process.

(In reply to comment #7)
> Review of attachment 277033 [details] [review]:
> 
> ::: gst-libs/gst/gl/egl/gstglcontext_egl.c
> @@ +456,2 @@
>    eglReleaseThread ();
> +  eglTerminate ();
> 
> It takes a display as parameter :) I'm not sure if this is 100% correct though,
> shouldn't this be just called when destroying the display?

Ideally, yes.  However it is just a hunch that the eglTerminate is required by android when all of the contexts/surfaces are destroyed.  If so then we need to figure out why the display still sticks around.
Comment 9 Sebastian Dröge (slomo) 2014-05-23 10:06:42 UTC
It works here now even without that change. Jan, can you confirm?
Comment 10 Jan Schmidt 2014-05-26 14:20:16 UTC
No, it's still broken for me using Tutorial-5 on Android 4.4, with a cerbero build as of gst-plugins-bad commit #f34894
Comment 11 Matthew Waters (ystreet00) 2014-05-27 00:50:12 UTC
Does this fix it ?

commit dad342454b450afaf80af9376880ad5065449ebb
Author: Matthew Waters <ystreet00@gmail.com>
Date:   Tue May 27 10:47:25 2014 +1000

    gl/context_egl: pass the vars in the right order to DestroySurface
    
    https://bugzilla.gnome.org/show_bug.cgi?id=728514
Comment 12 Jan Schmidt 2014-05-27 08:03:07 UTC
No, although now I also get:

I/GStreamer+glwindow( 3049): 0:00:10.038543701 0x75e0c5a0 gstglwindow.c:320:gst_gl_window_quit quit sent to gl window loop
E/libEGL  ( 3049): validate_display:254 error 3008 (EGL_BAD_DISPLAY)

and

I/GStreamer+glcontext( 3049): 0:00:16.337402343 0x77203290 gstglcontext.c:880:gst_gl_context_create_thread loop exited
I/GStreamer+glcontext( 3049): 
E/libEGL  ( 3049): validate_display:254 error 3008 (EGL_BAD_DISPLAY)
I/GStreamer+glcontext( 3049): 0:00:16.339630126 0x75eb2200 gstglcontext.c:357:gst_gl_context_finalize gl thread joined
Comment 13 Matthieu Bouron 2014-05-27 10:45:54 UTC
(In reply to comment #11)
> Does this fix it ?

It fixes the issue for me. I've tested with latest master on a nexus4.
Thanks !
Comment 14 Jan Schmidt 2014-05-27 13:48:33 UTC
I'm sorry - after a clean rebuild of the SDK, it's working for me too. I must have messed up my earlier test.

Good job spotting that one, Matthew :)