Skip to content

Avoid crashing when untimely _NET_WM_FRAME_DRAWN requests arrive

Main commit:

    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

Also contains a test case, and a slightly related fix that I had to do to make the test pass to not dead lock (first commit).

Merge request reports