WICG / page-lifecycle

Lifecycle API to support system initiated discarding and freezing
https://wicg.github.io/page-lifecycle/
Other
154 stars 12 forks source link

Add pausing execution of worklets and dedicated workers. #35

Closed dtapuska closed 5 years ago

dtapuska commented 5 years ago

The lifecycle of workers and worklets was undefined in the specification. Add some formalization around dedicated workers and worklets. Still to be determined is what happens with shared workers and service workers.

domenic commented 5 years ago

Interesting. This is very different than the requirement to stop running new tasks; this implies the current task should not continue. Is that intended? Is that the implementation strategy?

Separately, as written, this says when "a document" is frozen (any document, I guess), no worklet or dedicated worker agents should make forward progress. I think the intention was for the ones that "belong" to the document to not make forward progress, right?

There might be an easier way to do this, but off the top of my head, that would involve checking the owner set for frozen Documents, or for workers whose owner set contains frozen documents, recursively. (I feel like we should have some sort of owner document concept for workers, but at least this late in the day, I can't find it.)

dtapuska commented 5 years ago

This is precisely what Firefox does with its back/forward cache. If I have an infinitely running worker counting something it stops counting when it is put in the background and when I come back to the page it resumes where it left off.

dtapuska commented 5 years ago

I think I've more clearly specified which document and added a recursive definition of owning document.

Err; I guess it might not be clear if a worker is started in a shared worker. Ugh...