Skip to content

[web] Implement AppLifecycleState.detached properly #150636

@mdebbar

Description

@mdebbar

The way we implement it today is we listen to beforeunload events and set the state to detached. This is wrong for 2 reasons:

  1. The beforeunload event is cancelable, meaning it's possible for the page to continue to exist after this event fires (e.g. click on a link that downloads a file - issue).
  2. The detached state is about the app/engine having no views, and not about the page being unloaded.

To implement this properly, we need to watch the number of views registered in the engine. Once that number drops to zero, we switch to the detached state (and switch back to resumed when a view is registered).

cc @gspencergoog @ditman

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: multi windowIssues related to multi window supportengineflutter/engine related. See also e: labels.platform-webWeb applications specificallyteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions