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

Open
#4,643 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

B - bug DS - win32
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.