Skip to content

macOS: a redraw requested through WindowWaker while a frame draws is lost; the window stops drawing until the next input event #372

Open

Description

@kovaacs

On macOS (0.4.2 and master at 4a274e3), a window whose handler asks for its next frame through WindowWaker::request_redraw (or WindowContext::request_redraw_after, which goes through the waker) while draw() runs draws once and then stops, until an input event arrives.

Why: trigger_frame (src/platform/macos/view.rs) clears state.redraw_requested, calls draw(), then calls set_next_frame_needed(state.redraw_requested.take()), which pauses the display link unless the flag was set during the frame. WindowContext::request_redraw sets the flag. WindowWaker::request_redraw_after (src/platform/macos/waker.rs) only calls view.set_next_frame_needed(true): called on the main thread during draw() it runs at once, and the end of trigger_frame then undoes it.

This hits egui-baseview 0.9, which routes egui's repaint requests through the waker: animated UIs (meters, spectra) freeze unless the mouse moves over the window. Seen in a CLAP plug-in in Bitwig 6.1 (no CLAP timer extension there, so nothing else restarts the display link) and in a standalone window.

Repro: a WindowHandler whose draw() calls waker.request_redraw() each time, in a window with no input. Measured in an NSWindow test host: 1 frame and then none; with the fix below, about 120 frames a second (the display's rate).

Fix: have the waker set the flag too (PR to follow). Then a request made during a frame survives it, and one made between frames still starts the link.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions