-
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
Expose the full Result type to the rust map_async callback #2939
Conversation
Another change that I did not make in this PR but that I would like to push for is to not make Today, Users could decide to handle some errors in callback and some at the Thoughts? |
I get this build error from
|
Piping all results through the callback is certainly a faithful translation of the WebGPU spec's The only thing that worries me about changing |
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.
Needs cargo test --workspace
fixed. Rebasing on recent master should fix the macos build problems.
Since I spend more time n code that use wgpu-core than wgpu I hadn't noticed that wgpu was only exposing a sort of placeholder error type (BufferAsyncError), and that it is already not returning an error in Edit: that breaks because BufferAccessError is in core which the web backend doesn't have access to. Looking around I think I might be going against the intent of how errors should be reported by wgpu since there are a number of other placeholder-looking error types in wgpu. |
64e3cf5
to
c22bdc7
Compare
I removed the commit that replaces BufferAsyncError in favor of BufferAccessError for now. I'll revisit when I better understand the error handlign story. |
c22bdc7
to
f1b5373
Compare
a323444
to
af4f9a0
Compare
I rebased the PR and applied crowlCats's suggestion. The PR still only affects wgpu-core (and not wgpu). If I remember correctly the main decision to make for wgpu is how to deal with the web backend. It looks like the web backend isn't set up to report specific errors, so the options are:
It boils down to whether it is more important to improve the situation on native or to keep native and web on equal footing. I suggest landing this PR as is (unless there are other review comments to address of course) since it's uncontroversial. I'm happy to make the wgpu change (A) in another PR if folks agree with the direction. |
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.
Thank you! The changes to wgpu-core seem reasonable to me.
It boils down to whether it is more important to improve the situation on native or to keep native and web on equal footing.
I think we should generally aim for equal footing by default, and expose opt-in native-only functionality when there's a significant benefit. e.g., ideally out of memory errors would have the same error handling story between native and web if possible, and contain the same amount of detail - unless extra detail would significantly benefit the native backend.
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.
G2G outside one comment
…allback in map_async It provides with more information about the errors. BufferMapAsyncStatus is only needed for the C callback which needs an ffi-frendly payload.
af4f9a0
to
8b497bb
Compare
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.
Thanks!
Checklist
cargo clippy
.Description
map_async
communicates errors in two ways:In practice I don't think that handling errors from the return value of
map_async
is practical because it only reports a subset of errors. Unfortunately the callback, where all error handling can be concentrated, takes a simplified representation of the error which is ffi-friendly but not as useful as the Result type.We only need the ffi-friendly status for the C version of the callback, so in the PR I am proposing exposing the full error type to the rust callback.
Testing
None.