window-actor/x11: Don't cache the frame-drawn frame clock

We fetch a frame clock that we schedule update on when queuing
_NET_WM_FRAME_DRAWN events. In some situations this frame clock is the
one from the stage, and if there are multiple hotplugs in a row, we
failed to update it as there were no stage views changes on the window
actor itself. As an actor updates the stage views list on layout, When a
queue_frame_drawn() call was done (typically from an X11 event) after a
second hotplug, it'd attempt to schedule an update on the frame clock
from the previous hotplug, as it didn't get notified about any
stage-views changes since for itself there was none.

Fix this by not caching the frame clock at all and just fetch it every
time.

In the majority of cases, this fetching means iterating over a very
short list (most often a single entry, rarely more), so it's very
unlikely to be of any relevance. The only situations where it might be a
heavier operation is the short time between a hotplug and a layout, as
it will attempt to traverse up to the stage to find a clock, but that's
likely only a few levels, so even that is unlikely to be an issue.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4486
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1947>
This commit is contained in:
Jonas Ådahl 2021-07-30 11:35:10 +02:00 committed by Marge Bot
parent 18c414cca4
commit d2186f6f1a

View File

@ -60,7 +60,6 @@ struct _MetaWindowActorX11
guint send_frame_messages_timer;
int64_t frame_drawn_time;
gboolean pending_schedule_update_now;
ClutterFrameClock *frame_clock;
gulong repaint_scheduled_id;
gulong size_changed_id;
@ -499,8 +498,12 @@ meta_window_actor_x11_queue_frame_drawn (MetaWindowActor *actor,
if (skip_sync_delay)
{
if (actor_x11->frame_clock)
clutter_frame_clock_schedule_update_now (actor_x11->frame_clock);
ClutterFrameClock *frame_clock;
frame_clock = clutter_actor_pick_frame_clock (CLUTTER_ACTOR (actor),
NULL);
if (frame_clock)
clutter_frame_clock_schedule_update_now (frame_clock);
else
actor_x11->pending_schedule_update_now = TRUE;
}
@ -1284,11 +1287,16 @@ handle_stage_views_changed (MetaWindowActorX11 *actor_x11)
{
ClutterActor *actor = CLUTTER_ACTOR (actor_x11);
actor_x11->frame_clock = clutter_actor_pick_frame_clock (actor, NULL);
if (actor_x11->frame_clock && actor_x11->pending_schedule_update_now)
if (actor_x11->pending_schedule_update_now)
{
clutter_frame_clock_schedule_update_now (actor_x11->frame_clock);
actor_x11->pending_schedule_update_now = FALSE;
ClutterFrameClock *frame_clock;
frame_clock = clutter_actor_pick_frame_clock (actor, NULL);
if (frame_clock)
{
clutter_frame_clock_schedule_update_now (frame_clock);
actor_x11->pending_schedule_update_now = FALSE;
}
}
}