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

Reconcile with document lifecycle #4

Open
inexorabletash opened this issue Sep 15, 2017 · 10 comments
Open

Reconcile with document lifecycle #4

inexorabletash opened this issue Sep 15, 2017 · 10 comments
Milestone

Comments

@inexorabletash
Copy link
Member

Some browser implementations may want to put browsing contexts "to sleep" without terminating them. Do these retain the flag, or lose it? Is there a signal for "you thought you were holding the flag but nope" ?

See https://github.com/spanicker/web-lifecycle

@jakearchibald
Copy link
Contributor

An AbortSignal could be used as a notification method here.

@jakearchibald
Copy link
Contributor

Alternatively, if a flag is requested that's owned by a CPU-suspended tab, we could just discard the suspended tab.

@inexorabletash
Copy link
Member Author

SGTM.

I'd even go for the harsher stance of: if you're holding a resource you don't even get suspended, you just get discarded. If you are holding resources and don't want to get discarded, well then you'd better release the resources during the event.

@inexorabletash
Copy link
Member Author

From offline discussion:

Some use cases (e.g. document editors), the intent would be that the lock is held for (almost) the lifetime of the tab, and re-acquiring (and initializing state) is comparable to reloading. So a vote for allowing suspended tabs to hold locks.

@annevk
Copy link
Member

annevk commented Nov 13, 2017

Note that for SharedArrayBuffer we don't do anything special for these kind of documents: whatwg/html#2581.

@inexorabletash
Copy link
Member Author

inexorabletash commented Jan 18, 2018

cc: @spanicker

Consensus seems to be emerging in discussions that suspended tabs retain hold of the locks, presuming that the tab is given notification that it is about to be suspended.

Locks should never be stolen/broken by the user agent when a tab is suspended. Any logic like "if tab is holding exclusive access to a resource, do not suspend that tab but discard it instead" would be up to the user agent (since suspend vs. discard is a UA-specific heuristic anyway).

Seem reasonable?

@inexorabletash
Copy link
Member Author

Also, re: the "...presuming that the tab is given notification..." bit - do we need to transitively guarantee that for workers/iframes? Presumably yes...

@spanicker
Copy link

spanicker commented Jan 19, 2018

... suspended tabs retain hold of the locks, presuming that the tab is given notification that it is about to be suspended.

Yes the tab is notified of suspension via the "onfreeze" callback. However if they can retain holding the lock then why does it matter that there is a callback?
(sorry I'm confused)

@inexorabletash
Copy link
Member Author

why does it matter that there is a callback?

It's not necessary for the API to be consistent, but for a web app it allows a tab to relinquish the lock, e.g. so some other tab could be elected. For example, one tab is holding the "I get to sync app state to the network" lock, other tabs just delegate to it. If that tab gets "onfreeze" it can drop the lock so another tab can pick it up and network syncing continues. If we didn't have such an event then syncing would freeze. (And just "breaking" the lock would be bad because another tab would be elected, but when unfrozen both tabs would believe they can sync.)

In other use cases, just holding the lock even while frozen is the right thing.

@spanicker
Copy link

Thanks for the context, that makes sense!
onfreeze is guaranteed before suspension (and we also want to fire it before throttling interventions)

@inexorabletash inexorabletash added this to the v1 milestone Feb 7, 2018
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