-
Notifications
You must be signed in to change notification settings - Fork 949
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
Make some errors not fatal #3094
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests make me very happy
I updated the patch. I made a notable change to the error handling after checking the spec: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Format mad, but otherwise LGTM
…valid state. r=jgilbert Once gfx-rs/wgpu#3094 is merged, unallocated and freed handles will panic in wgpu-core so we don't have to do it here. In the mean time it will produce the wrong error but still fail safely. DestroyError::Invalid means the handle exists but is not is in an invalid state, for example if the buffer was created with invalid parameter like in this bug's test case. Differential Revision: https://phabricator.services.mozilla.com/D159054
…valid state. r=jgilbert Once gfx-rs/wgpu#3094 is merged, unallocated and freed handles will panic in wgpu-core so we don't have to do it here. In the mean time it will produce the wrong error but still fail safely. DestroyError::Invalid means the handle exists but is not is in an invalid state, for example if the buffer was created with invalid parameter like in this bug's test case. Differential Revision: https://phabricator.services.mozilla.com/D159054
Checklist
cargo clippy
.Connections
https://bugzilla.mozilla.org/show_bug.cgi?id=1791881
Description
Objects can be created with invalid parameters, putting them in an error state. When interacting with these objects, in the majority of cases validation should fail but wgpu should not panic.
buffer_get_mapped_range
is one of these exceptions because the API user must not call it without getting consent from the status provided in themap_async
callback.Currently wgpu does panic when interacting with invalid resources in a few places and this PR starts fixing that. I did not go over all of them to make sure there is consensus before producing a large-ish patch, and to get the few changes needed to unblock fuzzing as soon as possible.
There two important changes in this patch:
hub.rs
,Some(vacant)
andNone
are the same (it indicates the resource was not created or was already dropped) so they should both be fatal errors.handle_error_fatal
inbackend/direct.rs
should actually push the error into the error sink intsead of panicking.Only the first change really affects Firefox, but I think that the second one better matches the spec and how Firefox uses wgpu-core.
Testing
Tests! I did it again.