w3c / compute-pressure

A web API proposal that provides information about available compute capacity
https://www.w3.org/TR/compute-pressure/
Other
69 stars 10 forks source link

Clarify what supportedSources() should expose. #266

Closed arskama closed 5 months ago

arskama commented 5 months ago

Based on discussions in https://github.com/w3c/compute-pressure/issues/164#issuecomment-2056172501, we need to clarify what to expose when calling supportedSources() and also deciding on the use of returning a promise.

arskama commented 5 months ago

@rakuco any suggestion?

rakuco commented 5 months ago

Looking at https://github.com/w3c/compute-pressure/issues/164#issuecomment-2056303587, https://developer.mozilla.org/en-US/docs/Web/API/XRSystem/isSessionSupported is the most similar to what we have here: it's asynchronous and needs to query the platform before sending a result. All the other methods are synchronous because the data they need comes from the engine itself AFAICS.

The approach we take depends on what we want to convey: in its current form, supportedSources is a hint that basically says "this implementation supports at most these sources", but whether or not a source in supportedSources actually works depends on calling observe(). I don't know if this is a useful hint or not; perhaps calling observe() and checking for NotSupportedError is enough for developers, perhaps not.

If supportedSources is supposed to really indicate which sources are supported by the platform (meaning the results could even vary across calls), then it needs to become a method like XRSystem.isSessionSupported().

With this, I throw the ball back to @kenchris and @elchi3's court :-)

kenchris commented 5 months ago

The current one is more like a knownSources - maybe that is useful and we could expose it, but then most likely it would need to be renamed

Elchi3 commented 5 months ago

in its current form, supportedSources is a hint that basically says "this implementation supports at most these sources", but whether or not a source in supportedSources actually works depends on calling observe(). I don't know if this is a useful hint or not; perhaps calling observe() and checking for NotSupportedError is enough for developers, perhaps not.

I guess the only advantage is that you would know things earlier. Are there any wins for web developers with such an early hint? If not, then I'm not sure what a hint helps with (other than being potentially misleading).

See e.g. https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createShaderModule#hints where early hints matter but see also the note box that we provided there.

I guess if we had knownSources, I would have a note box like:

[!note] Note: The knownSources property is a merely hint about the sources your browser supports. It is not guaranteed pressure observation will work on your operating system or hardware. Call observe() and check for NotSupportedError if pressure observation is possible. (or call supportedSources() [if made available]).

kenchris commented 5 months ago

Yes, I think it might make sense. You might want to lazy load e.g. UI components and eagerly do it, but you should not do that for something that will definitely never be available/work