I'm running KDE Plasma (Wayland) on Arch Linux. This example code produces the following result:
extern crate minifb;
use minifb::{Key, Window, WindowOptions};
const WIDTH: usize = 640;
const HEIGHT: usize = 360;
fn main() {
let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT];
let mut window = Window::new(
"Test - ESC to exit",
WIDTH,
HEIGHT,
WindowOptions::default(),
)
.unwrap_or_else(|e| {
panic!("{}", e);
});
// Limit to max ~60 fps update rate
window.limit_update_rate(Some(std::time::Duration::from_micros(16600)));
let mut c = 0u8;
while window.is_open() && !window.is_key_down(Key::Escape) {
for i in buffer.iter_mut() {
*i = c as u32; // write something more funny here!
}
c=c^0xFF;
// We unwrap here as we want this code to exit if it fails. Real applications may want to handle this in a different way
window
.update_with_buffer(&buffer, WIDTH, HEIGHT)
.unwrap();
}
}
The window only updates its contents when I move my mouse over it, or change focus etc. Otherwise the code just hangs at window.update_with_buffer(&buffer, WIDTH, HEIGHT)
This only happens on Wayland. On X11 the window flashes continuously like it should do.
This is where it hangs:
(gdb) where
#0 0x00007ffff7e17af7 in poll () from /usr/lib/libc.so.6
#1 0x0000555555793abe in nix::poll::poll (fds=..., timeout=-1) at /home/hz/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.20.1/src/poll.rs:120
#2 0x0000555555666db0 in wayland_client::imp::queues::EventQueueInner::dispatch<closure-0> (self=0x5555557f09b0, data=..., fallback=...) at /home/hz/.cargo/registry/src/github.com-1ecc6299db9ec823/wayland-client-0.28.6/src/rust_imp/queues.rs:93
#3 0x000055555564405f in wayland_client::event_queue::EventQueue::dispatch<(),closure-0> (self=0x7fffffff8d18, data=0x7fffffff7e58, fallback=...) at /home/hz/.cargo/registry/src/github.com-1ecc6299db9ec823/wayland-client-0.28.6/src/event_queue.rs:152
#4 0x0000555555630c27 in minifb::os::posix::wayland::Window::update (self=0x7fffffff8ab8) at /home/hz/.cargo/registry/src/github.com-1ecc6299db9ec823/minifb-0.19.3/src/os/posix/wayland.rs:713
#5 0x00005555556334a1 in minifb::os::posix::wayland::Window::update_with_buffer_stride (self=0x7fffffff8ab8, buffer=..., buf_width=640, buf_height=360, buf_stride=640) at /home/hz/.cargo/registry/src/github.com-1ecc6299db9ec823/minifb-0.19.3/src/os/posix/wayland.rs:1105
#6 0x000055555560c5ff in minifb::os::posix::Window::update_with_buffer_stride (self=0x7fffffff8ab0, buffer=..., buf_width=640, buf_height=360, buf_stride=640) at /home/hz/.cargo/registry/src/github.com-1ecc6299db9ec823/minifb-0.19.3/src/os/posix/mod.rs:82
#7 0x00005555556098f9 in minifb::Window::update_with_buffer (self=0x7fffffff8ab0, buffer=..., width=640, height=360) at /home/hz/.cargo/registry/src/github.com-1ecc6299db9ec823/minifb-0.19.3/src/lib.rs:301
#8 0x000055555560941e in gif_viewer::main () at src/main.rs:34
I'm running KDE Plasma (Wayland) on Arch Linux. This example code produces the following result:
---WARNING: FLASHING COLORS--- https://youtu.be/5JCIFnCdnrg
The window only updates its contents when I move my mouse over it, or change focus etc. Otherwise the code just hangs at
window.update_with_buffer(&buffer, WIDTH, HEIGHT)
This only happens on Wayland. On X11 the window flashes continuously like it should do.
This is where it hangs: