-
Notifications
You must be signed in to change notification settings - Fork 920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebGL and WebGPU backends should not panic if canvas context is unavailable #3017
Comments
kpreid
added a commit
to kpreid/wgpu
that referenced
this issue
Sep 27, 2022
…ebGL 2). Part of fixing gfx-rs#3017. This commit changes the handling of `web_sys` errors and nulls from `expect()` to returning `Err`, but it doesn't actually affect the public API — that will be done in the next commit.
kpreid
added a commit
to kpreid/wgpu
that referenced
this issue
Sep 27, 2022
…s errors. Part of fixing gfx-rs#3017.
3 tasks
kpreid
added a commit
to kpreid/wgpu
that referenced
this issue
Nov 25, 2022
…ebGL 2). Part of fixing gfx-rs#3017. This commit changes the handling of `web_sys` errors and nulls from `expect()` to returning `Err`, but it doesn't actually affect the public API — that will be done in the next commit.
kpreid
added a commit
to kpreid/wgpu
that referenced
this issue
Nov 25, 2022
…s errors. Part of fixing gfx-rs#3017.
kpreid
added a commit
to kpreid/wgpu
that referenced
this issue
Dec 1, 2022
…ebGL 2). Part of fixing gfx-rs#3017. This commit changes the handling of `web_sys` errors and nulls from `expect()` to returning `Err`, but it doesn't actually affect the public API — that will be done in the next commit.
kpreid
added a commit
to kpreid/wgpu
that referenced
this issue
Dec 1, 2022
…s errors. Part of fixing gfx-rs#3017.
cwfitzgerald
pushed a commit
that referenced
this issue
Dec 1, 2022
…le (#3052) * Low-level error handling in canvas context creation (for WebGPU and WebGL 2). Part of fixing #3017. This commit changes the handling of `web_sys` errors and nulls from `expect()` to returning `Err`, but it doesn't actually affect the public API — that will be done in the next commit. * Breaking: Change type of `create_surface()` functions to expose canvas errors. Part of fixing #3017.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The WebGL and WebGPU backends have code which
expect()
s success in obtaining a canvas:wgpu/wgpu/src/backend/web.rs
Lines 956 to 959 in 94ce763
wgpu/wgpu-hal/src/gles/web.rs
Lines 36 to 41 in 94ce763
These will panic if the browser declines to provide a context, which may happen for reasons outside of the application programmer's control (browser does not support WebGPU or WebGL2, insufficient GPU memory, browser glitches) as well as ones which are (such as trying to use the same canvas for
"2d"
drawing). Therefore, the application may have reason to handle the error (if nothing else, to give the user an error message visible on the web page), which is best done by returning anErr
rather than panicking — especially as Rust onwasm32
does not support unwinding, so every panic is fatal to the Rust module and can at best be handled from JavaScript.This is not a solely theoretical scenario — I noticed the problem due to some Bevy Jam #2 games failing to start.
Platform
web, wgpu 0.13
The text was updated successfully, but these errors were encountered: