Skip to content
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

web: Implement Device::on_uncaptured_error #2132

Merged
merged 1 commit into from
Nov 5, 2021

Conversation

Herschel
Copy link
Contributor

@Herschel Herschel commented Oct 30, 2021

Connections
#2130

Description
This PR is a first pass at wiring up Device::on_uncaptured_error on web, mapping the WebGPU errors into wgpu::Error.

Possible improvements:

  • JS does not provide a standardized stack trace on error types, so the Error::source value is bogus.
  • Currently the error handler will not be called if an unknown error type is encountered (say, an error is added to the spec).
  • Due to using wasm_bindgen::Closure::forget, this will leak the memory associated with the closure. This seemed okay for a one-off diagnostic function, and also can be avoided by enabling weak references, available on all major browsers now. Alternatively, a map would need to be maintained between devices and their error handler.

Testing
Tested it in Ruffle to catch errors thrown by Chrome on certain platforms.

Copy link
Collaborator

@grovesNL grovesNL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Ideally we could have a catch-all and avoid leaking this (using weak references seems reasonable), but we can do that in follow-up PRs

@grovesNL grovesNL merged commit 7b3caad into gfx-rs:master Nov 5, 2021
Patryk27 pushed a commit to Patryk27/wgpu that referenced this pull request Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants