rust-windowing / rust-windowing/winit
I tried to launch the program with its window hidden on startup, but a fleeting window ghost always flashes briefly on screen
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 6.2k
- Forks
- 1.3k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 9
Description
Description
use eframe::egui;
use std::time::{Duration, Instant};struct TestApp {
start_time: Instant,
window_shown: bool,
}impl TestApp {
fn new(cc: &eframe::CreationContext<'_>) -> Self {
cc.egui_ctx
.send_viewport_cmd(egui::ViewportCommand::Visible(false));Self { start_time: Instant::now(), window_shown: false, } }}
impl eframe::App for TestApp {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
let ctx = ui.ctx().clone();if !self.window_shown { ctx.request_repaint(); ctx.send_viewport_cmd(egui::ViewportCommand::Visible(false)); if self.start_time.elapsed() >= Duration::from_secs(2) { println!("[TestApp] 2 seconds elapsed! Sending ViewportCommand::Visible(true)"); ctx.send_viewport_cmd(egui::ViewportCommand::Visible(true)); self.window_shown = true; } } ui.heading("Hidden Window Test App"); ui.label(format!( "Elapsed time since launch: {:.2} seconds", self.start_time.elapsed().as_secs_f64() )); if self.window_shown { ui.label("Status: Window is now VISIBLE!"); } else { ui.label("Status: Window is currently HIDDEN..."); } }}
fn main() -> Result<(), eframe::Error> {
let mut viewport = egui::ViewportBuilder::default()
.with_title("Hidden Window Test")
.with_inner_size([400.0, 300.0])
.with_visible(false);let options = eframe::NativeOptions { viewport, ..Default::default() }; eframe::run_native( "Hidden Window Test", options, Box::new(|cc| Ok(Box::new(TestApp::new(cc)))), )}
Here is the simplest code to replicate this bug
btw this is crate I am using
egui = { version = "0.34.1", default-features = false, features = ["default_fonts"] }
eframe = { version = "0.34.1", default-features = false, features = ["wgpu_no_default_features", "persistence"] }
wgpu = { version = "29.0.1", default-features = false, features = ["vulkan"] }
Windows version
Windows 11 [10.0.26200]
Winit version
v0.30.13
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Windows 11 case with winit 0.30.13 and the provided eframe example, focusing on ViewportBuilder::with_visible(false) and ViewportCommand::Visible. Trace the Windows startup visibility handling and verify that a window kept hidden at launch no longer flashes before becoming visible after the delayed command.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- desktop, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100