gfx-rs / wgpu-native

Native WebGPU implementation based on wgpu-core
Apache License 2.0
865 stars 103 forks source link

On Wayland, application hangs when using Mailbox present mode #377

Closed radgeRayden closed 6 months ago

radgeRayden commented 7 months ago

Using SDL3 on KDE 6 Wayland (Nvidia proprietary drivers, RTX3080). On my own application the application hangs after mimizing to taskbar (using Fifo present mode) or straight away (using Mailbox). I modified the triangle sample to use SDL3 (due to difficulties to get the original one to actually use Wayland) and could only reproduce the Mailbox hang. Currently not sure what the difference is between the window handling code from the sample and my application.

To test the repro you can apply the patch to the current trunk (https://github.com/gfx-rs/wgpu-native/commit/8f94e257f4abef4e5333fc1b181c2b404d6e34c0).

radgeRayden commented 7 months ago

Ran the program under gdb, then interrupted once the hang occurs. The traceback is the same for both manifestations of the bug:

0x00007ffff6b190bf in poll () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff6b190bf in poll () from /usr/lib/libc.so.6
#1  0x00007ffff4e07c13 in ?? () from /usr/lib/libnvidia-glcore.so.550.54.14
#2  0x00007ffff5222449 in ?? () from /usr/lib/libnvidia-glcore.so.550.54.14
#3  0x00007ffff5206ed0 in ?? () from /usr/lib/libnvidia-glcore.so.550.54.14
#4  0x00007ffff51232ce in ?? () from /usr/lib/libnvidia-glcore.so.550.54.14
#5  0x00007ffff05e3714 in DispatchWaitForFences (device=0x5555579afc60, fenceCount=1, pFences=0x7fffffffb660, waitAll=1, 
    timeout=18446744073709551615)
    at /usr/src/debug/vulkan-validation-layers/Vulkan-ValidationLayers-vulkan-sdk-1.3.275/layers/vulkan/generated/layer_chassis_dispatch.cpp:799
#6  0x00007ffff04b8c63 in vulkan_layer_chassis::WaitForFences (device=0x5555579afc60, fenceCount=1, pFences=0x7fffffffb660, 
    waitAll=1, timeout=18446744073709551615)
    at /usr/src/debug/vulkan-validation-layers/Vulkan-ValidationLayers-vulkan-sdk-1.3.275/layers/vulkan/generated/chassis.cpp:1824
#7  0x00007ffff7250494 in ash::device::Device::wait_for_fences (self=0x55555798e0d8, fences=..., wait_all=true, 
    timeout=18446744073709551615)
    at /home/radge/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ash-0.37.3+1.3.251/src/device.rs:2399
#8  0x00007ffff730ace1 in wgpu_hal::vulkan::instance::{impl#6}::acquire_texture (self=0x555557464260, timeout=...)
    at src/vulkan/instance.rs:967
#9  0x00007ffff6d4af60 in wgpu_core::global::Global<wgpu_core::identity::IdentityManagerFactory>::surface_get_current_texture<wgpu_core::identity::IdentityManagerFactory, wgpu_hal::vulkan::Api> (self=0x55555751fd60, surface_id=..., texture_id_in=())
    at /home/radge/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/9f505e7/wgpu-core/src/present.rs:167
#10 0x00007ffff6eeeb33 in wgpu_native::wgpuSurfaceGetCurrentTexture (surface=0x555557538da0, surface_texture=...) at src/lib.rs:3788
#11 0x0000555555556db4 in main ()
radgeRayden commented 7 months ago

Seems very similar to https://github.com/gfx-rs/wgpu/issues/4775

radgeRayden commented 6 months ago

With the newest commit, GLFW now opens a wayland window for me. I can reproduce the minimize hang when in Fifo and instant hang when using Mailbox, in the triangle sample.

radgeRayden commented 6 months ago

Seems to be fixed in the latest driver version 550.67.