eliemichel / LearnWebGPU-Code

The accompanying code of the Learn WebGPU C++ programming guide
https://eliemichel.github.io/LearnWebGPU
MIT License
114 stars 30 forks source link

step095 runtime error on MacOS #24

Open pierricgimmig opened 1 year ago

pierricgimmig commented 1 year ago

When launching the app built from a clean branch step095 on MacOS, I get:

pierric@pierrics-mbp LearnWebGPU-Code % ./build/App               
Requesting adapter...
Got adapter: <wgpu::Adapter 0x6000028b3b20>
Requesting device...
Got device: <wgpu::Device 0x600000d8dd50>
thread '<unnamed>' panicked at 'Unexpected backend Empty', src/lib.rs:3619:22
stack backtrace:
   0:        0x10515c070 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h819e9cbdf1a9e730
   1:        0x105173864 - core::fmt::write::ha5e9bf3131ecb7c0
   2:        0x105159f80 - std::io::Write::write_fmt::h414ce9994bf17404
   3:        0x10515be84 - std::sys_common::backtrace::print::h8072db0bbd5bcc3d
   4:        0x10515d0f8 - std::panicking::default_hook::{{closure}}::h2c85c5b0c2ede151
   5:        0x10515ceb8 - std::panicking::default_hook::hcf2f70992d02f6fe
   6:        0x10515d5d0 - std::panicking::rust_panic_with_hook::h023af7f90b47eb8b
   7:        0x10515d504 - std::panicking::begin_panic_handler::{{closure}}::h14283519edc1d634
   8:        0x10515c490 - std::sys_common::backtrace::__rust_end_short_backtrace::hc366c0b0cef5b747
   9:        0x10515d298 - _rust_begin_unwind
  10:        0x10519cc64 - core::panicking::panic_fmt::h324f50b29db90195
  11:        0x104f6ffa4 - _wgpuSurfaceGetPreferredFormat
  12:        0x10421574c - __ZN4wgpu7Surface18getPreferredFormatENS_7AdapterE
  13:        0x1041f3044 - __ZN11Application19initWindowAndDeviceEv
  14:        0x1041f2ae4 - __ZN11Application6onInitEv
  15:        0x1041f2118 - _main
fatal runtime error: failed to initiate panic, error 5
zsh: abort      ./build/App
pierric@pierrics-mbp LearnWebGPU-Code % 
pierricgimmig commented 1 year ago

Compiling and running step095 on Ubuntu 22.04 work without a hitch.

eliemichel commented 1 year ago

Is it a ARM (M1) or an x64 CPU? I may be able to test on a mac soon.

dennisferron commented 12 months ago

What's your screen resolution? See: https://github.com/eliemichel/LearnWebGPU-Code/issues/30

bugulo commented 11 months ago

I stumbled upon this as well.

The issue is that the adapter is released right after device is requested, and then bit later m_surface.getPreferredFormat(adapter) is called on already released adapter. Seems to solve the issue if you release the adapter later. @eliemichel