rust-windowing / winit

Window handling library in pure Rust
https://docs.rs/winit/
Apache License 2.0
4.73k stars 890 forks source link

Event loop freezes on Wayland #3551

Closed GenericConfluent closed 6 months ago

GenericConfluent commented 6 months ago

I'm on Wayland (Hyprland and river) with NVIDIA (proprietary drivers) and running something similar to the following seems to freeze the cursor first leaves the window for the first time after the window opens (I was thinking its the CursorLeft event, but could be the RedrawRequest or something). I'm not super familiar with winit. Here is my sample:

use pollster::FutureExt as _;
use winit::{
    event::{Event, WindowEvent},
    event_loop::{ControlFlow, EventLoop},
    window::WindowBuilder,
};

fn main() {
    let event_loop = EventLoop::new().unwrap();
    let window = WindowBuilder::new().build(&event_loop).unwrap();

    // BEGIN WGPU setup
    let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::default());

    let surface = instance.create_surface(&window).unwrap();
    let adapter = instance
        .request_adapter(&wgpu::RequestAdapterOptions {
            compatible_surface: Some(&surface),
            ..Default::default()
        })
        .block_on()
        .unwrap();

    let (device, queue) = adapter
        .request_device(&wgpu::DeviceDescriptor::default(), None)
        .block_on()
        .unwrap();

    let surface_caps = surface.get_capabilities(&adapter);
    let size = window.inner_size();
    let config = wgpu::SurfaceConfiguration {
        usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
        format: surface_caps.formats[0],
        width: size.width,
        height: size.height,
        present_mode: surface_caps.present_modes[0],
        alpha_mode: surface_caps.alpha_modes[0],
        view_formats: vec![],
        desired_maximum_frame_latency: 2,
    };
    surface.configure(&device, &config);
    // END WGPU SETUP

    event_loop.set_control_flow(ControlFlow::Wait);
    let _ = event_loop.run(move |event, elwt| match event {
        Event::WindowEvent {
            event: WindowEvent::CloseRequested,
            ..
        } => elwt.exit(),
        Event::WindowEvent { window_id, event } => {
            dbg!(&window_id);
            dbg!(&event);
            if event == WindowEvent::RedrawRequested {
                let output = surface.get_current_texture().unwrap();
                let view = output
                    .texture
                    .create_view(&wgpu::TextureViewDescriptor::default());
                let mut encoder =
                    device.create_command_encoder(&wgpu::CommandEncoderDescriptor::default());
                {
                    let _ = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
                        color_attachments: &[Some(wgpu::RenderPassColorAttachment {
                            view: &view,
                            resolve_target: None,
                            ops: wgpu::Operations {
                                load: wgpu::LoadOp::Clear(wgpu::Color::RED),
                                store: wgpu::StoreOp::Store,
                            },
                        })],
                        ..Default::default()
                    });
                }
                queue.submit(std::iter::once(encoder.finish()));
                output.present();
            }
        }
        _ => (),
    });
}

I'm pretty sure this is a winit problem. I recently upgraded my NVIDIA drivers and the winit version on my project, so it could be the drivers, except all the other windowing on my system is working without issue. This issue is causing downstream stuff like iced to freeze (see iced-rs/iced#2297) and I think may also be the cause of an issue I'm having where bevy will panic when I switch my workspace on Hyprland (though that may be unrelated):

thread 'Compute Task Pool (4)' panicked at crates/bevy_render/src/view/window/mod.rs:324:26:
Error reconfiguring surface: Outdated
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_render::view::window::prepare_windows`!
thread 'Compute Task Pool (5)' panicked at crates/bevy_render/src/pipelined_rendering.rs:49:67:
called `Result::unwrap()` on an `Err` value: RecvError
thread '<unnamed>' panicked at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/std/src/thread/local.rs:260:26:
cannot access a Thread Local Storage value during or after destruction: AccessError

Also just a note: I tried using ControlFlow::Poll and still had the same issue.

kchibisov commented 6 months ago

Try 0.29.12 and ensure to use the latest wayland-client (cargo update basically everything).

GenericConfluent commented 6 months ago

I was experiencing the issue with 0.29.12. Then I ran cargo update and tried running again and had the same problem (wayland-client didn't update but winit went to 0.29.13). Here's what it looked like after the cargo update:

https://github.com/rust-windowing/winit/assets/36684089/9ce8575e-5019-413e-9e84-fe4704db2178

On the first one after the window loses focus I need to send an interrupt to close it, and on the second I never let it lose focus so closing it works just fine. Is there any information about my system that would help reproduce this? Here is some info on my card and drivers if that helps:

# lspci -v | grep VGA -A 10
01:00.0 VGA compatible controller: NVIDIA Corporation GA104 [GeForce RTX 3060 Ti Lite Hash Rate] (rev a1) (prog-if 00 [VGA controller])
    Subsystem: Micro-Star International Co., Ltd. [MSI] GA104 [GeForce RTX 3060 Ti Lite Hash Rate]
    Flags: bus master, fast devsel, latency 0, IRQ 40, IOMMU group 7
    Memory at fb000000 (32-bit, non-prefetchable) [size=16M]
    Memory at d0000000 (64-bit, prefetchable) [size=256M]
    Memory at e0000000 (64-bit, prefetchable) [size=32M]
    I/O ports at f000 [size=128]
    Expansion ROM at fc000000 [virtual] [disabled] [size=512K]
    Capabilities: <access denied>
    Kernel driver in use: nvidia
    Kernel modules: nouveau, nvidia_drm, nvidia

# pacman -Q | grep nvidia
lib32-nvidia-utils 550.54.14-1
libva-nvidia-driver-git 0.0.11.r1.gea6d862-1
nvidia-dkms 550.54.14-2
nvidia-settings 550.54.14-1
nvidia-utils 550.54.14-2
opencl-nvidia 550.54.14-2
kchibisov commented 6 months ago

Post WAYLAND_DEBUG=1, but it really looks like a bug in nvidia driver and it holds the queue?

Better probably a video with WAYLAND_DEBUG and remove winit events.

kchibisov commented 6 months ago

Also, could you see where it's getting stuck? It feels like it's getting stuck inside the drawing actually? Use gdb for that, so it's not polling, but rather blocked on calling to nvidia driver, if that's the case, bring it to nvidia and it's not related to winit in any way.

GenericConfluent commented 6 months ago

On Hyprland the window never opened, and a couple of seconds later Hyprland crashed ("Exiting due to channel error"), but I got:

[2565314.661]  -> wl_display@1.get_registry(new id wl_registry@2)
[2565314.681]  -> wl_display@1.sync(new id wl_callback@3)
[2565319.415] wl_display@1.delete_id(3)
[2565319.426] wl_registry@2.global(1, "wl_shm", 1)
[2565319.470] wl_registry@2.global(2, "wl_drm", 2)
[2565319.478] wl_registry@2.global(3, "zwp_linux_dmabuf_v1", 4)
[2565319.485] wl_registry@2.global(4, "wl_compositor", 6)
[2565319.491] wl_registry@2.global(5, "wl_subcompositor", 1)
[2565319.497] wl_registry@2.global(6, "wl_data_device_manager", 3)
[2565319.504] wl_registry@2.global(7, "zwlr_export_dmabuf_manager_v1", 1)
[2565319.510] wl_registry@2.global(8, "zwlr_data_control_manager_v1", 2)
[2565319.515] wl_registry@2.global(9, "zwp_primary_selection_device_manager_v1", 1)
[2565319.522] wl_registry@2.global(10, "wp_viewporter", 1)
[2565319.528] wl_registry@2.global(11, "zwlr_gamma_control_manager_v1", 1)
[2565319.534] wl_registry@2.global(12, "zwlr_output_power_manager_v1", 1)
[2565319.540] wl_registry@2.global(13, "xdg_wm_base", 6)
[2565319.546] wl_registry@2.global(14, "wl_seat", 9)
[2565319.552] wl_registry@2.global(15, "wp_presentation", 1)
[2565319.558] wl_registry@2.global(16, "ext_idle_notifier_v1", 1)
[2565319.564] wl_registry@2.global(17, "zwlr_layer_shell_v1", 4)
[2565319.570] wl_registry@2.global(18, "org_kde_kwin_server_decoration_manager", 1)
[2565319.577] wl_registry@2.global(19, "zxdg_decoration_manager_v1", 1)
[2565319.585] wl_registry@2.global(20, "zwlr_output_manager_v1", 4)
[2565319.591] wl_registry@2.global(21, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1)
[2565319.597] wl_registry@2.global(22, "zwp_pointer_constraints_v1", 1)
[2565319.603] wl_registry@2.global(23, "zwp_relative_pointer_manager_v1", 1)
[2565319.609] wl_registry@2.global(24, "zwp_virtual_keyboard_manager_v1", 1)
[2565319.615] wl_registry@2.global(25, "zwlr_virtual_pointer_manager_v1", 2)
[2565319.621] wl_registry@2.global(26, "zwlr_foreign_toplevel_manager_v1", 3)
[2565319.627] wl_registry@2.global(27, "wp_drm_lease_device_v1", 1)
[2565319.633] wl_registry@2.global(28, "zwp_tablet_manager_v2", 1)
[2565319.639] wl_registry@2.global(29, "zwp_idle_inhibit_manager_v1", 1)
[2565319.645] wl_registry@2.global(30, "zxdg_exporter_v1", 1)
[2565319.650] wl_registry@2.global(31, "zxdg_importer_v1", 1)
[2565319.656] wl_registry@2.global(32, "zxdg_exporter_v2", 1)
[2565319.662] wl_registry@2.global(33, "zxdg_importer_v2", 1)
[2565319.668] wl_registry@2.global(34, "zwp_pointer_gestures_v1", 3)
[2565319.674] wl_registry@2.global(35, "zwp_text_input_manager_v3", 1)
[2565319.680] wl_registry@2.global(36, "zwp_input_method_manager_v2", 1)
[2565319.686] wl_registry@2.global(37, "xdg_activation_v1", 1)
[2565319.692] wl_registry@2.global(38, "ext_session_lock_manager_v1", 1)
[2565319.698] wl_registry@2.global(39, "wp_cursor_shape_manager_v1", 1)
[2565319.704] wl_registry@2.global(40, "wp_tearing_control_manager_v1", 1)
[2565319.710] wl_registry@2.global(41, "wp_single_pixel_buffer_manager_v1", 1)
[2565319.715] wl_registry@2.global(42, "xwayland_shell_v1", 1)
[2565319.721] wl_registry@2.global(43, "hyprland_toplevel_export_manager_v1", 2)
[2565319.727] wl_registry@2.global(44, "wp_fractional_scale_manager_v1", 1)
[2565319.733] wl_registry@2.global(45, "zwp_text_input_manager_v1", 1)
[2565319.739] wl_registry@2.global(46, "hyprland_global_shortcuts_manager_v1", 1)
[2565319.745] wl_registry@2.global(47, "zwlr_screencopy_manager_v1", 3)
[2565319.751] wl_registry@2.global(48, "zxdg_output_manager_v1", 3)
[2565319.757] wl_registry@2.global(49, "wl_output", 4)
[2565319.763] wl_callback@3.done(20513)
[2565319.858]  -> wl_registry@2.bind(4, "wl_compositor", 6, new id [unknown]@3)
[2565319.879]  -> wl_registry@2.bind(5, "wl_subcompositor", 1, new id [unknown]@4)
[2565319.892]  -> wl_registry@2.bind(49, "wl_output", 4, new id [unknown]@5)
[2565319.929]  -> wl_registry@2.bind(48, "zxdg_output_manager_v1", 3, new id [unknown]@6)
[2565319.966]  -> zxdg_output_manager_v1@6.get_xdg_output(new id zxdg_output_v1@7, wl_output@5)
[2565319.989]  -> wl_registry@2.bind(14, "wl_seat", 7, new id [unknown]@8)
[2565320.038]  -> wl_registry@2.bind(44, "wp_fractional_scale_manager_v1", 1, new id [unknown]@9)
[2565320.055]  -> wl_registry@2.bind(10, "wp_viewporter", 1, new id [unknown]@10)
[2565320.065]  -> wl_registry@2.bind(1, "wl_shm", 1, new id [unknown]@11)
[2565320.074]  -> wl_registry@2.bind(13, "xdg_wm_base", 6, new id [unknown]@12)
[2565320.082]  -> wl_registry@2.bind(19, "zxdg_decoration_manager_v1", 1, new id [unknown]@13)
[2565320.093]  -> wl_registry@2.bind(37, "xdg_activation_v1", 1, new id [unknown]@14)
[2565320.106]  -> wl_registry@2.bind(35, "zwp_text_input_manager_v3", 1, new id [unknown]@15)
[2565320.114]  -> wl_registry@2.bind(23, "zwp_relative_pointer_manager_v1", 1, new id [unknown]@16)
[2565320.126]  -> wl_registry@2.bind(22, "zwp_pointer_constraints_v1", 1, new id [unknown]@17)
[2565320.135]  -> wl_display@1.sync(new id wl_callback@18)
[2565320.247] wl_display@1.delete_id(18)
[2565320.253] wl_output@5.geometry(0, 0, 600, 340, 0, "Microstep", "MSI G27C5", 0)
[2565320.265] wl_output@5.mode(1, 1920, 1080, 60000)
[2565320.269] wl_output@5.scale(1)
[2565320.272] wl_output@5.name("DP-1")
[2565320.275] wl_output@5.description("Microstep MSI G27C5 0x000018EB (DP-1)")
[2565320.281] wl_output@5.done()
[2565320.284] zxdg_output_v1@7.name("DP-1")
[2565320.288] zxdg_output_v1@7.description("Microstep MSI G27C5 0x000018EB (DP-1)")
[2565320.291] zxdg_output_v1@7.logical_position(0, 0)
[2565320.296] zxdg_output_v1@7.logical_size(1920, 1080)
[2565320.300] wl_output@5.done()
[2565320.303] wl_seat@8.name("seat0")
[2565320.307] wl_seat@8.capabilities(3)
[2565320.310] wl_shm@11.format(0)
[2565320.314] wl_shm@11.format(1)
[2565320.316] wl_shm@11.format(875709016)
[2565320.319] wl_shm@11.format(875708993)
[2565320.324] wl_shm@11.format(875710274)
[2565320.327] wl_shm@11.format(842094674)
[2565320.330] wl_shm@11.format(842088786)
[2565320.332] wl_shm@11.format(892426322)
[2565320.335] wl_shm@11.format(892420434)
[2565320.338] wl_shm@11.format(909199186)
[2565320.341] wl_shm@11.format(1211384408)
[2565320.344] wl_shm@11.format(1211384385)
[2565320.347] wl_shm@11.format(942948952)
[2565320.350] wl_shm@11.format(942948929)
[2565320.352] wl_callback@18.done(20513)
[2565320.399]  -> wl_seat@8.get_keyboard(new id wl_keyboard@18)
[2565322.304]  -> zwp_text_input_manager_v3@15.get_text_input(new id zwp_text_input_v3@19, wl_seat@8)
[2565322.321]  -> wl_compositor@3.create_surface(new id wl_surface@20)
[2565322.331]  -> wl_seat@8.get_pointer(new id wl_pointer@21)
[2565322.340]  -> wl_registry@2.bind(39, "wp_cursor_shape_manager_v1", 1, new id [unknown]@22)
[2565322.351]  -> wp_cursor_shape_manager_v1@22.get_pointer(new id wp_cursor_shape_device_v1@23, wl_pointer@21)
[2565322.363]  -> zwp_relative_pointer_manager_v1@16.get_relative_pointer(new id zwp_relative_pointer_v1@24, wl_pointer@21)
[2565322.424]  -> wl_compositor@3.create_surface(new id wl_surface@25)
[2565322.439]  -> xdg_wm_base@12.get_xdg_surface(new id xdg_surface@26, wl_surface@25)
[2565322.447]  -> xdg_surface@26.get_toplevel(new id xdg_toplevel@27)
[2565322.456]  -> zxdg_decoration_manager_v1@13.get_toplevel_decoration(new id zxdg_toplevel_decoration_v1@28, xdg_toplevel@27)
[2565322.464]  -> zxdg_toplevel_decoration_v1@28.set_mode(2)
[2565322.472]  -> wp_viewporter@10.get_viewport(new id wp_viewport@29, wl_surface@25)
[2565322.481]  -> wp_fractional_scale_manager_v1@9.get_fractional_scale(new id wp_fractional_scale_v1@30, wl_surface@25)
[2565322.496]  -> wl_compositor@3.create_region(new id wl_region@31)
[2565322.504]  -> wl_region@31.add(0, 0, 2147483647, 2147483647)
[2565322.511]  -> wl_surface@25.set_opaque_region(wl_region@31)
[2565322.515]  -> wl_region@31.destroy()
[2565322.525]  -> xdg_toplevel@27.set_title("winit window")
[2565322.540]  -> xdg_toplevel@27.set_min_size(2, 1)
[2565322.545]  -> xdg_toplevel@27.set_max_size(0, 0)
[2565322.550]  -> wl_surface@25.commit()
[2565322.562]  -> wl_display@1.sync(new id wl_callback@32)
[2565322.708] wl_display@1.delete_id(31)
[2565322.715] wl_display@1.delete_id(32)
[2565322.718] wl_keyboard@18.keymap(1, fd 9, 64756)
[2565322.726] wl_keyboard@18.repeat_info(25, 600)
[2565322.729] wp_fractional_scale_v1@30.preferred_scale(120)
[2565322.733] wl_callback@32.done(20514)
[2565322.738] xdg_toplevel@27.wm_capabilities(array[16])
[2565322.743] xdg_toplevel@27.configure(960, 1050, array[0])
[2565322.747] zxdg_toplevel_decoration_v1@28.configure(2)
[2565322.751] xdg_surface@26.configure(20514)
[2565324.098]  -> xdg_surface@26.ack_configure(20514)
[2565324.114]  -> wl_compositor@3.create_region(new id wl_region@32)
[2565324.123]  -> wl_region@32.add(0, 0, 2147483647, 2147483647)
[2565324.129]  -> wl_surface@25.set_opaque_region(wl_region@32)
[2565324.133]  -> wl_region@32.destroy()
[2565324.141]  -> xdg_surface@26.set_window_geometry(0, 0, 960, 1050)
[2565324.147]  -> wp_viewport@29.set_destination(960, 1050)
[2565486.426]  -> wl_display@1.get_registry(new id wl_registry@2)
[2565486.438]  -> wl_display@1.sync(new id wl_callback@3)
[2565486.545] wl_display@1.delete_id(3)
[2565486.554] wl_registry@2.global(1, "wl_shm", 1)
[2565486.559] wl_registry@2.global(2, "wl_drm", 2)
[2565486.563]  -> wl_registry@2.bind(2, "wl_drm", 2, new id [unknown]@4)
[2565486.568] wl_registry@2.global(3, "zwp_linux_dmabuf_v1", 4)
[2565486.573] wl_registry@2.global(4, "wl_compositor", 6)
[2565486.578] wl_registry@2.global(5, "wl_subcompositor", 1)
[2565486.583] wl_registry@2.global(6, "wl_data_device_manager", 3)
[2565486.587] wl_registry@2.global(7, "zwlr_export_dmabuf_manager_v1", 1)
[2565486.591] wl_registry@2.global(8, "zwlr_data_control_manager_v1", 2)
[2565486.595] wl_registry@2.global(9, "zwp_primary_selection_device_manager_v1", 1)
[2565486.599] wl_registry@2.global(10, "wp_viewporter", 1)
[2565486.603] wl_registry@2.global(11, "zwlr_gamma_control_manager_v1", 1)
[2565486.608] wl_registry@2.global(12, "zwlr_output_power_manager_v1", 1)
[2565486.612] wl_registry@2.global(13, "xdg_wm_base", 6)
[2565486.617] wl_registry@2.global(14, "wl_seat", 9)
[2565486.620] wl_registry@2.global(15, "wp_presentation", 1)
[2565486.624] wl_registry@2.global(16, "ext_idle_notifier_v1", 1)
[2565486.628] wl_registry@2.global(17, "zwlr_layer_shell_v1", 4)
[2565486.632] wl_registry@2.global(18, "org_kde_kwin_server_decoration_manager", 1)
[2565486.636] wl_registry@2.global(19, "zxdg_decoration_manager_v1", 1)
[2565486.641] wl_registry@2.global(20, "zwlr_output_manager_v1", 4)
[2565486.645] wl_registry@2.global(21, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1)
[2565486.649] wl_registry@2.global(22, "zwp_pointer_constraints_v1", 1)
[2565486.653] wl_registry@2.global(23, "zwp_relative_pointer_manager_v1", 1)
[2565486.657] wl_registry@2.global(24, "zwp_virtual_keyboard_manager_v1", 1)
[2565486.661] wl_registry@2.global(25, "zwlr_virtual_pointer_manager_v1", 2)
[2565486.665] wl_registry@2.global(26, "zwlr_foreign_toplevel_manager_v1", 3)
[2565486.669] wl_registry@2.global(27, "wp_drm_lease_device_v1", 1)
[2565486.673] wl_registry@2.global(28, "zwp_tablet_manager_v2", 1)
[2565486.677] wl_registry@2.global(29, "zwp_idle_inhibit_manager_v1", 1)
[2565486.681] wl_registry@2.global(30, "zxdg_exporter_v1", 1)
[2565486.685] wl_registry@2.global(31, "zxdg_importer_v1", 1)
[2565486.689] wl_registry@2.global(32, "zxdg_exporter_v2", 1)
[2565486.693] wl_registry@2.global(33, "zxdg_importer_v2", 1)
[2565486.697] wl_registry@2.global(34, "zwp_pointer_gestures_v1", 3)
[2565486.700] wl_registry@2.global(35, "zwp_text_input_manager_v3", 1)
[2565486.704] wl_registry@2.global(36, "zwp_input_method_manager_v2", 1)
[2565486.708] wl_registry@2.global(37, "xdg_activation_v1", 1)
[2565486.712] wl_registry@2.global(38, "ext_session_lock_manager_v1", 1)
[2565486.716] wl_registry@2.global(39, "wp_cursor_shape_manager_v1", 1)
[2565486.720] wl_registry@2.global(40, "wp_tearing_control_manager_v1", 1)
[2565486.723] wl_registry@2.global(41, "wp_single_pixel_buffer_manager_v1", 1)
[2565486.727] wl_registry@2.global(42, "xwayland_shell_v1", 1)
[2565486.731] wl_registry@2.global(43, "hyprland_toplevel_export_manager_v1", 2)
[2565486.735] wl_registry@2.global(44, "wp_fractional_scale_manager_v1", 1)
[2565486.739] wl_registry@2.global(45, "zwp_text_input_manager_v1", 1)
[2565486.741] wl_registry@2.global(46, "hyprland_global_shortcuts_manager_v1", 1)
[2565486.744] wl_registry@2.global(47, "zwlr_screencopy_manager_v1", 3)
[2565486.746] wl_registry@2.global(48, "zxdg_output_manager_v1", 3)
[2565486.749] wl_registry@2.global(49, "wl_output", 4)
[2565486.751] wl_callback@3.done(20514)
[2565486.755]  -> wl_display@1.sync(new id wl_callback@3)
[2565486.805] wl_display@1.delete_id(3)
[2565486.810] wl_drm@4.device("/dev/dri/renderD128")
[2565486.814] wl_drm@4.capabilities(1)
[2565486.817] wl_drm@4.format(875708993)
[2565486.820] wl_drm@4.format(875709016)
[2565486.823] wl_drm@4.format(538982482)
[2565486.827] wl_drm@4.format(943212370)
[2565486.830] wl_drm@4.format(540422482)
[2565486.833] wl_drm@4.format(842221394)
[2565486.836] wl_drm@4.format(1498831189)
[2565486.839] wl_drm@4.format(842093121)
[2565486.843] wl_drm@4.format(842089025)
[2565486.846] wl_drm@4.format(842088786)
[2565486.849] wl_drm@4.format(842088770)
[2565486.852] wl_drm@4.format(892424792)
[2565486.855] wl_drm@4.format(892420696)
[2565486.859] wl_drm@4.format(892426322)
[2565486.861] wl_drm@4.format(892426306)
[2565486.865] wl_drm@4.format(892424769)
[2565486.868] wl_drm@4.format(892420673)
[2565486.872] wl_drm@4.format(892420434)
[2565486.875] wl_drm@4.format(892420418)
[2565486.879] wl_drm@4.format(1211384385)
[2565486.882] wl_drm@4.format(1211384408)
[2565486.886] wl_drm@4.format(875713089)
[2565486.889] wl_drm@4.format(875713345)
[2565486.891] wl_drm@4.format(875713368)
[2565486.893] wl_drm@4.format(875713112)
[2565486.895] wl_drm@4.format(943867730)
[2565486.897] wl_drm@4.format(909199186)
[2565486.899] wl_drm@4.format(909199170)
[2565486.901] wl_drm@4.format(875710290)
[2565486.903] wl_drm@4.format(875710274)
[2565486.905] wl_drm@4.format(808669761)
[2565486.907] wl_drm@4.format(875714642)
[2565486.909] wl_drm@4.format(875714626)
[2565486.912] wl_drm@4.format(875708754)
[2565486.914] wl_drm@4.format(875708738)
[2565486.915] wl_drm@4.format(808669784)
[2565486.917] wl_drm@4.format(808665688)
[2565486.919] wl_drm@4.format(808671314)
[2565486.921] wl_drm@4.format(808671298)
[2565486.923] wl_drm@4.format(808665426)
[2565486.926] wl_drm@4.format(808665410)
[2565486.929] wl_drm@4.format(825241938)
[2565486.931] wl_drm@4.format(808464722)
[2565486.933] wl_drm@4.format(808665665)
[2565486.935] wl_drm@4.format(825241922)
[2565486.937] wl_drm@4.format(808464706)
[2565486.939] wl_drm@4.format(842093913)
[2565486.941] wl_drm@4.format(842094158)
[2565486.943] wl_drm@4.format(825382478)
[2565486.945] wl_drm@4.format(909203022)
[2565486.947] wl_drm@4.format(875714126)
[2565486.949] wl_drm@4.format(808530000)
[2565486.951] wl_drm@4.format(808530512)
[2565486.953] wl_drm@4.format(842084432)
[2565486.955] wl_drm@4.format(825246792)
[2565486.957] wl_drm@4.format(809781333)
[2565486.959] wl_callback@3.done(20514)
[2565487.623]  -> wl_display@1.get_registry(new id wl_registry@3)
[2565487.630]  -> wl_display@1.sync(new id wl_callback@5)
[2565487.701] wl_display@1.delete_id(5)
[2565487.705] wl_registry@3.global(1, "wl_shm", 1)
[2565487.708] wl_registry@3.global(2, "wl_drm", 2)
[2565487.711] wl_registry@3.global(3, "zwp_linux_dmabuf_v1", 4)
[2565487.715]  -> wl_registry@3.bind(3, "zwp_linux_dmabuf_v1", 4, new id [unknown]@6)
[2565487.719] wl_registry@3.global(4, "wl_compositor", 6)
[2565487.723] wl_registry@3.global(5, "wl_subcompositor", 1)
[2565487.727] wl_registry@3.global(6, "wl_data_device_manager", 3)
[2565487.730] wl_registry@3.global(7, "zwlr_export_dmabuf_manager_v1", 1)
[2565487.734] wl_registry@3.global(8, "zwlr_data_control_manager_v1", 2)
[2565487.737] wl_registry@3.global(9, "zwp_primary_selection_device_manager_v1", 1)
[2565487.741] wl_registry@3.global(10, "wp_viewporter", 1)
[2565487.745] wl_registry@3.global(11, "zwlr_gamma_control_manager_v1", 1)
[2565487.749] wl_registry@3.global(12, "zwlr_output_power_manager_v1", 1)
[2565487.753] wl_registry@3.global(13, "xdg_wm_base", 6)
[2565487.757] wl_registry@3.global(14, "wl_seat", 9)
[2565487.760] wl_registry@3.global(15, "wp_presentation", 1)
[2565487.764]  -> wl_registry@3.bind(15, "wp_presentation", 1, new id [unknown]@7)
[2565487.768] wl_registry@3.global(16, "ext_idle_notifier_v1", 1)
[2565487.772] wl_registry@3.global(17, "zwlr_layer_shell_v1", 4)
[2565487.775] wl_registry@3.global(18, "org_kde_kwin_server_decoration_manager", 1)
[2565487.779] wl_registry@3.global(19, "zxdg_decoration_manager_v1", 1)
[2565487.782] wl_registry@3.global(20, "zwlr_output_manager_v1", 4)
[2565487.786] wl_registry@3.global(21, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1)
[2565487.790] wl_registry@3.global(22, "zwp_pointer_constraints_v1", 1)
[2565487.794] wl_registry@3.global(23, "zwp_relative_pointer_manager_v1", 1)
[2565487.798] wl_registry@3.global(24, "zwp_virtual_keyboard_manager_v1", 1)
[2565487.802] wl_registry@3.global(25, "zwlr_virtual_pointer_manager_v1", 2)
[2565487.806] wl_registry@3.global(26, "zwlr_foreign_toplevel_manager_v1", 3)
[2565487.811] wl_registry@3.global(27, "wp_drm_lease_device_v1", 1)
[2565487.816] wl_registry@3.global(28, "zwp_tablet_manager_v2", 1)
[2565487.820] wl_registry@3.global(29, "zwp_idle_inhibit_manager_v1", 1)
[2565487.823] wl_registry@3.global(30, "zxdg_exporter_v1", 1)
[2565487.826] wl_registry@3.global(31, "zxdg_importer_v1", 1)
[2565487.830] wl_registry@3.global(32, "zxdg_exporter_v2", 1)
[2565487.834] wl_registry@3.global(33, "zxdg_importer_v2", 1)
[2565487.837] wl_registry@3.global(34, "zwp_pointer_gestures_v1", 3)
[2565487.840] wl_registry@3.global(35, "zwp_text_input_manager_v3", 1)
[2565487.844] wl_registry@3.global(36, "zwp_input_method_manager_v2", 1)
[2565487.849] wl_registry@3.global(37, "xdg_activation_v1", 1)
[2565487.852] wl_registry@3.global(38, "ext_session_lock_manager_v1", 1)
[2565487.856] wl_registry@3.global(39, "wp_cursor_shape_manager_v1", 1)
[2565487.859] wl_registry@3.global(40, "wp_tearing_control_manager_v1", 1)
[2565487.863] wl_registry@3.global(41, "wp_single_pixel_buffer_manager_v1", 1)
[2565487.867] wl_registry@3.global(42, "xwayland_shell_v1", 1)
[2565487.871] wl_registry@3.global(43, "hyprland_toplevel_export_manager_v1", 2)
[2565487.874] wl_registry@3.global(44, "wp_fractional_scale_manager_v1", 1)
[2565487.877] wl_registry@3.global(45, "zwp_text_input_manager_v1", 1)
[2565487.881] wl_registry@3.global(46, "hyprland_global_shortcuts_manager_v1", 1)
[2565487.885] wl_registry@3.global(47, "zwlr_screencopy_manager_v1", 3)
[2565487.888] wl_registry@3.global(48, "zxdg_output_manager_v1", 3)
[2565487.892] wl_registry@3.global(49, "wl_output", 4)
[2565487.896] wl_callback@5.done(20514)
[2565487.901]  -> zwp_linux_dmabuf_v1@6.get_default_feedback(new id zwp_linux_dmabuf_feedback_v1@5)
[2565487.906]  -> wl_display@1.sync(new id wl_callback@8)
[2565487.944] wl_display@1.delete_id(8)
[2565487.947] zwp_linux_dmabuf_feedback_v1@5.main_device(array[8])
[2565487.950] zwp_linux_dmabuf_feedback_v1@5.format_table(fd 26, 12544)
[2565487.970] zwp_linux_dmabuf_feedback_v1@5.tranche_target_device(array[8])
[2565487.973] zwp_linux_dmabuf_feedback_v1@5.tranche_flags(0)
[2565487.978] zwp_linux_dmabuf_feedback_v1@5.tranche_formats(array[1568])
[2565488.030] zwp_linux_dmabuf_feedback_v1@5.tranche_done()
[2565488.033] zwp_linux_dmabuf_feedback_v1@5.done()
[2565488.036] wl_callback@8.done(20514)
[2565492.888]  -> wl_display@1.get_registry(new id wl_registry@31)
[2565492.897]  -> wl_display@1.sync(new id wl_callback@33)

so then I tried running it on river, which didn't crash and allowed me to replicate the issue properly. The output is here. One interesting (or maybe trivially unimportant) difference between the river and Hyprland runs was that on river the clear colour didn't fill the entire window.

GenericConfluent commented 6 months ago

Also, could you see where it's getting stuck? It feels like it's getting stuck inside the drawing actually? Use gdb for that, so it's not polling, but rather blocked on calling to nvidia driver, if that's the case, bring it to nvidia and it's not related to winit in any way.

I'll give it a good run-through in the debugger and try to see where the freeze happens.

GenericConfluent commented 6 months ago

I pulled in the master branch and rewrote the sample with the necessary updates for debugging. I went to run it and... everything worked. Went back to the crates.io version and it crashed again. I'm not sure why it works but it does, regardless this doesn't need a fix.

hannesojala commented 6 months ago

I'm on the same setup as you (prop. NVIDIA and Hyprland) and still having the same issue using winit = { git = "https://github.com/rust-windowing/winit.git", branch = "master" } in a wgpu app.

Pausing in the debugger yields this call stack, which lines up with what @kchibisov says. (Probably not a winit issue)

__poll (@__poll:23)
___lldb_unnamed_symbol36075 (@___lldb_unnamed_symbol36075:42)
___lldb_unnamed_symbol44333 (@___lldb_unnamed_symbol44333:22)
___lldb_unnamed_symbol44144 (@___lldb_unnamed_symbol44144:158)
___lldb_unnamed_symbol42740 (@___lldb_unnamed_symbol42740:10)
DispatchWaitForFences(VkDevice_T*, unsigned int, VkFence_T* const*, unsigned int, unsigned long) (@DispatchWaitForFences(VkDevice_T*, unsigned int, VkFence_T* const*, unsigned int, unsigned long):78)
vulkan_layer_chassis::WaitForFences(VkDevice_T*, unsigned int, VkFence_T* const*, unsigned int, unsigned long) (@vulkan_layer_chassis::WaitForFences(VkDevice_T*, unsigned int, VkFence_T* const*, unsigned int, unsigned long):180)
ash::device::Device::wait_for_fences
wgpu_hal::vulkan::instance::<impl wgpu_hal::Surface<wgpu_hal::vulkan::Api> for wgpu_hal::vulkan::Surface>::acquire_texture
wgpu_core::present::<impl wgpu_core::global::Global<G>>::surface_get_current_texture
<wgpu::backend::wgpu_core::ContextWgpuCore as wgpu::context::Context>::surface_get_current_texture
<T as wgpu::context::DynContext>::surface_get_current_texture
wgpu::Surface::get_current_texture
...

@GenericConfluent Can you think of anything else other than updating winit that changed for you? I'm not having any luck with updating.

EDIT: It seems like my problem was related to https://github.com/gfx-rs/wgpu/issues/4775. Using the latest commit of wgpu did the trick.