Re: [ServiceWorker] requestIdleCallback (equivalent) for ServiceWorkerGlobalScope (#790)

My opinion, blending in a bit of perspective writing non-blocking servers in Node.js:

- CPU-bound work should never be done in the service worker. It is only for reacting to fetch events (or other incoming events like push). Thus you really need Worker at least. requestIdleCallback will not cut it in the general case. (I am less sure about SharedWorker.)
- In theory the rest of your work should be doable fast, without blocking fetch events. E.g. all I/O should be async and return to the event loop immediately. So the cases listed in the OP should not need requestIdleCallback. In practice maybe browsers are not as good as Node.js in this regard.
- requestIdleCallback still seems like a bad API because unlike in the foreground thread, you have no guarantee that painting will occur at least 16 ms apart. Network requests could come in every 1 ms. You just never know.

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/790#issuecomment-160680905

Received on Monday, 30 November 2015 16:33:48 UTC