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 745163 - Pending frame callbacks aren't destroyed with its surface
Pending frame callbacks aren't destroyed with its surface
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: wayland
git master
Other Linux
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2015-02-25 15:31 UTC by Carlos Garnacho
Modified: 2015-03-05 16:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
wayland: Destroy pending frame callbacks when destroying a surface (3.52 KB, patch)
2015-02-25 15:31 UTC, Carlos Garnacho
reviewed Details | Review
wayland: Destroy pending frame callbacks when destroying a surface (4.96 KB, patch)
2015-03-03 16:34 UTC, Carlos Garnacho
reviewed Details | Review

Description Carlos Garnacho 2015-02-25 15:31:01 UTC
In the unlikely event that a surface is destroyed right after having done wl_surface_frame()/wl_surface_commit(), mutter may have already pushed the callback to the compositor in order to be called, resulting in callbacks running for the just destroyed surface.

I'm attaching a patch that ensures pending frame callbacks are removed at the time of destroying a surface.
Comment 1 Carlos Garnacho 2015-02-25 15:31:37 UTC
Created attachment 297890 [details] [review]
wayland: Destroy pending frame callbacks when destroying a surface

MetaWaylandFrameCallback has been added a surface field, which is then
checked when destroying the surfaces. This prevents unintended callbacks
to run after a surface has been destroyed.
Comment 2 Carlos Garnacho 2015-02-25 15:35:38 UTC
FWIW, bug https://bugzilla.gnome.org/show_bug.cgi?id=743427 lead to the discovery of this
Comment 3 Jonas Ådahl 2015-02-26 01:00:31 UTC
Review of attachment 297890 [details] [review]:

::: src/wayland/meta-wayland-surface.c
@@ +697,3 @@
 
+  meta_wayland_compositor_destroy_frame_callbacks (compositor, surface);
+

Hmm. I think we might have a race condition if we remove them here. It would occur when:

client: wl_surface.frame
client: xdg_surface.destroy
server: repaint - won't draw buffer from wl_surface as xdg_surface.destroy unmanaged the window
client: wl_surface.destroy

In this situation we'd still respond to the frame callback even though the surface was never drawn.
Comment 4 Carlos Garnacho 2015-03-02 11:44:24 UTC
(In reply to Jonas Ådahl from comment #3)
> Review of attachment 297890 [details] [review] [review]:
> 
> ::: src/wayland/meta-wayland-surface.c
> @@ +697,3 @@
>  
> +  meta_wayland_compositor_destroy_frame_callbacks (compositor, surface);
> +
> 
> Hmm. I think we might have a race condition if we remove them here. It would
> occur when:
> 
> client: wl_surface.frame
> client: xdg_surface.destroy
> server: repaint - won't draw buffer from wl_surface as xdg_surface.destroy
> unmanaged the window
> client: wl_surface.destroy
> 
> In this situation we'd still respond to the frame callback even though the
> surface was never drawn.

Right... I guess the proper fix is ensuring this is called from the destructor of the roles implying a surface makes it onscreen.

This call on wl_surface_destructor should stay I guess, both as a safety net, and for surfaces that don't need a role to be presented onscreen (eg. the pointer cursor).

I'm updating the patch.
Comment 5 Carlos Garnacho 2015-03-03 16:34:18 UTC
Created attachment 298448 [details] [review]
wayland: Destroy pending frame callbacks when destroying a surface

MetaWaylandFrameCallback has been added a surface field, which is then
checked when destroying the surfaces. This prevents unintended callbacks
to run after a surface has been destroyed.
Comment 6 Jonas Ådahl 2015-03-04 04:11:22 UTC
Review of attachment 298448 [details] [review]:

Looks good to me.
Comment 7 Carlos Garnacho 2015-03-05 16:35:06 UTC
Attachment 298448 [details] pushed as d3988c0 - wayland: Destroy pending frame callbacks when destroying a surface