Repository navigation
Description
In WebGL, web developers take advantage of UNMASKED_VENDOR_WEBGL and UNMASKED_RENDERER_WEBGL to respectively get the vendor and renderer string of the graphics driver so that they can optimize GPU-driven content and debug GPU problems. See replies to Dean Jackson’s tweet.
The detail of information varies between browsers:
- Safari only returns
Apple IncandApple GPUsince February 2020. - Firefox buckets WebGL renderer strings on desktop since June 2021. See SanitizeRenderer.cpp file.
- Chrome returns full information for
UNMASKED_VENDOR_WEBGLandUNMASKED_RENDERER_WEBGL.
WebGPU
In WebGPU, the GPU vendor and product names may be available to web developers through GPUAdapter.name depending on the browser implementation. The spec currently defines it as below:
A human-readable name identifying the adapter. The contents are implementation-defined.
I believe the spec should formally define the contents of GPUAdapter.name to help web developers who need GPU hardware information.
Proposal 1
GPUAdapter.name returns a string that helps identify the vendor and the product without giving the exact name of the GPU hardware (.e.g "Nvidia Kepler"). The specification would have to create and maintain a registry of known PCI IDs that map to hardcoded strings. The degree of granularity would be defined by the spec.
const adapter = await navigator.gpu.requestAdapter();
if (adapter.name == 'Nvidia Kepler') {
// TODO: Optimize...
}We may want to have two separate fields: GPUAdapter.vendor and GPUAdapter.architecture.
Proposal 2
A new method Promise<DOMString> GPUAdapter.requestDebugInformation() indicates to the browser that the website wants full and detailed GPU hardware information.
The browser may prompt the user there since the method is asynchronous.
const adapter = await navigator.gpu.requestAdapter();
const fullDebugInfo = await adapter.requestDebugInformation();
if (fullDebugInfo == 'Nvidia GK20A') {
// TODO: Optimize...
}GPUAdapter.name is removed from the spec.
Proposal 3 (Mix of proposals 1 and 2)
A new method Promise<DOMString> GPUAdapter.requestDebugInformation() indicates to the browser that the website wants GPU hardware information. The browser returns a string that helps identify the vendor and the product without giving the exact name of the GPU hardware (.e.g “Nvidia Kepler”). The specification would have to create and maintain a registry of known PCI IDs that map to hardcoded strings. The degree of granularity would be defined by the spec.
const adapter = await navigator.gpu.requestAdapter();
const sanitizedDebugInfo = await adapter.requestDebugInformation();
if (sanitizedDebugInfo == 'Nvidia Kepler') {
// TODO: Optimize...
}We may want to return a dictionary with two separate fields: vendor and architecture.
GPUAdapter.name is removed from the spec.
Thoughts? Ideas?
⬇️ Add them below.
Activity
Kangz commentedon Nov 10, 2021
I think it's useful to split proposals for replacing
GPUAdapter.nameinto two independent parts: what's exposed, and how you get it (and can request more information than what you have).Replacing
GPUAdapter.namewith more granular data.The problem with
GPUAdapter.nameis that if it is the only information you have about the adapter, then it needs to bundle everything and applications need logic to parse its format. The format might vary between browsers, or even version of the same browser and we get in the same type of issues that the user agent string has. The WebGLUNMASKED_RENDERERstring has the same issue. Also with a bundled info like this, the browser can't track which pieces of data the application makes use of (which is important for some of the fingerprinting mitigations, for example the "privacy budget").I think it would be more useful to developers to have information pre-split into various aspects, with additional semantic that are more convenient. Note that all of the fields are optional, so a browser can choose to omit them.
partial dictionary GPUAdapterInfo { DOMString vendor; // For example "Intel" DOMString architecture; // For example "Gen 11" DOMString productName; // For example "Intel HD 630" DOMString driverVersion; };vendor,architectureandproductNameare in increasing order of precision and allow the application to only 1) get the data they need (if they care only about the vendor and not the product name) and 2) avoid having to parse strings to extract relevant data.architectureis special in that it is usually not exposed, so browsers could have tables of PCI device IDs (or not expose it if they don't know). Usually developer match against product names but what they really care about for optimizations are the architectures.driverVersionis a bit unfortunate because it might still require parsing but there isn't really a way around it, and it is pretty high entropy so I expect it wouldn't be exposed often.Obviously a browser that doesn't want to expose any info can do just that. And that behavior can be tailored on the context that requested the info: an installed PWA doesn't have the same trust as a 1x1 cross origin iframe.
How information is exposed.
There's a lot of choice in how the information is exposed, and how it can be upgrade. Examples of alternatives (not necessarily exclusive) are:
GPUAdapterincludesGPUAdapterInfoinline or as a member.GPUAdapterInfois returned by an async method onGPUAdapter(so that there can be a prompt or something else)GPUAdapterto be updated with more precise data.GPUAdapterOptionsallows asking aGPUAdapterwith more info directly.NavigatorUAData.getHighEntropyValueswhere the application must list the additional info it wants in a call to an async method.1 + 3 looks nice at a first glance but I didn't really give it much thought. What do you all think?
krogovin commentedon Nov 10, 2021
There are actually two vendors very often:
There is a world of difference between NVIDIA closed source drivers and Nouveau's open source drivers. Ditto on Intel, there are big differences across the 3 drivers: MacOS, MS-Windows and Linux.
It might be useful to have that driver "vendor" either part of driverVersion or as a separate string.
On a related note, what Firefox is doing to GPU name is awful in my opinion. It is a bizarre halfway mark.
For the privacy conscious, maybe also have a standard option/method where browsers can have a setting to keep the GPU info private and report the same thing across browsers. Although, not exactly WebGPU, it might be ideal to have a standard interface where a web-page can inform a user that the GPU info is masked and ask for permission to get the unmasked values.
gyagp commentedon Nov 10, 2021
For a specific GPU, the efficient way to define it is (vendor_id + device_id). Even for the same architecture and productName, there might be many variants and we may need to differentiate them to work around some issues. For example, we ever met an NV12 hardware overlay issue on 25 variants of Gen9 GPUs (Kaby Lake and Coffee Lake), and we need to work around part of them.
For Intel platforms, Mesa code (https://gitlab.freedesktop.org/mesa/mesa/-/blob/master/include/pci_ids/i965_pci_ids.h) can give a rough idea how to map among them.
krogovin commentedon Nov 11, 2021
vendor_id is not that bad of an idea to identify the vendor, though if the vendor ID is taken from the driver then it identifies it uniquely enough. However, the problem with using the device_id of a GPU is that quite often a number of a new SKU variant is nearly the same as another one released a while back. In that case the device ID won't be recognized but a string description would be.
Perhaps in addition to the string, also the ID's? That would be ideal I think.
Kangz commentedon Nov 15, 2021
This is mostly doable by looking at the platform in the user agent string. It doesn't give the difference between Nvidia / nouveau or amdvlk / radv on Linux but these are kinda niche differences.
Yeah that's some of the proposals above that involve promises to get more details: promises allow the browser to show a permission prompt to the user, if they want to do so.
Ah, that's a bit unfortunate that productName isn't one-to-one with device ids. Maybe we can have both and the browser chooses what to expose.
One thing with the proposals above is that even if the spec allows exposing a lot of different information, browser can choose to expose only a subset or nothing, so applications will have to be able to deal with that anyway.
krogovin commentedon Nov 15, 2021
If one views Linux desktop as niche (and it is perfectly reasonable to do so), then the difference is niche. However, given that native can know, it would be nice for web apps to know.
I think the rule of thumb would end up being this: if the GPU info is masked (or partially masked), then the user implicitly accepts that a GPU app is more likely to perform more slowly or not even work.
kvark commentedon Nov 17, 2021
The proposal (Proposal-4?) to expose data more granularly looks like the right way to go. It makes the developer lives easier (less parsing), and an implementation has a clear choice on where to draw the privacy line. As for "driverVersion", maybe we shouldn't have it entirely - it's too much of a fingerprinting factor anyway to sanely expose on the Web.
krogovin commentedon Dec 8, 2021
Seconding @kvark, I very much having a struct with a bunch of fields. It also, with some work admittedly, pretty easy to go from VkPhysicalDeviceProperties to those fields. Those fields suggested will handle most (but maybe not all) cases to identify a GPU and driver for the purpose of tuning and work-arounds.
toji commentedon Dec 13, 2021
I've got a proposal that tries to capture a lot of the discussion around GPU identifiers. I'll add it to this thread, but first I want to try to sum up what I understand the goals and reasoning behind such a feature to be. The actual proposal will be a separate comment for easier reference/reading.
Goals:
Native equivalents:
The following structures are what expose similar information in the various native libraries, though they obviously don't have the same privacy considerations. Included here as reference.
Prior art on the Web Platform:
User-Agent client hints, and especially NavigatorUAData.getHighEntropyValues(), have been introduced previously as a more privacy preserving and developer friendly alternative to UA string parsing.
Ideally supported scenarios:
Bug workarounds
A WebGPU developer wants to ensure that their content works on all devices, but is aware of a bug on a specific family of GPUs that causes corrupted rendering. Using
GPUAdapterPropertiesthey can identify when users are using GPUs that fall into that bucket and switch to a slower code path that doesn't provoke the issue.Filing issue reports
A WebGPU developer has included a "Report an issue" button on their page. Normally they have found that they need very little adapter information to operate, but when users experience a problem they want to gather as much data as they can about the problem. On the report filing page they include UI to allow the user to include their GPU information in the report, which when checked causes the browser to confirm that they want to let the page know their full adapter details.
Performance optimization
A WebGPU developer wants all users to experience good performance on their page, but has developed some effects that are not practical on mobile GPUs. They can check
GPUAdapterPropertieson page load to get a broad idea of what family of GPU the user has to start them off with a reasonable set of defaults. On a settings page, however, they can include a button which detects the best settings for their device. Clicking it may prompt the user for consent to see more detailed GPU information so that ideal settings for their device can be selected.WebGPU developer community assets
A common and useful asset for developers is sites such as https://gpuinfo.org/, which visualize your current devices capabilities in an easy to read format and (with users consent) can collect information about GPU capabilities to report in aggregate to other developers, giving them a sense of how widespread various capabilities are. Offering a way for users to opt-in to contributing to such a database is desirable.
Real-world use cases:
These are some known use cases for GPU identifiers that we have heard of in the past. These refer to WebGL applications specifically, but we have every reason to expect that they will be applicable to WebGPU as well.
Tweets replying to Dean Jackson's inquiry about removing WEBGL_debug_renderer_info:
Feedback communicated to the Khronos Group (2019):
Ken Russell (@kenrussell) collected quotes from various WebGL developers and reported them to the WebGL Working Group in 2019. Some of those same points have also been communicated in the GPUAdaper.name considered harmful issue. I'm repeating them here for easy reference.
The following are some quoted reasons why various pages use WEBGL_debug_renderer_info:
Unity
or "HD" rendering
Uber
Sketchfab
Scirra
Figma
noclip.website
toji commentedon Dec 13, 2021
Now for the actual proposal:
Speculative IDL:
Usage
The primary thing that this API pattern establishes is a divide between "Information the UA is comfortable exposing without a prompt" and "Information the UA requires explicit consent for."
Calling
requestAdapterInfo()with an info level of"default"(the default, conveniently enough) will return aGPUAdapterInfowith any fields that the UA is comfortable populating without user consent, including possibly none at all. I would advocate for always having at leastvendorreturn a string, even if the string is a generic"unknown"value. Certain high entropy values, such as a full unmasked name or driver version, should never be exposed to the"default"request unless the user has previously given explicit consent to report them (like during a prior call with the info level set to"detailed").We should strongly encourage the
"default"info level returning nothing (or reduced/masked values) to be normalized for all browsers in some circumstances. An example would be browsing modes that give a greater expectation of privacy like Chrome's Incognito mode, but more especially in "enhanced privacy" modes like Edge's strict tracking prevention or Firefox's Enhanced Tracking Protection. Doing so provides a better compatibility story for browsers that wish to expose very little information by default, because developers need to plan for encountering cases where no adapter information is available more frequently.In the case that the developer needs more information than what the
"default"info level provides, they can callrequestAdapterInfo()with an info level of"detailed"to request more detailed information. The UA should obtain user consent, such as with a prompt, before exposing any information that it would not have otherwise reported at the"default"info level, though once consent has been given future requests from the same origin for"detailed"adapter info could be returned immediately.The
"detailed"info level is still allowed to omit any values the UA desires, including in the most extreme cases omitting everything. But given that the user has consented to reporting some information developers would likely view it as a bug if nothing was reported. The"detailed"info level may also replace masked values reported at the"default"info level with unmasked values.Value formatting
In order to make developers' lives easier and cut down on variations across devices/browsers I would highly recommend that the values that we return (except perhaps the full name?) be strictly formatted and ideally be listed in a registry so that other browser vendors and developers can all be on the same page about what values are returned. WebXR employed this pattern to good results when reporting the type of controller being used.
I would recommend something like: All vendor, architecture, and device strings must be limited to only lowercase letters, numbers, and (if word breaks are absolutely necessary) hyphens (“-”). The full name, if exposed, could be the name string directly from the native API.
It should be noted that "device" is a tricky one. The native APIs identify devices via an UINT ID, and new devices are released all the time so any approach that requires the browser to map IDs to the numbers is going to be difficult to maintain and lag behind product releases. (By contrast, there are few enough vendors that we can easily maintain that mapping.) As such we may want to consider just exposing the device ID (nullable), and reserve the human-readable name for the fullName string.
Regardless of how we approach the device identifier, you’d end up with results like this (with the understanding, of course, that the full names and possibly device would only be exposed with user consent):
Iframe controls
We should be using Permissions Policy to control whether or not certain WebGPU features are exposed to iframes. We could apply this at any level of the API we wanted, such as specifically blocking adapter info from being reported, but I would advocate for using it to enable/disable the WebGPU API entirely.
The recommended feature identifier would be
"webgpu", and the default allowlist for this feature would be["self"]. (Which lets documents from the top level browsing context use the feature by default.)(Whether or not we have a permissions policy to enable/disable WebGPU use, we could also discuss a secondary permissions policy like
"webgpu-adapter-info"that would block just this specific feature of the API.)This may feel extreme, but ultimately it feels like a good way to strike a balance between enabling powerful rendering and computation capabilities on the web and a desire to mitigate abuse by bad actors. In practice it would be invoked like this:
Embeds for pages like Sketchfab could include it as part of the code snippets they ask developers to copy/paste, so it would not block those kinds of desirable usages. It would likely raise eyebrows if something such as a social media "like" button were to require the same permission, though. As a result it helps mitigate the most grievous cases of tracking pixels or similar embedded documents getting full GPU access. (It is worth noting that no such mechanism exists for WebGL, but preventing abuse of compute shaders is likely worth the additional effort here.)
beaufortfrancois commentedon Dec 14, 2021
Thank you @toji for this proposal!
If that I understand correctly, depending on the
GPUAdapterInfoLevelvalue,requestAdapterInfo()could be called any time, or would require a user interaction first. I think* it would be better if the user activation would not depend on this value. What do you think?krogovin commentedon Dec 14, 2021
I like this proposal except the fullName part which means using it means sort-of-parsing it; I much rather that a browser does that. In addition, I am hopeful that browsers use the same code to deliver the information; i.e. if two different browsers running on the same machine are both configured to give the full GPU info, then they should give the exact same strings.
gyagp commentedon Dec 14, 2021
It should be very hard to define (format) architecture, device, fullName and sync them among different browsers in practice. Here are lists of GPUs from Intel (https://en.wikipedia.org/wiki/List_of_Intel_graphics_processing_units), NVIDIA (https://en.wikipedia.org/wiki/List_of_Nvidia_graphics_processing_units) and AMD (https://en.wikipedia.org/wiki/List_of_AMD_graphics_processing_units), and we have so many other GPU vendors. It may require huge continuous effort to maintain them in browsers.
How about driver version? It's also very important for issue reporting and submission.
toji commentedon Dec 14, 2021
Yeah, I agree. Thanks for pointing that out! There is a minor API ergonomics issue that comes up with that, in that I'm not sure if there's precedent elsewhere on the web platform for a function that requires user activation with some inputs, but doesn't require it with others. Worth looking into.
Agreed, and that's probably the part of this proposal that I'm least sure about. Although at least in the case of fullName I'd advocate for that being the raw string from the native API with no formatting. If we include it at all, because...
If we do include fullName or anything like it, the purpose would primarily be for human readable display/debugging. Like, "we logged this with your bug report as a hint to our developers." My hope would be that any runtime usage, such as activating workarounds, would have sufficient information from the other fields.
This is a point of contention at the moment, and several people have advocated against including it because it's assumed that WebGL never exposed it. I can see something that looks like a driver version in my WebGL unmasked strings, though, so I'm not so sure about that. In any case, if we included a version it would definitely only be included in the higher entropy tier so I don't see it as a big problem.
kainino0x commentedon Dec 15, 2021
I'd like to do this as a "best effort" - obviously we can't cover every device, but I do think we can cover a majority of devices so that it's useful to developers. E.g. for Intel "gen8", "gen9", etc. For NVIDIA "pascal", "turing", etc. The registry wouldn't strictly define which bucket every single device goes into, just what the buckets are labeled.
It's still going to be hard to maintain but it seems maybe tractable.
Agree, this would be from the driver and not from the registry.
toji commentedon Jan 24, 2022
As requested during the last call, I've put together an explainer capturing my proposal from this issue and put it up as a HackMD document for easy collaboration here: https://hackmd.io/@Toji/S1rvjZD6t
As we discussed, the goal should be to use this document to work out any broad issues with the proposal as a group (For example, I expect the exact structure of the interface we return will undergo some changes vs. what I've put there initially.) Then, once any large concerns have been addressed we'll loop in the PING and work out the remaining details with their input.
toji commentedon Jan 26, 2022
At @litherum's request in today's call, the above document has been mirror into this repo at https://github.com/gpuweb/gpuweb/blob/main/design/AdapterIdentifiers.md to facilitate pull requests.
toji commentedon Mar 9, 2022
Following today's call #2635 was merged into the Adapter Identifiers design doc. There were some outstanding questions that came up during the meeting, such as:
These are great questions, and it's probably going to be most effective to resolve them in the context of actual algorithms, so the plan at this point is to begin working on a spec PR adding
GPUAdapterInfoand the related APIs and continue the discussion in that PR.Worth noting that integration with Permissions Policy as outlined by the doc is still not agreed upon, so that aspect will not be acted on at this time while further investigation is done.
Kangz commentedon Apr 26, 2022
Tentatively closing since the explainer landed and the group agreed that it is a possible direction forward. Works is now happening in iteration of the GPUAdapter identifiers PR.