GNOME Bugzilla – Bug 785518
rpi, gl: eglCreateImageKHR failing
Last modified: 2018-05-31 17:02:04 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
Same problem when using a mp4 file containing a 720p H264 video.
Have chez that RPI EGL is loaded and not Mesa?
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
(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?
> (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)
(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
+ Trace 237734
> 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.
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 ?
(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
(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
So, is this fixed now?
The assertion has been fixed but playing a HD stream isn't still working by default (need to set gpu_mem=512).
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.