Skip to content

Commit

Permalink
Render one frame before showing the window to avoid flashing (#777)
Browse files Browse the repository at this point in the history
  • Loading branch information
Long0x0 authored Dec 10, 2024
1 parent 8e05367 commit 806ee4d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion masonry/src/event_loop_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ impl MasonryState<'_> {
let window = event_loop.create_window(attributes).unwrap();

let adapter = Adapter::with_event_loop_proxy(&window, self.proxy.clone());
window.set_visible(visible);
let window = Arc::new(window);
// https://github.com/rust-windowing/winit/issues/2308
#[cfg(target_os = "ios")]
Expand All @@ -286,6 +285,20 @@ impl MasonryState<'_> {
};
self.render_root
.handle_window_event(WindowEvent::Rescale(scale_factor));
// Render one frame before showing the window to avoid flashing
if visible {
let (scene, tree_update) = self.render_root.redraw();
self.render(scene);
if let WindowState::Rendering {
window,
accesskit_adapter,
..
} = &mut self.window
{
accesskit_adapter.update_if_active(|| tree_update);
window.set_visible(true);
};
}
}
WindowState::Suspended {
window,
Expand Down

0 comments on commit 806ee4d

Please sign in to comment.