Skip to content

Reconcile with document lifecycle #4

Open

Description

@inexorabletash

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

Activity

  1. jakearchibald commented on Oct 2, 2017

    @jakearchibald
    Contributor

    An AbortSignal could be used as a notification method here.

  2. jakearchibald commented on Oct 3, 2017

    @jakearchibald
    Contributor

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

  3. inexorabletash commented on Oct 3, 2017

    @inexorabletash
    MemberAuthor

    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.

  4. inexorabletash commented on Oct 3, 2017

    @inexorabletash
    MemberAuthor

    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.

  5. annevk commented on Nov 13, 2017

    @annevk
    Member

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

  6. inexorabletash commented on Jan 18, 2018

    @inexorabletash
    MemberAuthor

    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?

  7. inexorabletash commented on Jan 18, 2018

    @inexorabletash
    MemberAuthor

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

  8. spanicker commented on Jan 19, 2018

    @spanicker

    ... 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)

  9. inexorabletash commented on Jan 19, 2018

    @inexorabletash
    MemberAuthor

    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.

  10. spanicker commented on Jan 19, 2018

    @spanicker

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

  11. added this to the v1 milestone on Feb 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions