Skip to content
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

Requesting wake locks from Workers #156

Closed
reillyeon opened this issue Mar 9, 2019 · 8 comments
Closed

Requesting wake locks from Workers #156

reillyeon opened this issue Mar 9, 2019 · 8 comments
Assignees

Comments

@reillyeon
Copy link
Member

For all intents and purposes a wake lock requested from a (dedicated) worker is the same as one requested by the frame that owns the worker but especially for system wake locks which are likely being held to a computation continues uninterrupted it makes sense to have that managed by the worker performing the computation.

This does raise a question for implementations on how to determine when a worker script has become unresponsive.

@kenchris
Copy link
Contributor

kenchris commented Mar 11, 2019

OK, adding this now is quite simple but we have a few things to handle later

@kenchris
Copy link
Contributor

Additional info here: w3c/sensors#388

@kenchris
Copy link
Contributor

kenchris commented Mar 18, 2019

So this should work now by using the permission spec, but should we still add a requestPermission()? and where should that then live? on the WakeLock object?

@reillyeon
Copy link
Member Author

I see no harm in adding a requestPermission() function that is a wrapper around the algorithm from the permissions spec. It should be able to take a wake lock type as a parameter so either be a static function on WakeLock with extra parameters or inherit the parameters from the WakeLock that is provided as this.

@kenchris
Copy link
Contributor

It is static on notification spec as well as on device orientation and motion - so let's go with that

How does this look?

[Exposed=Window] static Promise<PermissionState> requestPermission(WakeLockType type)

@reillyeon
Copy link
Member Author

Seems reasonable.

@mrunalk
Copy link

mrunalk commented Mar 21, 2019

Any reason why requestPermission() has to be static in Wakelock's case. in case of Notifications API may be there are many different types of notifications but for WakeLock we are dealing with only two types of wakelocks. I would prefer non-static version which inherits parameters.

@kenchris
Copy link
Contributor

@mrunalk yes

  • consistency with the web platform
  • you don't need to instantiate an object you never will use as you intent to do it on a worker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@reillyeon @kenchris @mrunalk and others