diff --git a/window/src/os/wayland/window.rs b/window/src/os/wayland/window.rs index 189d3b5ee..db66d7d26 100644 --- a/window/src/os/wayland/window.rs +++ b/window/src/os/wayland/window.rs @@ -801,27 +801,26 @@ impl WaylandWindowInner { } self.invalidated = false; - self.events.dispatch(WindowEvent::NeedRepaint); - if self.gl_state.is_some() { - // Ask the compositor to wake us up when it is time to paint - // the next frame. - // We don't do this when we're using WebGPU because we don't - // always get a timely wakeup. We configure wgpu to use a - // vsync-equivalent PresentMode so we should already be - // respecting the maximum frame rate, making it less critical - // to rely on Wayland's frame scheduling. - // - let window_id = self.window_id; - let callback = self.surface.frame(); - callback.quick_assign(move |_source, _event, _data| { - WaylandConnection::with_window_inner(window_id, |inner| { - inner.next_frame_is_ready(); - Ok(()) - }); + // Ask the compositor to wake us up when its time to paint the next frame, + // note that this only happens _after_ the next commit + let window_id = self.window_id; + let callback = self.surface.frame(); + callback.quick_assign(move |_source, _event, _data| { + WaylandConnection::with_window_inner(window_id, |inner| { + inner.next_frame_is_ready(); + Ok(()) }); - self.frame_callback.replace(callback); - } + }); + self.frame_callback.replace(callback); + + // The repaint has the side of effect of committing the surface, + // which is necessary for the frame callback to get triggered. + // Ordering the repaint after requesting the callback ensures that + // we will get woken at the appropriate time. + // + // + self.events.dispatch(WindowEvent::NeedRepaint); Ok(()) }