We would like to propose A Lifecycle For Web Apps to support system initiated termination and CPU suspension.
With large numbers of web apps (and tabs) running, critical resources such as memory, CPU, battery, network etc easily get oversubscribed, leading to a bad end user experience. Application lifecycle is a key way that modern OS’ manage resources. On Android, iOS and also more recent Windows versions, apps can be started and stopped at will by the platform. This lets the platform streamline and re-allocate resources where they best benefit the user.
To fill this gap in the web platform, it is important to create the right incentive structure for web developers, and allow the system to proactively reallocate resources and avoid getting into extreme resource situations. For a platform to support application lifecycle, it needs to:
- provide developers with signals about transitions between the lifecycle states
- provide lifecycle-compatible APIs that allow key capabilities to work even when the app is backgrounded or stopped.
This proposal defines what the lifecycle of a web page is and adds necessary extensions to enable supporting two important system interventions necessary for resource re-allocation:
- Tab discarding for memory saving
- CPU stopping for battery saving
Please take a look at the explainer above for problem statement, proposal, usage and more details. Feedback welcome!
\cc @surma @igrigorik @ojanvafai @toddreifsteck @Jake_Archibald @RickByers @tabatkins