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 738648 - gdk_window_get_content() causes creation/destruction of backend surface
gdk_window_get_content() causes creation/destruction of backend surface
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: X11
3.14.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-10-16 18:30 UTC by Owen Taylor
Modified: 2014-11-06 11:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GdkWindowX11: Keep the impl window cairo surface around until destroy (2.45 KB, patch)
2014-10-30 09:32 UTC, Alexander Larsson
committed Details | Review

Description Owen Taylor 2014-10-16 18:30:14 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.
Comment 1 Alexander Larsson 2014-10-30 09:07:44 UTC
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.
Comment 2 Alexander Larsson 2014-10-30 09:32:48 UTC
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.
Comment 3 Alexander Larsson 2014-10-30 09:33:19 UTC
Attachment 289633 [details] pushed as afd9709 - GdkWindowX11: Keep the impl window cairo surface around until destroy
Comment 4 Alexander Larsson 2014-10-30 09:33:54 UTC
I pushed the above, but maybe we should backport it to 3.14.
Comment 5 Alexander Larsson 2014-11-06 11:27:31 UTC
Backported this and the followup window-scale fix to gtk-3-14