examples/runners/wgpu: avoid holding onto to multiple surfaces at the same time. #181
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This unbreaks Wayland (I had been using
WAYLAND_DISPLAY= cargo run ...
for ages instead of investigating it, turns out to have been something very silly).This is what the bug looked like:
I kept thinking maybe this is a Wayland protocol mismatch or something, but no, Mesa (the opensource GPU driver stack for Linux) has a bug:
wsi_wl_surface_init
cangoto fail
but returnVK_SUCCESS
.We accidentally ended up with this broken scenario, on Wayland:
wgpu::Surface
s for the samewl_surface
(the Wayland window object).configure(...)
called on themvkCreateSwapchainKHR
gets calledvkCreateSwapchainKHR
fails to acquire an exclusive resourcewp_linux_drm_syncobj_manager_v1#63: error 0: surface already exists
wgpu
now thinks it has a valid swapchain for the second surface, toowgpu
fails to query various surface propertiesWith
RUST_LOG=wgpu_hal=error
I was able to see theseVK_ERROR_SURFACE_LOST_KHR
(errors which
wgpu
largely ignores, leading to 0 supported modes/formats):(maybe we should run with at least the equivalent of
RUST_LOG=error
by default? I remember being frustrated thatwarn!
/error!
were silent, while working onrustc
self-profiling code, which didn't necessarily need nice user-facing diagnostics, but also didn't have a good way to emit them anyway, from the separatemeasureme
library)While the Mesa bug being fixed wouldn't prevent the second
wgpu::Surface
from being created (viainstance.create_surface(&window)
), it could at least fail with a better error (e.g.VK_ERROR_NATIVE_WINDOW_IN_USE_KHR
) when trying to create the swapchain, which would make the situation less confusing.I've mentioned some of these interactions in this
wgpu
issue: