Skip to content

Commit

Permalink
Replace asynchronous .requestAdapterInfo() with synchronous .info (gp…
Browse files Browse the repository at this point in the history
…uweb#4662)

Replaces the GPUAdapter method
`Promise<GPUAdapterInfo> requestAdapterInfo();`
with a synchronous attribute
`[SameObject] readonly attribute GPUAdapterInfo info;`

Important points:

- `requestAdapterInfo()` is removed. Chromium will deprecate and remove it and attempt to get any sites migrated off of it, so hopefully Firefox/Safari won't have to implement it at all (though the implementation is trivial so they may choose to, for compatibility with outdated sites).
- The available info about a given `GPUAdapter` may no longer change. You can only get new info by getting a new `GPUAdapter`. (The only reason this should happen is if someone adds a permission prompt for fingerprintability.)

Less important points:
- You can now only get one `GPUAdapterInfo` object per `GPUAdapter` object, since `adapter.info` returns the same object every time you access it.
  • Loading branch information
kainino0x authored May 28, 2024
1 parent 6f92ce2 commit 19516f6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 27 deletions.
5 changes: 5 additions & 0 deletions design/AdapterIdentifiers.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# WebGPU Adapter Identifiers

**This document is outdated. `adapter.requestAdapterInfo()` has been replaced with
`adapter.info` and `unmaskHints` doesn't exist anymore. See:
[#4536](https://github.com/gpuweb/gpuweb/issues/4536),
[#4316](https://github.com/gpuweb/gpuweb/pull/4316).

## Introduction

The WebGL extension [WEBGL_debug_renderer_info](https://www.khronos.org/registry/webgl/extensions/WEBGL_debug_renderer_info/) reports identifying information about a device's graphics driver for the purposes of debugging or detection and avoidance of bugs or performance pitfalls on a particular driver or piece of hardware.
Expand Down
64 changes: 37 additions & 27 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,6 @@ Several operations in WebGPU return promises.

- {{GPU}}.{{GPU/requestAdapter()}}
- {{GPUAdapter}}.{{GPUAdapter/requestDevice()}}
- {{GPUAdapter}}.{{GPUAdapter/requestAdapterInfo()}}
- {{GPUDevice}}.{{GPUDevice/createComputePipelineAsync()}}
- {{GPUDevice}}.{{GPUDevice/createRenderPipelineAsync()}}
- {{GPUBuffer}}.{{GPUBuffer/mapAsync()}}
Expand Down Expand Up @@ -1699,11 +1698,26 @@ interface WGSLLanguageFeatures {

{{GPUAdapterInfo}} exposes various identifying information about an adapter.

None of the members in {{GPUAdapterInfo}} are guaranteed to be populated. It is at the user
None of the members in {{GPUAdapterInfo}} are guaranteed to be populated with any particular value;
if no value is provided, the attribute will return the empty string `""`. It is at the user
agent's discretion which values to reveal, and it is likely that on some devices none of the values
will be populated. As such, applications **must** be able to handle any possible {{GPUAdapterInfo}} values,
including the absence of those values.

The information exposed by a {{GPUAdapter}} is immutable: for a given adapter, each {{GPUAdapterInfo}}
attribute will return the same value every time it's accessed.

Note:
Though the {{GPUAdapterInfo}} attributes are immutable *once accessed*, an implementation may delay the decision on
what to expose for each attribute until the first time it is accessed.

Note:
Other {{GPUAdapter}} instances, even if they represent the same physical adapter, may expose
different values in {{GPUAdapterInfo}}.
However, they **should** expose the same values unless a specific
event has increased the amount of identifying information the page is allowed to access.
(No such events are defined by this specification.)

<p tracking-vector>
For privacy considerations, see [[#privacy-adapter-identifiers]].
</p>
Expand Down Expand Up @@ -2337,10 +2351,10 @@ To get a {{GPUAdapter}}, use {{GPU/requestAdapter()}}.
interface GPUAdapter {
[SameObject] readonly attribute GPUSupportedFeatures features;
[SameObject] readonly attribute GPUSupportedLimits limits;
[SameObject] readonly attribute GPUAdapterInfo info;
readonly attribute boolean isFallbackAdapter;

Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {});
Promise<GPUAdapterInfo> requestAdapterInfo();
};
</script>

Expand All @@ -2355,6 +2369,26 @@ interface GPUAdapter {
::
The limits in `this`.{{GPUAdapter/[[adapter]]}}.{{adapter/[[limits]]}}.

: <dfn>info</dfn>
::
Information about the physical adapter underlying this {{GPUAdapter}}.

For a given {{GPUAdapter}}, the {{GPUAdapterInfo}} values exposed are constant over time.

The same object is returned each time. To create that object for the first time:

<div algorithm=GPUAdapter.info>
<div data-timeline=content>
**Called on:** {{GPUAdapter}} |this|.

**Returns:** {{GPUAdapterInfo}}

[=Content timeline=] steps:

1. Return a [$new adapter info$] for |this|.{{GPUAdapter/[[adapter]]}}.
</div>
</div>

: <dfn>isFallbackAdapter</dfn>
::
Returns the value of {{GPUAdapter/[[adapter]]}}.{{adapter/[[fallback]]}}.
Expand Down Expand Up @@ -2476,30 +2510,6 @@ interface GPUAdapter {
|device|.{{GPUDevice/lost}} has already resolved before |promise| resolves.
</div>
</div>

: <dfn>requestAdapterInfo()</dfn>
::
Requests the {{GPUAdapterInfo}} for this {{GPUAdapter}}.

Note: Adapter info values are returned with a Promise to give user agents an
opportunity to perform potentially long-running checks in the future.

<div algorithm=GPUAdapter.requestAdapterInfo>
<div data-timeline=content>
**Called on:** {{GPUAdapter}} |this|.

**Returns:** {{Promise}}&lt;{{GPUAdapterInfo}}&gt;

[=Content timeline=] steps:

1. Let |promise| be [=a new promise=].
1. Let |adapter| be |this|.{{GPUAdapter/[[adapter]]}}.
1. Run the following steps [=in parallel=]:
1. [=Resolve=] |promise| with a [$new adapter info$] for |adapter|.

1. Return |promise|.
</div>
</div>
</dl>

<div class=example>
Expand Down

0 comments on commit 19516f6

Please sign in to comment.