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 785518 - rpi, gl: eglCreateImageKHR failing
rpi, gl: eglCreateImageKHR failing
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-07-28 08:40 UTC by Guillaume Desmottes
Modified: 2018-05-31 17:02 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Guillaume Desmottes 2017-07-28 08:40:15 UTC
I built gst master on pi with those settings:

  gst-plugins-bad:with_egl_module_name       /opt/vc/lib/libEGL.so                                                    The file to pass to g_module_open to open the libEGL.so library (default: libEGL.so)
  gst-plugins-bad:with_gl_api                gles2                                                                    A comma separated list of opengl APIs to enable building against. Supported values are opengl and gles2.
  gst-plugins-bad:with_gl_platform           egl                                                                      A comma separated list of opengl platforms to enable building against. Supported values are glx, egl, cgl, wgl and eagl
  gst-plugins-bad:with_gl_winsys             dispmanx                                                                 A comma separated list of opengl windows systems to enable building against. Supported values are x11, wayland, win32, cocoa, and dispmanx
  gst-plugins-bad:with_gles2_module_name     /opt/vc/lib/libGLESv2.so                                                 The file to pass to g_module_open to open the libGLESv2.so library (default: libGLESv2.so)
  gst-plugins-bad:with_opengl_module_name                                                                             The file to pass to g_module_open to open the libGL.so library (default: libGL.so)

Those pipelines are working fine:
  gst-launch-1.0 videotestsrc ! glimagesink
  gst-launch-1.0 videotestsrc ! omxh264enc ! queue ! omxh264dec ! queue ! glimagesink

But this one is not:

$ gst-launch-1.0 -v filesrc location=../medias/short-hd.h264 ! h264parse ! omxh264dec ! queue ! glimagesink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Got context from element 'sink': gst.gl.GLDisplay=context, gst.gl.GLDisplay=(GstGLDisplay)"\(GstGLDisplayEGL\)\ gldisplayegl0";
/GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:src: caps = video/x-h264, pixel-aspect-ratio=(fraction)1/1, width=(int)1920, height=(int)1080, framerate=(fraction)60/1, parsed=(boolean)true, stream-format=(string)byte-stream, alignment=(string)au, profile=(string)baseline, level=(string)4.2
/GstPipeline:pipeline0/GstOMXH264Dec-omxh264dec:omxh264dec-omxh264dec0.GstPad:sink: caps = video/x-h264, pixel-aspect-ratio=(fraction)1/1, width=(int)1920, height=(int)1080, framerate=(fraction)60/1, parsed=(boolean)true, stream-format=(string)byte-stream, alignment=(string)au, profile=(string)baseline, level=(string)4.2
/GstPipeline:pipeline0/GstOMXH264Dec-omxh264dec:omxh264dec-omxh264dec0.GstPad:src: caps = video/x-raw(memory:GLMemory), format=(string)RGBA, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)sRGB, framerate=(fraction)60/1
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:sink: caps = video/x-raw(memory:GLMemory), format=(string)RGBA, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)sRGB, framerate=(fraction)60/1
/GstPipeline:pipeline0/GstQueue:queue0.GstPad:sink: caps = video/x-raw(memory:GLMemory), format=(string)RGBA, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)sRGB, framerate=(fraction)60/1
/GstPipeline:pipeline0/GstGLImageSinkBin:glimagesinkbin0.GstGhostPad:sink.GstProxyPad:proxypad0: caps = video/x-raw(memory:GLMemory), format=(string)RGBA, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)sRGB, framerate=(fraction)60/1
/GstPipeline:pipeline0/GstGLImageSinkBin:glimagesinkbin0/GstGLUploadElement:gluploadelement0.GstPad:src: caps = video/x-raw(memory:GLMemory), width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)60/1, format=(string)RGBA, texture-target=(string)2D, colorimetry=(string)sRGB
/GstPipeline:pipeline0/GstGLImageSinkBin:glimagesinkbin0/GstGLColorConvertElement:glcolorconvertelement0.GstPad:src: caps = video/x-raw(memory:GLMemory), width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)60/1, format=(string)RGBA, texture-target=(string)2D, colorimetry=(string)sRGB
/GstPipeline:pipeline0/GstGLImageSinkBin:glimagesinkbin0/GstGLColorBalance:glcolorbalance0.GstPad:src: caps = video/x-raw(memory:GLMemory), width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)60/1, format=(string)RGBA, texture-target=(string)2D, colorimetry=(string)sRGB
/GstPipeline:pipeline0/GstGLImageSinkBin:glimagesinkbin0/GstGLImageSink:sink.GstPad:sink: caps = video/x-raw(memory:GLMemory), width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)60/1, format=(string)RGBA, texture-target=(string)2D, colorimetry=(string)sRGB
/GstPipeline:pipeline0/GstGLImageSinkBin:glimagesinkbin0/GstGLColorBalance:glcolorbalance0.GstPad:sink: caps = video/x-raw(memory:GLMemory), width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)60/1, format=(string)RGBA, texture-target=(string)2D, colorimetry=(string)sRGB
/GstPipeline:pipeline0/GstGLImageSinkBin:glimagesinkbin0/GstGLColorConvertElement:glcolorconvertelement0.GstPad:sink: caps = video/x-raw(memory:GLMemory), width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)60/1, format=(string)RGBA, texture-target=(string)2D, colorimetry=(string)sRGB
eglCreateImageKHR:  failed to create image for buffer 0x1 target 12465 error 0x300c
0:00:00.420248019 11105   0x7ccc00 ERROR           glbasememory gstglbasememory.c:97:_mem_create_gl: Failed to create GL buffer: Failed to create EGLImage
0:00:00.420357549 11105 0x71502260 ERROR           glbasememory gstglbasememory.c:171:gst_gl_base_memory_init: Could not create GL buffer with context:0x7db8d8
/GstPipeline:pipeline0/GstGLImageSinkBin:glimagesinkbin0/GstGLUploadElement:gluploadelement0.GstPad:sink: caps = video/x-raw(memory:GLMemory), format=(string)RGBA, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)sRGB, framerate=(fraction)60/1
/GstPipeline:pipeline0/GstGLImageSinkBin:glimagesinkbin0.GstGhostPad:sink: caps = video/x-raw(memory:GLMemory), format=(string)RGBA, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)sRGB, framerate=(fraction)60/1

** (gst-launch-1.0:11105): CRITICAL **: gst_egl_image_get_image: assertion 'GST_IS_EGL_IMAGE (image)' failed
eglCreateImageKHR:  failed to create image for buffer 0x2 target 12465 error 0x300c
0:00:00.428211972 11105   0x7ccc00 ERROR           glbasememory gstglbasememory.c:97:_mem_create_gl: Failed to create GL buffer: Failed to create EGLImage
0:00:00.428285513 11105 0x71502260 ERROR           glbasememory gstglbasememory.c:171:gst_gl_base_memory_init: Could not create GL buffer with context:0x7db8d8
Comment 1 Guillaume Desmottes 2017-07-28 09:21:00 UTC
Same problem when using a mp4 file containing a 720p H264 video.
Comment 2 Nicolas Dufresne (ndufresne) 2017-07-28 12:48:36 UTC
Have chez that RPI EGL is loaded and not Mesa?
Comment 3 Julien Isorce 2017-07-28 20:30:17 UTC
Maybe not enough gpu mem by default, can you try to set gpu_mem=512 in /boot/config.txt ?

In order to use less gpu memory (FBO) there is a GstGL bug tracker here https://bugzilla.gnome.org/show_bug.cgi?id=730927
Comment 4 Guillaume Desmottes 2017-07-31 08:07:46 UTC
(In reply to Nicolas Dufresne (stormer) from comment #2)
> Have chez that RPI EGL is loaded and not Mesa?

I think so:

0:00:00.352933542  1623  0x13c8000 INFO               glcontext gstglcontext.c:1259:gst_gl_context_create_thread:<glcontextegl0> available GL APIs: gles2
0:00:00.352995989  1623  0x13c8000 DEBUG              glcontext gstglcontext.c:1278:gst_gl_context_create_thread:<glcontextegl0> Filling info
0:00:00.353503016  1623  0x13c8000 INFO               glcontext gstglcontext.c:1072:_create_context_info:<glcontextegl0> GL_VERSION: OpenGL ES 2.0
0:00:00.353573433  1623  0x13c8000 INFO               glcontext gstglcontext.c:1075:_create_context_info:<glcontextegl0> GL_SHADING_LANGUAGE_VERSION: OpenGL ES GLSL ES 1.00
0:00:00.353626766  1623  0x13c8000 INFO               glcontext gstglcontext.c:1077:_create_context_info:<glcontextegl0> GL_VENDOR: Broadcom

(In reply to Julien Isorce from comment #3)
> Maybe not enough gpu mem by default, can you try to set gpu_mem=512 in
> /boot/config.txt ?
> 
> In order to use less gpu memory (FBO) there is a GstGL bug tracker here
> https://bugzilla.gnome.org/show_bug.cgi?id=730927

Indeed, that did the trick thanks!

Should I close this as a dup of bug #730927 then?
Comment 5 Julien Isorce 2017-07-31 09:46:21 UTC
> (In reply to Julien Isorce from comment #3)
> > Maybe not enough gpu mem by default, can you try to set gpu_mem=512 in
> > /boot/config.txt ?
> > 
> > In order to use less gpu memory (FBO) there is a GstGL bug tracker here
> > https://bugzilla.gnome.org/show_bug.cgi?id=730927
> 
> Indeed, that did the trick thanks!

Great! Could you check if the assert "CRITICAL **: gst_egl_image_get_image:" comes from the call of gst_gl_memory_egl_get_image from gstomxvideodec.c ? If yes then there is a bug in GstGL because it means that gstomxvideodec.c::gst_buffer_pool_acquire_buffer succeeded. So I think GstGL's gst_gl_buffer_pool_alloc should not return GST_FLOW_OK in this case.

Also I wonder how we could improve the out of mem detection.
There is the message "eglCreateImageKHR:  failed to create image for buffer 0x1 target 12465 error 0x300c", but it is not from GstGL right ?
0x300c -> EGL_BAD_PARAMETER

Ideally it should have return EGL_BAD_ALLOC
"If insufficient memory is available to complete the specified operation, the error EGL_BAD_ALLOC is generated."
So that it points to the action which is to increase mem.

Also eglCreateImage should only increment a reference counter so it could be that gstglmemory.c::_gl_tex_create could have catch GL_OUT_OF_MEMORY in the first place.

> 
> Should I close this as a dup of bug #730927 then?

I am not sure because that other bug mentions that this is for the YUV cases. Can you count how many times gl->GenFramebuffers is called ? If 0 then not a duplicate.
(also note that the hw decoder also uses some gpu mem)
Comment 6 Guillaume Desmottes 2017-07-31 13:30:28 UTC
(In reply to Julien Isorce from comment #5)
> Great! Could you check if the assert "CRITICAL **: gst_egl_image_get_image:"
> comes from the call of gst_gl_memory_egl_get_image from gstomxvideodec.c ?

Looks like it:

0  raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:51
  • #1 g_logv
    from /lib/arm-linux-gnueabihf/libglib-2.0.so.0
  • #2 g_log
    from /lib/arm-linux-gnueabihf/libglib-2.0.so.0
  • #3 g_return_if_fail_warning
    from /lib/arm-linux-gnueabihf/libglib-2.0.so.0
  • #4 gst_egl_image_get_image
    at ../subprojects/gst-plugins-bad/gst-libs/gst/gl/egl/gsteglimage.c line 113
  • #5 gst_gl_memory_egl_get_image
    at ../subprojects/gst-plugins-bad/gst-libs/gst/gl/egl/gstglmemoryegl.c line 88
  • #6 gst_omx_video_dec_allocate_output_buffers
    at ../omx/gstomxvideodec.c line 687
  • #7 gst_omx_video_dec_reconfigure_output_port
    at ../omx/gstomxvideodec.c line 1167
  • #8 gst_omx_video_dec_loop
    at ../omx/gstomxvideodec.c line 1432
  • #9 gst_task_func
    at ../subprojects/gstreamer/gst/gsttask.c line 332
  • #10 default_func
    at ../subprojects/gstreamer/gst/gsttaskpool.c line 69
  • #11 ??
    from /lib/arm-linux-gnueabihf/libglib-2.0.so.0

> If yes then there is a bug in GstGL because it means that
> gstomxvideodec.c::gst_buffer_pool_acquire_buffer succeeded. So I think
> GstGL's gst_gl_buffer_pool_alloc should not return GST_FLOW_OK in this case.

Indeed, looks like acquire_buffer() succeeded.

> Also I wonder how we could improve the out of mem detection.
> There is the message "eglCreateImageKHR:  failed to create image for buffer
> 0x1 target 12465 error 0x300c", but it is not from GstGL right ?
> 0x300c -> EGL_BAD_PARAMETER

I'm not sure where it's from actually; I'm not familiar with GstGL.
Here are the logs:

0:00:04.011831351 11665  0x1e6c000 LOG                gldisplay gstgldisplay_egl.c:252:gst_gl_display_egl_from_gl_display:<gldisplayegl0> display <gldisplayegl0>is already a GstGLDisplayEGL
eglCreateImageKHR:  failed to create image for buffer 0x1 target 12465 error 0x300c
0:00:04.012813011 11665  0x1e6c000 ERROR           glbasememory gstglbasememory.c:97:_mem_create_gl: Failed to create GL buffer: Failed to create EGLImage
0:00:04.012952593 11665 0x70a02090 ERROR           glbasememory gstglbasememory.c:171:gst_gl_base_memory_init: Could not create GL buffer with context:0x1e75880


> Can you count how many times gl->GenFramebuffers is called ? If 0
> then not a duplicate.
> (also note that the hw decoder also uses some gpu mem)

Looks like it's not called.
Comment 7 Julien Isorce 2017-07-31 14:12:10 UTC
Thx for checking.

Can you try this for GstGL in -bad ?

--- a/gst-libs/gst/gl/egl/gstglmemoryegl.c
+++ b/gst-libs/gst/gl/egl/gstglmemoryegl.c
@@ -160,6 +160,11 @@ _gl_mem_egl_alloc (GstGLBaseMemoryAllocator * allocator,
       params->parent.alloc_params, params->v_info, params->plane,
       params->valign, params->parent.user_data, params->parent.notify);
 
+  if (!gl_mem->image) {
+    gst_allocator_free (GST_ALLOCATOR_CAST (allocator), GST_GL_MEMORY_CAST (mem));
+    return NULL;
+  }
+
   return mem;
 }

Hopefully this makes pool acquire_buffer to fail so that there is no critical.

According to https://bugzilla.gnome.org/show_bug.cgi?id=729588 it was fixed so gpu_mem=128 worked for 1080p. If it does not work now then it is a regression again.
Can you try gst-launch-1.0 filesrc location=short-hd.h264 ! h264parse ! omxh264dec ! glupload ! "video/x-raw(memory:GLMemory)" ! fakesink ?
Comment 8 Guillaume Desmottes 2017-08-01 07:50:22 UTC
(In reply to Julien Isorce from comment #7)
> Hopefully this makes pool acquire_buffer to fail so that there is no
> critical.

Yes it does.

> According to https://bugzilla.gnome.org/show_bug.cgi?id=729588 it was fixed
> so gpu_mem=128 worked for 1080p. If it does not work now then it is a
> regression again.
> Can you try gst-launch-1.0 filesrc location=short-hd.h264 ! h264parse !
> omxh264dec ! glupload ! "video/x-raw(memory:GLMemory)" ! fakesink ?

Yes it works with gpu_mem=128
Comment 9 Julien Isorce 2017-08-01 09:39:33 UTC
(In reply to Guillaume Desmottes from comment #8)
> (In reply to Julien Isorce from comment #7)
> > Hopefully this makes pool acquire_buffer to fail so that there is no
> > critical.
> 
> Yes it does.
> 

commit b89c94b37eda4e9c093b159d6536bbef2ef30e27
Author: Julien Isorce <jisorce@oblong.com>
Date:   Tue Aug 1 10:21:51 2017 +0100

    gl: return NULL mem if eglCreateImage failed
    
    Found on rpi when gpu_mem is too low so there is not enough memory to
    create the eglimage. But still gst_buffer_pool_acquire_buffer succeeded.
    And it leads to a CRITICAL assert:
      gst_egl_image_get_image: assertion 'GST_IS_EGL_IMAGE (image)' failed
    
    https://bugzilla.gnome.org/show_bug.cgi?id=785518
Comment 10 Matthew Waters (ystreet00) 2018-02-09 01:24:40 UTC
So, is this fixed now?
Comment 11 Guillaume Desmottes 2018-05-31 14:48:34 UTC
The assertion has been fixed but playing a HD stream isn't still working by default (need to set gpu_mem=512).
Comment 12 Julien Isorce 2018-05-31 17:02:04 UTC
I think we should profile how many textures other gl objects are in use, to check how we could minimize their use or re-use them.