Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render one frame before showing the window to avoid flashing #777

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading