-
Notifications
You must be signed in to change notification settings - Fork 10
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
Determine the behavior when calling unobserve/disconnect method before the promise returned by observe method is settled #164
Comments
More generally speaking, |
Maybe this would work:
Biggest issue I see if the "global task" as that will run when after JS has completed, including the sync disconnect/unobserve, so it will readd to the active observer list and activate the observation, so that code would probably have to check whether it's promise has been removed from the pending observer promises list and if so, don't do any work |
Given it looks like we will remove the async permission stuff, this becomes a non-issue. But we should keep using promises in observe() so that we can add it back. |
Given the current Blink implementation, I think this will still be an issue even if the permission bits are removed, as there are async steps involved in checking if It could be possible to stop distinguishing between a successful async connection to the platform side (and maybe even drop the NotSupportedError exception related to checking for supported source types), but one would still have a window where the async connection is being established internally but disconnect/unobserve can still be called. |
For the record, at least Web Bluetooth and WebHID also need to deal with this: |
Given that we use an attribute for supported source types, we have not made that an async querying function, so we could do this check sync and it should not be an issue. If we want to make that async in the future, it does become a problem yes. |
If that is indeed async, how is the attribute implemented today then? Also the current activation was happening on the main tread (in the global task) so the promise resolve wasn't waiting on that, you just get the events when they are delivered |
We haven't really spec'ed how that happens, and in the spec that also happens in the global task (main thread) so if we want to do that, we need to find out how to make these changes |
@rakuco I did a PR to remove the permissions integration, but I can change it to keep the global task and instead do the activation in parallel. Then afterwards we could do the pendingPromises. If you think that is the way to go, tell me and I will prepare the PRs |
The Reading the spec again, it looks like Am I getting this correctly?
|
@arskama mentioned that the attribute getter returns only values supported by the spec and not necessarily the underlying hardware - I believe that is how it worked in some other specs, we can consider whether to change that or not. |
Values supported by the spec or by the implementation? If it's the former, then |
Basically what the browser supports on at least one of its platforms |
Btw looking at those WebHID pending promises, I don't ever see them remove promises as they resolve. Looks like a mistake, or am I missing something? |
https://wicg.github.io/compute-pressure/#platform-primitives The question remaining is: How do we inform the user on the case where the HW doesn't support the platform collector requests? If observe is synchronous, there is no way to do it. |
@Elchi3 I was wondering if you have any input on what supportedSources should expose. Right now it exposes the sources supported by the user agent (browser) but not necessarily supported on a platform (say Android) or by the hardware. Should we change that and make it an async getter, or add a similar method with that behavior in addition to the attribute? |
Good to know, I need to clarify this in the docs. So users will only find out if it is really supported in the current environment when calling https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver/supportedEntryTypes_static is the same thing for PerformanceObserver but I guess given the Perf APIs aren't depending on specific hardware, it is fine as a static property there.
Not sure if there is a standard way for it on the web platform but a method is used elsewhere (especially when it has to do with hardware support, see WebXR and WebGL). https://developer.mozilla.org/en-US/docs/Web/API/CSS/supports_static |
If we decide to do this, we can remove the existing API for now and if we don't make it, we can add this new method after shipping @tomayac you feedback is also welcome |
Before M125 release, I don't see it happening. So if we want to provide the platform collector source list, then it s maybe better to remove it now and add it later when we have an implementation. |
The following codes will cause the promise never resolve or reject in current implementation. It is more reasonable to reject these promises instead and the spec should give more clarity about this.
let promise = observer.observe('cpu');
observer.disconnect();
The text was updated successfully, but these errors were encountered: