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

Synchronously query GPUAdapterInfo #4536

Closed
kainino0x opened this issue Mar 25, 2024 · 3 comments · Fixed by #4662
Closed

Synchronously query GPUAdapterInfo #4536

kainino0x opened this issue Mar 25, 2024 · 3 comments · Fixed by #4662
Labels
api WebGPU API
Milestone

Comments

@kainino0x
Copy link
Contributor

Right now it is only possible to get GPUAdapterInfo by calling requestAdapterInfo, which is async.
However, in #4316 we removed the possibility that it would trigger a permission prompt, and I think we should consider it a breaking change to add a prompt - that is, we shouldn't do it (see #3962).

Because of this I don't think there is any reason that requestAdapterInfo as it exists today should be async:

  • It's easy to prefetch this info along with the adapter - no reason for a round trip.
    • Unless browsers need to keep fingerprintable (but not otherwise secure or private) data out of the content process?
  • Any dynamic measurement or modulation of the adapter info, done by the browser, does not need to be async: GPUAdapterInfo has 4 separate getters that can do that stuff. (In fact, this is already necessary: browsers shouldn't assume that just calling requestAdapterInfo gives the page everything in the GPUAdapterInfo struct. They don't get it until they access the properties.)
  • If we make requestAdapterInfo actually do anything extra (like via a flag that says "please give me everything you're willing to give me with a permission prompt"), the synchronously accessed GPUAdapterInfo can dynamically update to provide that data.

Strawperson proposal:

  • Add a [SameObject] readonly attribute GPUAdapterInfo info; to GPUAdapter.
  • It returns the same JS object every time you access it.
  • requestAdapterInfo still returns a new one each time for minor backward-compatibility reasons (unless we think it's better to change this and return the same one as adapter.info).
  • If the info available to the page changes, the attributes on the GPUAdapterInfo object start returning different values (like an empty string gets changed to a non-empty string).
@kainino0x
Copy link
Contributor Author

^ FWIW the thing that prompted looking at this was designing the C API for RequestAdapterInfo. In the C API we may make it synchronous even if it remains async in the JS API - unless we come up with a reason in this issue that it would be bad for Wasm bindings to call requestAdapterInfo ahead-of-time during C's RequestAdapter.

@Kangz
Copy link
Contributor

Kangz commented Apr 9, 2024

GPU Web WG 2024-03-27
  • KN: came up because we were talking about the C API. Handy - not fundamental to that though. Where we landed with requestAdapterInfo - no reason for it to be async. Just happened because of how we got there.
  • KG: I do agree with that. Not that bad to make your own async function with requestAdapterInfo - no hard requirement to make it sync.
  • KN I'd still prefer to clean this up in the JS API. If we agree on that I'll probably change the C API to make this synchronous.
  • KG: only reason we might not want to do that - think by the time you request an adapter. you get it from a list that already has this info.
  • KN: this is once you have the adapter though.
  • KG: think this is fine. Deprecate requestAdapterInfo?
  • KN: yes - maybe use it later for something that will pop up a permission prompt.
  • MW: I'm fine with this proposal.
  • KG: let's put up a PR.
  • KN: milestone 1?
  • KG: yes.

@kainino0x
Copy link
Contributor Author

kainino0x commented May 28, 2024

More meeting notes posted in #4550 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api WebGPU API
Projects
None yet
2 participants