What is the issue with the HTML Standard?
Arising out of the discussion on extended-life SharedWorkers.
What should happen when a SharedWorker not longer has any active Documents?
Problems that arise in this discussion
- privacy - a ShW continuing to make network requests when there are no visible documents for the site is a privacy problem
- resources - a ShW continuing to use CPU, memory, network when there are no visible documents for the site is a privacy problem
- correctness - a page that enters BFCache and is restored should operate correctly
- ergonomics - ideally authors need not do anything to achieve correctness or if they do, it should be an existing best practice
A couple of options spring to mind.
Let them keep running
This is a privacy problem and a resource problem.
Destroy them after a short time
This removes the privacy and resource problems but
- Correctness are existing pages that use ShWs installing error handlers? If they are can they reliably tell the difference between an error that comes from the ShW failing during startup (not likely to be retryable) vs due to BFCache (should result in the ShW restarting).
- Ergonomics - we would move from a state where ShWs are expected to run reliable once they successfully start to one where they are expected to be destroyed. This means existing pages that have shared state between page and worker need to be rewritten to handle destroy/restart of the worker.
Pause and resume them
Chrome already does this with DedicatedWorkers although I don't think there is any spec. "Pause" here does not mean to pause the event loop, it means to pause the JS VM mid-task. This was necessary for DedicatedWorkers because there is no expectation of short-lived JS tasks, they are free continue without yielding.
I don't know if there is any way express this kind of pausing in the spec.
I believe this avoid all of the problems listed above.
Other options?
What do other browsers do right now for ShWs and DWs?
@domenic @annevk @smaug---- @asutherland @past @jyasskin @wanderview @domfarolino @yoshisatoyanagisawa
What is the issue with the HTML Standard?
Arising out of the discussion on extended-life SharedWorkers.
What should happen when a SharedWorker not longer has any active Documents?
Problems that arise in this discussion
A couple of options spring to mind.
Let them keep running
This is a privacy problem and a resource problem.
Destroy them after a short time
This removes the privacy and resource problems but
Pause and resume them
Chrome already does this with DedicatedWorkers although I don't think there is any spec. "Pause" here does not mean to pause the event loop, it means to pause the JS VM mid-task. This was necessary for DedicatedWorkers because there is no expectation of short-lived JS tasks, they are free continue without yielding.
I don't know if there is any way express this kind of pausing in the spec.
I believe this avoid all of the problems listed above.
Other options?
What do other browsers do right now for ShWs and DWs?
@domenic @annevk @smaug---- @asutherland @past @jyasskin @wanderview @domfarolino @yoshisatoyanagisawa