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

Generate a validation error on mapAsync early-reject #4786

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

kainino0x
Copy link
Contributor

@kainino0x kainino0x commented Jul 25, 2024

This is currently a proposal. Approved!

Fixes #4690

@kainino0x kainino0x added proposal api WebGPU API labels Jul 25, 2024
@kainino0x kainino0x added this to the Milestone 0 milestone Jul 25, 2024
@kainino0x kainino0x added the needs-cts-issue This change requires tests (or would need tests if accepted), but may not have a CTS issue filed yet label Jul 25, 2024
@kainino0x kainino0x marked this pull request as draft July 25, 2024 01:55
Copy link
Contributor

Previews, as seen when this build job started (e3d8478):
WebGPU webgpu.idl | Explainer | Correspondence Reference
WGSL grammar.js | wgsl.lalr.txt

@kainino0x kainino0x added the potentially breaking Could require a breaking change to the API label Jul 26, 2024
@kainino0x kainino0x marked this pull request as ready for review July 27, 2024 06:45
Copy link
Member

@toji toji left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@mwyrzykowski mwyrzykowski left a comment

Choose a reason for hiding this comment

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

I have some concerns about introducing this pattern because I couldn"t find another instance in WebGPU where we have both an early reject and a device timeline validation error.

It does not seem consistent with the rest of error handling in WebGPU, unless I am missing a key point? Do we have another instance where we have both early reject and a device timeline validation error? Presumably the device validation error will occur sometime after the early reject?

If we already have this pattern then I think it should be ok, but seems odd having both the early rejection and the validation error.

@kainino0x
Copy link
Contributor Author

I have some concerns about introducing this pattern because I couldn"t find another instance in WebGPU where we have both an early reject and a device timeline validation error.

Yes, we do it for all of the device-timeline error cases of mapAsync (which is most of them):

  1. Issue the map failure steps on contentTimeline.
  2. Generate a validation error.
  3. Return.

@mwyrzykowski
Copy link

I have some concerns about introducing this pattern because I couldn"t find another instance in WebGPU where we have both an early reject and a device timeline validation error.

Yes, we do it for all of the device-timeline error cases of mapAsync (which is most of them):

  1. Issue the map failure steps on contentTimeline.
  2. Generate a validation error.
  3. Return.

None of those are early rejection cases on the content timeline that I"m aware of. I couldn"t find any early rejection cases on the content timeline which also generate a device validation error on the device timeline.

@kainino0x
Copy link
Contributor Author

kainino0x commented Aug 28, 2024

Ah, on the content timeline, no, I think this is the first where the spec actually specifies that. But since the errors are always delivered asynchronously, to an application the timeline barely matters - the only observable behavior difference is whether a .then callback resolves in a microtask off the current task, or later in a regular task. I think it"s more important to have consistent behavior across different error scenarios of mapAsync.

As for the implementation burden, there are several places where I think in practice an implementation needs to have a way to InjectError anyway, for example in writeTexture to avoid copying the entire source buffer to the GPU process (which is very important):

@mwyrzykowski
Copy link

There are also several places where I think in practice an implementation needs to have a way to InjectError anyway, for example in writeTexture to avoid copying the entire source buffer to the GPU process (which is very important):

Indeed, we can inject the error and we do this in other places (such as GPUQueue.writeBuffer/writeTexture in the above case).

My primary concern is more the uniqueness to the early rejection and combined device timeline error. But perhaps the argument is, apologies if already stated, having this early rejection + validation error is preferable over simply having an early rejection?

Initially, I was not convinced the new pattern warrants the likely zero impact breaking change. But if we think this provides greater consistency, I am happy to switch my review to an approval ✅

Copy link

@mwyrzykowski mwyrzykowski left a comment

Choose a reason for hiding this comment

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

Thinking about it more and discussion with @kainino0x I am convinced this change is better than what exists today, despite the technically breaking change as it likely impacts no one

@kainino0x
Copy link
Contributor Author

Thanks!

@kainino0x kainino0x added the api resolved Resolved - waiting for a change to the API specification label Aug 28, 2024
@kainino0x kainino0x merged commit ed7dd07 into gpuweb:main Aug 28, 2024
4 checks passed
@kainino0x kainino0x deleted the mapasync-early-reject branch August 28, 2024 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api resolved Resolved - waiting for a change to the API specification api WebGPU API needs-cts-issue This change requires tests (or would need tests if accepted), but may not have a CTS issue filed yet potentially breaking Could require a breaking change to the API proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mapAsync early-reject doesn"t generate a validation error
4 participants