rust_minifb icon indicating copy to clipboard operation
rust_minifb copied to clipboard

Window always renders white on Windows 11 in release build.

Open neildanson opened this issue 2 months ago • 19 comments

I appreciate this may not be an issue with minifb (Windows versions, Graphics driver versions) - but its pretty much my only dependency.

Everything displays correctly in debug builds. Same code works fine in both release & debug on M1 mac.

Any of the examples exhibit this.

Main things I can think of that may impact?

rustc 1.79.0-nightly (ccfcd950b 2024-04-15)

Nvidia 3080, game ready driver 552.22 (april 16 2024)

Edition Windows 11 Pro Version 23H2 Installed on ‎06/‎10/‎2022 OS build 22631.3447 Experience Windows Feature Experience Pack 1000.22688.1000.0

I had a small application that was fine from 1 month ago, no changes in code (probably a windows update and a rustup update).

neildanson avatar Apr 24 '24 08:04 neildanson

I would recommend that you try to clone the rust_minifb repo and run one of the examples and see if these works. Such as cargo run --release --example noise and see if it still shows up while or not if you switch between --release and not including it.

emoon avatar Apr 24 '24 08:04 emoon

Repro


use minifb::*;

const WIDTH: usize = 320;
const HEIGHT: usize = 240;

fn create_window() -> minifb::Window {
    minifb::Window::new(
        "App",
        WIDTH,
        HEIGHT,
        WindowOptions {
            scale: Scale::X4,
            transparency: false,
            ..WindowOptions::default()
        },
    )
    .unwrap_or_else(|e| {
        panic!("{}", e);
    })
}

fn update_buffers(window: &mut minifb::Window, buffer: &[u32]) {
    window.update_with_buffer(&buffer, WIDTH, HEIGHT).unwrap();
}

fn main() {
    let mut window = create_window();
    let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT];

    while window.is_open() && !window.is_key_down(Key::Escape) {
        for i in 0..WIDTH * HEIGHT {
            buffer[i] = 0xff000000;
        }
        update_buffers(&mut window, &buffer);
    }
}

In Release

image

In Debug

image

neildanson avatar Apr 24 '24 08:04 neildanson

I would recommend that you try to clone the rust_minifb repo and run one of the examples and see if these works. Such as cargo run --release --example noise and see if it still shows up while or not if you switch between --release and not including it.

Interestingly this works.

neildanson avatar Apr 24 '24 08:04 neildanson

Also interestingly however is that the version in master (cargo toml 0.25) doesnt match the released version (also 0.25) (ie missing window.set_target_fps(60);)

Could it be fixed since the latest published to crates.io?

neildanson avatar Apr 24 '24 08:04 neildanson

I can confirm that adding

minifb = { git = "https://github.com/emoon/rust_minifb.git", rev = "633e6cd4f8f55fd9cbedc461976dde0f408bea35" }

as my dependency everything renders fine

neildanson avatar Apr 24 '24 08:04 neildanson

Unsure, I can make a new release later today.

emoon avatar Apr 24 '24 09:04 emoon

No rush on my account - its good to know its fixed and I'm unblocked by specifying the revision.

Thanks for such an awesome project :)

neildanson avatar Apr 24 '24 09:04 neildanson

Thanks :)

emoon avatar Apr 24 '24 09:04 emoon

Just saw this issue - now that Rust 1.78 is live, we're also seeing the problem on stable. We'll also pin to the git version as well until a new release is up, but leaving a note here in case other users are encountering the same problem.

bunnie avatar May 09 '24 16:05 bunnie

Some function is also deprecated in the new release -- so the switch over isn't exactly clean, but, I'll also check in the code change to comply to the deprecation notice as well when I rev things.

bunnie avatar May 09 '24 16:05 bunnie

I wonder what changed from 1.77 to 1.78 that made this happen?

Cyborus04 avatar May 10 '24 16:05 Cyborus04

I will sort out a new release today

emoon avatar May 11 '24 08:05 emoon

I wonder what changed from 1.77 to 1.78 that made this happen?

A couple changes specifically impacting windows: https://github.com/rust-lang/rust/pull/115141/ or this https://github.com/rust-lang/rust/pull/112267/

Nothing leaps out at me as the culprit, there were also some changes to locking that maybe introduced a race condition? Either way, top of main branch works.

Thanks @emoon for the support!

bunnie avatar May 11 '24 09:05 bunnie

0.26 has now been published

emoon avatar May 11 '24 18:05 emoon

thank you ~~~

bunnie avatar May 12 '24 04:05 bunnie