GNOME Bugzilla – Bug 738648
gdk_window_get_content() causes creation/destruction of backend surface
Last modified: 2014-11-06 11:27:31 UTC
I'm not entirely sure when this regressed, but now we have a code path: gdk_window_begin_paint() gdk_window_get_content() gdk_window_ref_impl_surface() gdk_x11_ref_cairo_surface hook_surface_changed() cairo_surface_destroy() [surface is destroyed] [mime data is removed] on_surface_changed, So A) we have a surface being created and destroyed on every call to gdk_window_get_content() B) The hack to use cairo_surface_set_mime_data() to get notification when the window contents actually change is mostly ineffective and every call to gdk_window_begin_paint() will cause a frame to be triggered, even if no damage is actually painted. I think I added the hack mostly to handle cases where begin_paint() wasn't called at all - maybe when GDK_EXPOSURE_MASK is not set on a window, so that would still work - but it's certainly concerning that we're triggering it off a getter. gdk_window_create_similar_surface() has similar thrashing behavior where a cairo surface is created and destroyed.
This regressed in this commit from Jasper: https://git.gnome.org/browse/gtk+/commit/?id=d48adf9cee7e340acd7f8b9a5f9716695352b848 We used to keep the per-window cairo subsurface around in each GdkWindow which ref:ed the impl cairo surface. Now that we don't do this maybe we should keep the surface for the impl window around until destroy.
Created attachment 289633 [details] [review] GdkWindowX11: Keep the impl window cairo surface around until destroy We used to have a weak ref to the cairo surface and it was keep alive by the references in the normal windows, but that reference was removed by d48adf9cee7e340acd7f8b9a5f9716695352b848, causing us to constantly create and destroy the surface.
Attachment 289633 [details] pushed as afd9709 - GdkWindowX11: Keep the impl window cairo surface around until destroy
I pushed the above, but maybe we should backport it to 3.14.
Backported this and the followup window-scale fix to gtk-3-14