Closed arskama closed 5 months ago
@rakuco any suggestion?
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 :-)
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
in its current form,
supportedSources
is a hint that basically says "this implementation supports at most these sources", but whether or not a source insupportedSources
actually works depends on callingobserve()
. I don't know if this is a useful hint or not; perhaps callingobserve()
and checking forNotSupportedError
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. Callobserve()
and check forNotSupportedError
if pressure observation is possible. (or callsupportedSources()
[if made available]).
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
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 apromise
.