GskGlRenderer asserts on renderer->driver not being NULL
Was porting CcCropArea
, a widget used in Contacts and g-c-c, which crops an image to a user/contact avatar. When the user is done, it needs to create a GdkPixbuf
from a GdkPaintable
so that we can set it as the avatar.
Steps to reproduce
- Create a
GskGlRenderer
and realize it - Use that to render your
GdkPaintable
into a texture - when your function is over, do a proper cleanup of the renderer by calling
g_object_unref()
- Application is now dead
Relevant code:
GdkPixbuf *
cc_crop_area_create_pixbuf (CcCropArea *area)
{
g_autoptr (GtkSnapshot) snapshot = NULL;
g_autoptr (GskRenderNode) node = NULL;
g_autoptr (GskRenderer) renderer = NULL; // <- g_object_unref()ed at the end
g_autoptr (GdkTexture) texture = NULL;
g_autoptr (GError) error = NULL;
graphene_rect_t viewport;
g_return_val_if_fail (CC_IS_CROP_AREA (area), NULL);
snapshot = gtk_snapshot_new ();
gdk_paintable_snapshot (area->paintable, snapshot,
gdk_paintable_get_intrinsic_width (area->paintable),
gdk_paintable_get_intrinsic_height (area->paintable));
node = gtk_snapshot_free_to_node (g_steal_pointer (&snapshot));
renderer = gsk_gl_renderer_new ();
if (!gsk_renderer_realize (renderer, NULL, &error)) {
g_warning ("Couldn't realize GL renderer: %s", error->message);
return NULL;
}
viewport = GRAPHENE_RECT_INIT (area->crop.x, area->crop.y,
area->crop.width, area->crop.height);
texture = gsk_renderer_render_texture (renderer, node, &viewport);
return gdk_pixbuf_get_from_texture (texture);
}
Current behavior
I get the following assertions when cleanuping the GskGlRenderer:
Gsk:ERROR:../../../../jhbuild/checkout/gtk/gsk/gl/gskglrenderer.c:298:gsk_gl_renderer_dispose: assertion failed: (self->driver == NULL) Bail out! Gsk:ERROR:../../../../jhbuild/checkout/gtk/gsk/gl/gskglrenderer.c:298:gsk_gl_renderer_dispose: assertion failed: (self->driver == NULL)
Offending lines are in gsk_gl_renderer_dispose()
Expected outcome
GTK doesn't crash my application
Version information
- Which version of GTK you are using
- What operating system and version
- Fedora 35 Workstation
- For Linux, which distribution
- Fedora, using jhbuild
- If you built GTK yourself, the list of options used to configure the build
- whatever jhbuild uses, but in this case
G_ENABLE_DEBUG
is probably the thing that does the trick
- whatever jhbuild uses, but in this case
Additional information
I think we can just remove the assertion in the dispose, since we only do g_clear_object ();
in the finalize.
Probably the same crash as #4586 (closed)