[Cogl] How can we gracefully handle Cogl and GL out of memory conditions?

Reza Ghassemi reza.robin1 at gmail.com
Tue Oct 15 16:32:50 PDT 2013


Update on this.
I fixed the bug where the error value was not set to NULL.  That cleared up
the warning.  I reverted the clutter commit "clutter-offscreen-effect:
Allocate the cogl texture directly" which wasn't checking for a NULL
texture before calling cogl_texture_allocate() with it .  However the
behavior of the app when running out of memory has not changed from before
using the wip/cogl-14-fixes branch. It still experiences black actors
occasionally when many GL calls fail due to lack of memory.  Perhaps we
need to catch this problem even earlier and enforce a very low priority on
off screen effects so they won't even be attempted if they will eat up all
remaining memory.

Jim


On Mon, Oct 14, 2013 at 5:49 PM, Reza Ghassemi <reza.robin1 at gmail.com>wrote:

> Thanks, Robert.
> I tried building from the top of Clutter1.14 branch and wip/cogl-14-fixes
> branch (this is for an ARM processor, BTW)  and tested it with the out of
> memory situation.  The results were as follows: an abort occurred in glibc
> and the following Cogl warning was produced.  Is this happening because the
> code is trying to free the texture allocation that was actually never made?
>
> Reza
>
> (.:2259): Cogl-WARNING **: CoglError set over the top of a previous
> CoglError or uninitialized memory.
> This indicates a bug in someone's code. You must ensure an error is NULL
> before it's set.
> The overwriting error message was: Out of memory
> *** glibc detected *** Volt: free(): invalid next size (normal):
> 0x013171a0 ***
> =
>
> #0  0x41ead5b0 in __GI_raise (sig=<optimized out>) at
> ../nptl/sysdeps/unix/sysv/linux/raise.c:67
> #1  0x41eb0ff0 in __GI_abort () at abort.c:108
> #2  0x41ee1fe8 in __libc_message (do_abort=<optimized out>, fmt=Could not
> find the frame base for "__libc_message".
> ) at ../sysdeps/unix/sysv/linux/libc_fatal.c:201
> #3  0x41eeca34 in malloc_printerr (action=<optimized out>, str=<optimized
> out>, ptr=<optimized out>) at malloc.c:6538
> #4  0x41ef1a04 in __GI___libc_free (mem=<optimized out>) at malloc.c:3760
> #5  0x49a61ec0 in g_free ()
> #6  0x49a2ea2c in array_free ()
> #7  0x40319de0 in _cogl_texture_2d_sliced_slices_free ()
> #8  0x40319e00 in _cogl_texture_2d_sliced_free ()
> #9  0x40318158 in _cogl_object_texture_2d_sliced_indirect_free ()
> #10 0x402d6ae8 in _cogl_object_default_unref ()
> #11 0x402d6b44 in cogl_object_unref ()
> #12 0x40316bfc in cogl_texture_new_with_size ()
> #13 0x4049ba10 in clutter_offscreen_effect_real_create_texture
> (effect=0x144d808, width=1920, height=1080) at
> ./clutter-offscreen-effect.c:143
> #14 0x4049cbfc in clutter_offscreen_effect_create_texture
> (effect=0x144d808, width=1920, height=1080) at
> ./clutter-offscreen-effect.c:600
> #15 0x4049bc60 in update_fbo (effect=0x144d808, fbo_width=1920,
> fbo_height=1080) at ./clutter-offscreen-effect.c:203
>
>
> On Sat, Oct 12, 2013 at 6:43 AM, Robert Bragg <robert at sixbynine.org>wrote:
>
>> Hi Reza,
>>
>> Cogl 1.14 should be able to gracefully report out of memory conditions
>> when allocating textures and framebuffers. The recommended way would be to
>> use cogl_texture_allocate() and cogl_framebuffer_allocate() to explicitly
>> try and allocate texture and framebuffer resources which can report a
>> CoglError if there was a problem.
>>
>> If you are using Cogl's high level texture constructors like
>> cogl_texture_new_with_size or cogl_texture_new_from_data then these apis
>> should return NULL if there was a problem allocating the texture due to
>> lack of memory but in Cogl 1.14 it looks like we broke these semantics and
>> it's possible for cogl_texture_new_with_size to return a CoglTexture object
>> which doesn't yet have an associated allocation and you could hit an error
>> later if you try to create a framebuffer from that texture if it turns out
>> you don't have enough memory.
>>
>> I think Clutter 1.14 uses cogl_texture_new_with_size for the offscreen
>> effects and it is expecting it to return NULL if there is an error.
>> Similarly Clutter uses cogl_offscreen_new_to_texture() and expects that to
>> return NULL on failure to allocate. I'm afraid that we also broke the
>> semantics of this api too :-/
>>
>> I've just push a wip/cogl-14-fixes branch with a couple of patches that
>> may help you by fixing both of those regressions on the 1.14 branch.
>>
>> I hope that helps,
>> Robert
>>
>>
>>
>> On Sat, Oct 12, 2013 at 12:00 AM, Reza Ghassemi <reza.robin1 at gmail.com>wrote:
>>
>>> Sorry, somehow sent this before I was done.
>>> To conclude:
>>> The output below shows Clutter warning when the texture for the 2nd
>>> offscreen effect (blur) on an actor tree could not be allocated.  The first
>>> effect (desaturate) did get allocated and applied and displayed properly.
>>> However when an animated page turn effect on a stack of 5 actors was
>>> attempted the GL out of memory errors occurred and parts or the entire
>>> screen went black.
>>>
>>> Question: Any recommendations how to deal with this?  Is this a bug in
>>> cogl or clutter?  Is this expected?  We want to just not do the effect if
>>> memory is going to run out and avoid the black screen.  Should we do some
>>> memory queries and keep track of how much we might need and catch potential
>>> problems in application code?
>>>
>>> Upgrading to 1.16 is going to take some effect do to dependency changes
>>> and deprecated function use so we'd like to avoid that if possible.
>>>
>>> Thanks again.
>>>
>>> Reza
>>>
>>>
>>>
>>> On Fri, Oct 11, 2013 at 3:36 PM, Reza Ghassemi <reza.robin1 at gmail.com>wrote:
>>>
>>>> Hello Clutter users and developers,
>>>>
>>>> Using the top of 1.14 branch when trying to use 2 offscreen effects
>>>> such as blur and desaturate on a full HD screen sized actor and then after
>>>> that trying to do a page turn effect on a smaller actor we run out of
>>>>  video RAM (I'm assuming) on our OpenGL ES device  and get errors from Cogl
>>>> when it calls GL calls to render attributes or allocate texture memory for
>>>> resulting in black actor(s).
>>>>
>>>>     While we might be able to fix this particular issue by making sure
>>>> to remove/destroy the effects from the actor before applying another effect
>>>> on another actor, we want a graceful general way to handle tight memory
>>>> situations and not just display black to support other party developement
>>>> with our script driven driven system.  It seems that you can eat up most of
>>>> your memory with an effect and then memory runs out just trying to draw
>>>> normal actors with no effects
>>>>
>>>> Clutter-WARNING **: Unable to allocate texture for offscreen effect:
>>>> Out of memory
>>>>
>>>> However we get into a situation where we're getting errors from GL out
>>>> of memory I guess when trying to use more than one offscreen effect in the
>>>> same scene and when some of them are failing.  This results in black
>>>> textures.  It seems that the memory isn't recovered until the actors are
>>>> deleted and a new scene is constructed.
>>>>
>>>> (.:1836): Cogl-WARNING **: ./driver/gl/cogl-framebuffer-gl.c:1072: GL
>>>> error (1285): Out of memory
>>>>
>>>>
>>>> (.:1836): Cogl-WARNING **: ./driver/gl/cogl-framebuffer-gl.c:1072: GL
>>>> error (1285): Out of memory
>>>>
>>>>
>>>> (.:1836): Cogl-WARNING **: ./driver/gl/cogl-framebuffer-gl.c:1139: GL
>>>> error (1285): Out of memory
>>>>
>>>>
>>>> (.:1836): Cogl-WARNING **: ./driver/gl/cogl-framebuffer-gl.c:1072: GL
>>>> error (1285): Out of memory
>>>>
>>>>
>>>> (.:1836): Cogl-WARNING **: ./driver/gl/cogl-framebuffer-gl.c:1072: GL
>>>> error (1285): Out of memory
>>>>
>>>>
>>>> (.:1836): Cogl-WARNING **: ./driver/gl/cogl-framebuffer-gl.c:1139: GL
>>>> error (1285): Out of memory
>>>>
>>>>
>>>> (.:1836): Cogl-WARNING **: ./driver/gl/cogl-framebuffer-gl.c:1072: GL
>>>> error (1285): Out of memory
>>>>
>>>
>>>
>>> _______________________________________________
>>> clutter-list mailing list
>>> clutter-list at gnome.org
>>> https://mail.gnome.org/mailman/listinfo/clutter-list
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/cogl/attachments/20131015/9b33ddd0/attachment.html>


More information about the Cogl mailing list