bevy: Panic in bevy_render when acquiring next swapchain texture
Bevy version
0.6
Operating system & version
Manjaro Gnome (Wayland)
What you did
Tried to run the button UI example, then tried to run the most basic piece of rendering Bevy code:
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.run();
}
What you expected to happen
A blank window with the default clear color.
What actually happened
A panic when acquiring “next swapchain texture”. The specific panic message:
thread 'main' panicked at 'Failed to acquire next swap chain texture!: Timeout', /home/<user>/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.6.0/src/view/window.rs:161:24
Additional information
When running with the default windowing config (X11 through winit
) the application hangs after closing the window, while it “destroys 2 command encoders” and exists properly when enabling Wayland in bevy_winit
. The log below is with Wayland
enabled. Only the last log line is different on X11.
The full log at the INFO
level:
2022-01-09T12:59:35.490450Z INFO wgpu_hal::vulkan::instance: Instance version: 0x4020ca
2022-01-09T12:59:35.490504Z INFO wgpu_hal::vulkan::instance: Enabling debug utils
2022-01-09T12:59:35.490562Z INFO wgpu_hal::vulkan::instance: Enabling device properties2
2022-01-09T12:59:35.499823Z INFO wgpu_core::instance: Adapter Vulkan AdapterInfo { name: "AMD Radeon RX 5700 XT", vendor: 4098, device: 29471, device_type: DiscreteGpu, backend: Vulkan }
2022-01-09T12:59:35.499880Z INFO bevy_render::renderer: AdapterInfo { name: "AMD Radeon RX 5700 XT", vendor: 4098, device: 29471, device_type: DiscreteGpu, backend: Vulkan }
2022-01-09T12:59:35.499913Z WARN wgpu_core::instance: Feature MAPPABLE_PRIMARY_BUFFERS enabled on a discrete gpu. This is a massive performance footgun and likely not what you wanted
2022-01-09T12:59:35.501677Z INFO wgpu_hal::vulkan::instance: GENERAL [Loader Message (0x0)]
Loading layer library libVkLayer_khronos_validation.so
2022-01-09T12:59:35.501697Z INFO wgpu_hal::vulkan::instance: objects: (type: INSTANCE, hndl: 0x5575ec046ee0, name: ?)
2022-01-09T12:59:35.501710Z INFO wgpu_hal::vulkan::instance: GENERAL [Loader Message (0x0)]
Inserted device layer VK_LAYER_KHRONOS_validation (libVkLayer_khronos_validation.so)
2022-01-09T12:59:35.501724Z INFO wgpu_hal::vulkan::instance: objects: (type: INSTANCE, hndl: 0x5575ec046ee0, name: ?)
2022-01-09T12:59:35.501746Z INFO wgpu_hal::vulkan::instance: GENERAL [Loader Message (0x0)]
/usr/lib32/amdvlk32.so: wrong ELF class: ELFCLASS32
2022-01-09T12:59:35.501762Z INFO wgpu_hal::vulkan::instance: objects: (type: INSTANCE, hndl: 0x5575ec046ee0, name: ?)
2022-01-09T12:59:35.501775Z INFO wgpu_hal::vulkan::instance: GENERAL [Loader Message (0x0)]
Loading layer library /usr/lib/amdvlk64.so
2022-01-09T12:59:35.501788Z INFO wgpu_hal::vulkan::instance: objects: (type: INSTANCE, hndl: 0x5575ec046ee0, name: ?)
2022-01-09T12:59:35.501802Z INFO wgpu_hal::vulkan::instance: GENERAL [Loader Message (0x0)]
Failed to find vkGetDeviceProcAddr in layer /usr/lib/amdvlk64.so
2022-01-09T12:59:35.501815Z INFO wgpu_hal::vulkan::instance: objects: (type: INSTANCE, hndl: 0x5575ec046ee0, name: ?)
2022-01-09T12:59:35.501828Z INFO wgpu_hal::vulkan::instance: GENERAL [Loader Message (0x0)]
Loading layer library libVkLayer_MESA_device_select.so
2022-01-09T12:59:35.501841Z INFO wgpu_hal::vulkan::instance: objects: (type: INSTANCE, hndl: 0x5575ec046ee0, name: ?)
2022-01-09T12:59:35.501854Z INFO wgpu_hal::vulkan::instance: GENERAL [Loader Message (0x0)]
Failed to find vkGetDeviceProcAddr in layer libVkLayer_MESA_device_select.so
2022-01-09T12:59:35.501867Z INFO wgpu_hal::vulkan::instance: objects: (type: INSTANCE, hndl: 0x5575ec046ee0, name: ?)
2022-01-09T12:59:35.503802Z INFO wgpu_hal::vulkan::adapter: Private capabilities: PrivateCapabilities { flip_y_requires_shift: true, imageless_framebuffers: true, image_view_usage: true, timeline_semaphores: true, texture_d24: false, texture_d24_s8: false, can_present: true, non_coherent_map_mask: 127, robust_buffer_access: true, robust_image_access: true }
2022-01-09T12:59:35.517292Z INFO wgpu_core::device: Created texture Valid((0, 1, Vulkan)) with TextureDescriptor { label: None, size: Extent3d { width: 1, height: 1, depth_or_array_layers: 1 }, mip_level_count: 1, sample_count: 1, dimension: D2, format: Bgra8UnormSrgb, usage: COPY_DST | TEXTURE_BINDING }
2022-01-09T12:59:35.528681Z INFO wgpu_core::device: Created texture Valid((1, 1, Vulkan)) with TextureDescriptor { label: None, size: Extent3d { width: 1, height: 1, depth_or_array_layers: 1 }, mip_level_count: 1, sample_count: 1, dimension: D2, format: Bgra8UnormSrgb, usage: COPY_DST | TEXTURE_BINDING }
2022-01-09T12:59:35.599069Z WARN gilrs_core::platform::platform::gamepad: "/dev/input/event3" doesn't have at least 1 button and 2 axes, ignoring.
2022-01-09T12:59:35.630673Z INFO wgpu_core::device: Created buffer Valid((0, 1, Vulkan)) with BufferDescriptor { label: None, size: 16384, usage: COPY_DST | UNIFORM, mapped_at_creation: false }
2022-01-09T12:59:35.631975Z INFO wgpu_core::device: configuring surface with SurfaceConfiguration { usage: RENDER_ATTACHMENT, format: Bgra8UnormSrgb, width: 1280, height: 720, present_mode: Fifo }
2022-01-09T12:59:35.632080Z INFO wgpu_core::device: Created texture Valid((2, 1, Vulkan)) with TextureDescriptor { label: None, size: Extent3d { width: 1, height: 1, depth_or_array_layers: 1 }, mip_level_count: 1, sample_count: 1, dimension: D2, format: Bgra8UnormSrgb, usage: COPY_DST | TEXTURE_BINDING }
2022-01-09T12:59:35.633172Z INFO wgpu_core::device: Created buffer Valid((1, 1, Vulkan)) with BufferDescriptor { label: Some("color_material_uniform_buffer"), size: 32, usage: COPY_DST | UNIFORM, mapped_at_creation: true }
2022-01-09T12:59:35.633193Z INFO wgpu_core::device: Created buffer Valid((2, 1, Vulkan)) with BufferDescriptor { label: Some("pbr_standard_material_uniform_buffer"), size: 64, usage: COPY_DST | UNIFORM, mapped_at_creation: true }
thread 'main' panicked at 'Failed to acquire next swap chain texture!: Timeout', /home/<user>/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.6.0/src/view/window.rs:161:24
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2022-01-09T12:59:35.698147Z INFO wgpu_core::hub: Dropping Global
2022-01-09T12:59:35.709770Z INFO wgpu_core::device: Destroying 2 command encoders
If it’s any help, I can confirm that vkcube
works perfectly on the system.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 32 (8 by maintainers)
Commits related to this issue
- Ignore `Timeout` errors on Linux AMD & Intel (#5957) # Objective - Fix #3606 - Fix #4579 - Fix #3380 ## Solution When running on a Linux machine with some AMD or Intel device, when calling... — committed to bevyengine/bevy by nicopap 2 years ago
- Ignore `Timeout` errors on Linux AMD & Intel (#5957) # Objective - Fix #3606 - Fix #4579 - Fix #3380 ## Solution When running on a Linux machine with some AMD or Intel device, when calling... — committed to ItsDoot/bevy by nicopap 2 years ago
@nyvs this should find you well: https://wiki.archlinux.org/title/Vulkan#Selecting_Vulkan_driver.
Otherwise, make sure you have the
vulkan-radeon
andamdvlk
packages installed. UseAMD_VULKAN_ICD=RADV cargo run
when running a program to forceRADV
driver to be used. UseAMD_VULKAN_ICD=AMDVLK cargo run
to use AMDVLK. Beware that when both drivers are installedamdvlk
becomes the default unless you specify otherwise in your environment. The Arch Wiki link has the details. Feel free to reach out if the wiki isn’t clear enough. Otherwise do like k-brk and only install the one you prefer.Some more points on my own troubles:
many_cubes
andpbr
examples) work perfectly with both driverssprite
doesn’t work on AMDVLK whilemany_sprites
does.Can someone running
amdvlk
try running an example that fails with the Timeout error with vsync disabled to see if that resolves the problem? Wgpu has an open issue that might be related.WGPU_BACKEND=gl cargo run this will run successfully
I was about to create a new issue, but adding to this one is better. Here is details on what happens to me
When running my game, using the amdgpu-pro drivers (literally just
cargo run
) my game crashes as soon as it opens, with the following error:This doesn’t occur with the default
amdgpu
drivers. However, amdgpu-pro is required to use the AMD GPU profiler.Precise steps:
cargo run
(in the case of bevycargo run --release --example many_cubes
)Note that if
--release
flag is not present, it doesn’t crash with the bevy examples, I imagine the debug builds for my game crash because I specify:Environment
bevy: 0.8.1 & 0.9.0-dev (tried
lighting
,many_cubes
,ui
,3d_scene
) OS: Archlinux Kernel: 5.19.5-arch1-1 cpu: amd ryzen 9 3900X 12-Core gpu: amd radeon rx 5700 xt driver: vulkan-amdgpu-pro 22.10.3_1420322-1Working driver is
xf86-video-amdgpu 22.0.0-1
Workaround
Setting the
present_mode
toImmediate
fixes it. And anyway I need it to get meaningful information out of the profiler.Solution
The error seems to be in
window.rs
in theprepare_windows
function. Indeed, using aif let Some(frame)
instead of panicking does fix the issue. This was already discussed in previous related issues.Related
A few known issues occur at the same place:
Had this problem as well as detailed in discord thread: https://discord.com/channels/691052431525675048/749690364792668301/983133065834532884
Using
AMD_VULKAN_ICD=RADV
did indeed solve my issue. I’m using just a 5700G CPU with its iGPU. Thanks bjorn3 and cart!I’ll remove
amdvlk
for now, but can definitely reinstall it if needed for tests!Posted to the original issue already but just in case. Since 5.10.91 kernel patch I don’t experience this issue. 5.10.88 was last know kernel I had this issue with. I’m using NixOS unstable (don’t know what kernel Arch ships).
There is a lot of contradicting information so I’m no longer sure about it. But from my testing of multiple combinations of kernels, hw drivers and vulkan drivers I think the problem was with open source driver and that vsync made the issue worse. From my testing the fix was either to switch to proprietary driver or to update kernel (and thus amdgpu).