4/28/2025, copying Lifecycle 2.0 agreed within Firebolt working group from restricted "Simplified Lifecycle2.0" page from "Preferred Program" space to public regular "RDK" space so everyone can read it and can be referred to in App Lifecycle Presentation in Tech Summit 2025 session.

1. Functional Requirements

1.1. State diagram

1.2. State & transition requirements

# Description
0

GIVEN a Firebolt app is being loaded

WHEN the container is created

THEN

  • Platform MUST set Environment on container, e.g. endpoint URL
  • Platform MUST have a meaningful value for Discovery.getNavigationIntent()
  • App MUST create WebSocket to Firebolt
  • App MAY call Discovery.getNavigationIntent() at any time
  • App MUST call Lifecycle.listen() separately for each event of interest.
  • App MUST call Lifecycle.ready()
1

GIVEN  the platform launched the app with a non- PreloadIntent

  OR the app does not have permission to be loaded directly to Suspended

WHEN the app calls Lifecycle.ready()

THEN

  • App MUST be moved into the Paused state
  • App MUST be notified via the onStart method
  • App SHOULD set up the Rialto client
  • App SHOULD set up W-EGL surface
2

GIVEN an app is in the Paused state

THEN

  • App SHOULD set up minimal graphics for a "good" user experience based on latest Intent
  • App MAY prepare animation resources for UX
  • App MUST hold off on playing animations to conserve CPU
2, 4, 7

GIVEN an app is in the Paused, Active, or Suspended state

WHEN a Discovery.onNavigateTo notification occurs

THEN

  • App SHOULD immediately begin to fetch and compose the appropriate UX
  • App UX SHOULD be the one indicated by the Intent from the notification
  • App MUST present a "good" user experience while the above steps are completed

See Intents, below

3a

GIVEN an app is in the Active state

THEN

  • Platform MUST notify the app
  • App MUST now be visible
3b

GIVEN an app is in the Active state

WHEN the onActivate notification is called

THEN

  • App MAY begin any animations
  • App MAY call Discovery.getNavigationIntent() to check the latest intent
  • App MAY begin to fetch and compose the appropriate UX
  • App UX MUST be the one indicated by the most recent Intent from the notification
  • App MUST present a "good" user experience while the above steps are completed
5a

GIVEN an app is Active

WHEN it is moved to Paused

THEN

  • App MUST now be invisible
  • App MUST be notified with onPaused
5b

GIVEN an App moves from Active to Paused

WHEN the onPause notification is called

THEN

  • App MUST stop all animations
  • App MUST maintain it's most recent UX state and surface
6a

GIVEN an app is Paused

WHEN it moves to Suspended

THEN

  • Platform SHOULD reduce CPU cycles given to the app
  • Platform SHOULD reduce platform resources given to the app's graphics surface, e.g. destroy or set it 1x1 (5)
  • Platform MAY reduce Network bandwidth available to the app
  • Platform MUST notify the app with onSuspended
6b

GIVEN an app is Suspended

WHEN the onSuspended notification occurs

THEN

  • App MUST deallocate it's EGL surface
  • App MUST deallocate GPU textures and other GPU memory
  • App MUST deallocate any other memory not necessary for a hot launch
8a

GIVEN an app is Suspended

WHEN the app is being moved to Hibernated

THEN

  • App is technically still Suspended, since Hibernation removes CPU
  • Platform MUST notify the app via the onHibernate notification
  • App MUST do any synchronous operations it may require to ensure smooth hibernation & restoring, e.g. check system clock
8b

GIVEN an app is Suspended

WHEN the app is done executing onHibernate

THEN

  • Platform MUST execute the MemCR hibernate procedure and copy app to storage
  • Platform MUST destroy app container
8c

GIVEN an app is Hibernated

WHEN the app is being moved to Suspended

THEN

  • Platform MUST restore the app container
  • Platform MUST reverse the MemCR restore procedure and copy app back to memory
  • App MUST be notified and do any operations it may require to ensure smooth restoration, e.g. reaquire app-specific tokens
9a

GIVEN an app is Suspended

WHEN the app is being moved to Paused

THEN

  • Platform MUST resize the app's graphics surface to full size
  • Platform MUST restore normal CPU to the app process
  • Platform MUST restore normal network bandwidth to the app process
  • Platform MUST notify the app with onResume
9b

GIVEN an app is Paused

WHEN the onResume notification is called

THEN

  • App SHOULD reallocate it's EGL surface
  • App SHOULD reallocate GPU textures and other GPU memory
  • App SHOULD reallocate any other memory not necessary for a hot launch
10

GIVEN an app has permission to be loaded directly to Suspended

  AND the platform launched the app with a PreloadIntent

WHEN the app calls Lifecycle.ready()

THEN

  • App MUST be moved into the Suspended state
  • App MUST be notified via the onStartSuspend method
  • App MUST NOT create a graphics surface or allocate
11

GIVEN an app is in Paused, Active, or Suspended state

WHEN the app is being terminated

  AND a graceful shutdown is possible*

THEN

  • Platform MUST notify the app of destruction via Lifecycle.onDestroy() 
  • Platform MUST pass a string  parameter with the reason for shutting down the app
  • Platform MUST limit reason values to:
    • TBD, MUST solve Netflix and other partners use cases
  • Platform MUST give app enough time for execution of synchronous tasks
  • Platform MUST account for the fact that there may be more than one layer of RPC, e.g. WPE → JavaScript so slightly more time may be needed


Determination out of scope for this document, but effort should be made to have this requirement fulfilled as often as possible

12

GIVEN an app is built for W3C / HTML 

WHEN the app access the Firebolt 2.x SDK

THEN the SDK client library MUST NOT have the Lifecycle module

AND the WPE browser MUST map the Firebolt Lifecycle to the W3C Page Lifecycle*

AND the WPE browser MUST handle Firebolt requirements for video, textures, graphics, etc.*


Details of the mapping requires review with architecture & engineering, see  W3C Page Lifecycle below for draft requirements.

1.3. Intents

Non-comprehensive list of intents that are used in concert with Lifecycle to manage the deep-linking and quick switching.

Intent Schema Acceptance criteria
LaunchIntent
{
  "action": "launch"
}

 

WHEN processing a LaunchIntent

THEN the app SHOULD keep the previous UX visible so the user may return to it


WHEN transitioning to Active

  AND the current intent is a LaunchIntent

THEN the platform SHOULD unpause any video tags previous paused by the platform in the most recent Lifecycle.onPause transition

PreloadIntent
{
  "action": "preload"
}

 

WHEN transitioning to Paused

  AND processing a PreloadIntent

THEN the app SHOULD load / use as little resources at possible

AND the platform MUST send the app a new, more specific intent before any transition to Active occurs

HomeIntent
{
  "action": "home"
}

 

WHEN processing a HomeIntent

THEN the app SHOULD load it's home experience

1.4. Container mapping (tentative)

This is tentative, requires review with engineering, but having it creates a level of confidence in our model.

API Type:

method = App → Platform
notification = platform → app

Firebolt / Wayland API API Type W3C Firebolt 1.x Netflix Cobalt Prime
Lifecycle.ready() method

NA

Lifecycle.ready()

Lifecycle.ready()

Lifecycle.ready()

Lifecycle.ready()

Discovery.getNavigationIntent() method

Discovery.getNavigationIntent()

Discovery.getNavigationIntent()

Discovery.getNavigationIntent()

Discovery.getNavigationIntent()

Discovery.getNavigationIntent()

Lifecycle.close(reason) method

Window.close





Lifecycle.onStart() notification

Window.load

Lifecycle.onInactive (previous: initializing)

boot to Background w/ graphics=true

SbSystemRequestConceal

AV_DISPLAY_REQUEST_ENTER_BACKGROUND_VISIBLE

Lifecycle.onStartSuspend notification

NA

NA

boot to Background w/ graphics=false



Lifecycle.onActivate() notification Document.visibilityChanged = 'visible'

Document.visibilityState = 'visible'

All video tags unpaused (if paused by WPE via onPause)

Lifecycle.onForeground (previous: Inactive)

warm launch to Foreground w/ focus = true

SbSystemRequestFocus

AV_DISPLAY_REQUEST_ENTER_FOREGROUND

Lifecycle.onPause() notification

Document.visibilityChanged = 'hidden'

Document.visibilityState = 'hidden'

All video tags paused by WPE

Lifecycle.onInactive (previous: Foreground)

focus lost to Foreground w/ focus = false

Can we pause video in Netflix here?

SbSystemRequestBlur

AV_DISPLAY_REQUEST_ENTER_BACKGROUND_VISIBLE

Discovery.onNavigateTo(PreloadIntent)

...while Paused

notification

 Discovery.onNavigateTo(intent)

NA

move to/stay in Background w/ graphics = true

Cancel any content loaded



Discovery.onNavigateTo(Normal Intent)

notification

 Discovery.onNavigateTo(intent) 

Discovery.onNavigateTo(intent)

Load new content, stay in Background w/ graphics = true

Can Netflix load new content w/out being warmed launched?



Lifecycle.onSuspend() notification

Document.freeze()

All canvas tags have their context deallocated by WPE

Lifecycle.onSuspended (previous: Inactive)

stay in Background w/ graphics = false (possible?)

SbSystemRequestFreeze

AV_DISPLAY_REQUEST_ENTER_BACKGROUND
Lifecycle.onResume() notification

Document.resume()

All canvas tags have their context recreated

All canvas tags have the W3C onContextLost event is fired

Lifecycle.onInactive (previous: Suspended)

stay in Background w/ graphics = true (possible?) SbSystemRequestConceal AV_DISPLAY_REQUEST_ENTER_BACKGROUND_VISIBLE
Lifecycle.onHibernate() notification NA NA


Lifecycle.onRestore() notification NA NA


wl_keyboard::enter notification Window.focus() Lifecycle.onForeground (previous: Background)


wl_keyboard::leave notification Window.blur() Lifecycle.onBackground (previous: Foreground)


1.5. W3C Page Lifecycle

This is tentative, requires review with engineering, but having it creates a level of confidence in our model.

Sample W3C app:

import { Discovery } from '@firebolt-js/sdk'

document.addEventListener("visibilityChange" (event) => {
  var deeplink = await Discovery.getNavigationIntent()

  if (deeplink.action === 'preload') {
    // reset UI and load a low resource, "good" experience, e.g. a splash screen
    clearUX()
    showSplash()
  }
  else if (deeplink.action === 'entity') {
    loadDetailsPage(deeplink.data.entityId)
  }
  else if (deeplink.action === 'playback') {
    loadPlayer(deeplink.data.entityId)
  }
    
  // check if visible or hidden
  if (document.visibilityState === 'visible') {
    // App moved to Active
    turnOnAnimations()
  }
  else {
    turnOffAnimations()
    showSplash()
  }
}) 

document.addEventListener("resume", () => {
  showSplash()
  reauthenticateWithBackoffice()
})

All method calls are to app-written functionality's except for Discovery.getNavigationIntent()

1.6. Open questions

List of open items

Use Case Possible design(s) Agreement
As an app developer I want to know why my app is being suspended
  • add reason parameter to onSuspend

This is actually onDestroy, not onSuspend

  • Need an enum passed to onDestroy
  • Values TB

TODO: Document enum, add param to onDestroy

2. Non-functional Requirements

These use cases do not affect the Function Requirements, but need to be solved as part of non-function requirements by architecture & engineering.

2.1. Open questions

Use Case Possible design(s) Agreement

As an app platform I want to know which apps can be preloaded to suspended

False alarm: Jeremy misunderstood bart.

  • widget config

Out of scope

  • Need app lifecycle capabilities in shared widget format
  • until we have shared widget, each distributor solves

TODO: document capabilities in spec, no APIs

When does the platform know a direct-to-supend has reached, e.g. how long?

This requires an architectural conversation, and we'll need to document the expectations, but it doesn't require any additional APIs.

TODO: define platform requirements, document.

As an app developer I want to know how long I have to suspend
  • Distributor to outline in app requirements during onboarding
  • Platform to provide app configuration value
  • Platform to add parameter to onSuspend

This requires an architectural conversation, and we'll need to document the expectations, but it doesn't require any additional APIs.

TODO: define platform requirements, document.

As an app developer I want to know how long I have to destroy
  • Distributor to outline in app requirements during onboarding
  • Platform to provide app configuration value
  • Platform to add parameter to onSuspend
  • document for developers

This requires an architectural conversation, and we'll need to document the expectations, but it doesn't require any additional APIs.

TODO: define non-functional platform requirements

As a platform I want a deterministic way to know when to activate an app
  • detect first frame
  • inspect dom?

TODO: define non-functional platform requirements

Next step: NFR PoC & documentation w/ engineering

3. States and explanation

from Bart C after finalization discussion, 6 March 25 Update


3.1. 1 AppContainer/process start & setting Navigation Intent

Various uses case can lead to start or preload an applications. Typically the user will request to start specific App in the IUI (Main UI) with the intent to bring it to the screen. 
The IUI will call upon the platform ALM (ALM stands here for ApplicationLifecycleManager) to start specific app_id and optionally also specify via NavigationIntent structure what specific view of the app should be opened. 
Technically the ALM will do many things when creating app. Won't describe here everything it does, only parts relevant to this lifecycle. ALM will create session_id/token required for secure communication between App and Firebolt Server. ALM will set the NavigationIntent value it got from IUI on the NavigationIntent singleton associated with that Application_id on the Firebolt Server. 
The ALM will check what apptype, prepare and initiate start of associated AppContainer,  optionaly set StartTargetState ENV var on AppContainer (that defines target bootflow at moment of containerstart) and and then App process execution within the Container will start. TBD if TBD in actualy native App implementation if bringing StartTargetState ENV variable brings in significant improvement in launch time 

The App can/must assume that it is in "INITIALIZING" state from its process start. No specific Notification will be send from ALM to App lto tell it that it is in Initializing state because Firebolt communication between App and ALM is not established yet. 

3.2. 2 Firebolt Lifecycle communication & getNavigationIntent

App/AppEngine connects to Firebolt Server App with Authentication token/session_id that it got as env value within the container env.

One of first things App must is to call is Discovery.getNatvigationIntent(2a) , register for each Lifecycle2.0 notifications with Lifecycle.listen('start',callback) pattern and then do 
 call Lifecycle.ready(2b) method to say to platform it is ready for Lifecycle communications.
Important that this Lifecycle.ready method will be returned with OK or ERROR coming from ALM (through FireboltServer) as it serves as confirmation, handshake between App and ALM that Lifecycle communication can start.
Discovery.getNavigationIntent (is singleton for each App_id) returns NavigationIntent for the App. To for example know what screen/deeplink to load in the app. Definition of all intent values in separate section/document

3.3. 3 cold start flow to pause or suspend directly

The app will startup either in :

  • A)regular App startup flow that leads to PAUSED and possibly other state afterwards
  • B)or in flow that leads to SUSPENDED state directly. Latter is more unusual and not supported by all Apps (eg Netflix requires it) but platform and lifecycle model must support it 
    The ALM decides the flow the App must follow based on use case & app capabilities and communicates that to the App explicitly with with different Lifecycle Notification, onStart for flow A and onStartSuspend for flow B. ALM may also communicate that already earlier via other means (ENV variable or part of NavigationIntent structure) but these are not necessary guaranteed

Example use case of flow B)
At box boot the ALM may decide to preload specific applications so these would launch quick (quicker compared to boot from cold start) when user requests them. But to not consume too much resources ALM decides to preload them in Suspended mode directly, provided that the application that supports that. Netflix supports it but for example WebApps won't support preloading them via this flow B) from initializing to suspended directly, these require to be preloaded via passing paused state and then suspend/hibernate them.

3.3.1. 3a coldstart to pause

3a describes flow from Initializing to PAUSED (see 3a). ALM will send OnStart(3a) to signal App that it must follow flow A to PAUSED and is entering PAUSED state and should initialize its RialtoClient and connect to associated RialtoServer (preparing but not setting up active Audio Video stream Session yet though), setup Wayland-egl surface with associated shell, fetch the App Graphics assets relevant to the NavigationIntent from network/flash and possibly load textures, vertices and shaders in GPU to prepare for frame rendering. 
The moment the Application renders its first frame on the actual wayland-EGL surface (eglSwapBuffers & wl.commit) is IMPORTANT Point in Lifecycle model.
Because that is trigger and pre-requisite for the transition to Active and if all conditions are fulfilled will lead to sending of onActivate() message in 4

Notes :
*At the moment the App got onStart event, App can assume it is in PAUSED state even though in reality it may still be transitioning to 'stable' PAUSED state (in ALM internal App state, we will make difference between transition & state at first frame render). 
*Important that ALM only sends OnStart event when RialtoServer instance associated with App/AppEngine is ready. ALM must have started RialtoServer instance through RialtoServerManager before seding OnStart notification. 

3.3.2. 3b preload in suspend (lukewarm)

3b)is for preload directly in suspend use case, for example required for netflix, where netflix will boot directly in suspended mode. The App must not setup Wayland-EGL surface, no rialto AV client and should not load textures,vertices, shaders in GPU.  
Note that only few apps can support this direct to suspeded mode preload. For example WebApps through browser cannot be preloaded this way. These need to first enter paused state and then moved to suspended state.
REMAINING open QUESTION here : On what basis will ALM know and decide that App can be considered to have landed in Suspended mode instead of still being in transiting state? 

3.4. 4 App Activation

The moment the Application renders its first frame on its actual Wayland-egl surface (eglSwapBuffers wl.commit) in PAUSED mode is IMPORTANT tipping Point in Lifecycle model.
Because that will trigger the transition to Active and sending of onActivate (see 4) message if all conditions are fulfilled.
Following chain of events happens underneath: That first fame rendering (first eglSwapBuffers wl.commit) will be detected by westeros wayland window manager and send WstClient_firstFrame event to ALM and ALM in case this is associated with LaunchApp request from IUI (and not preload request) will notify the IUI (MainApp) that this app_id is ready to be made visible. It is IUI that makes the decision to make that app/window visible or not as that depends on expected User behaviour/UI state. In regular App start flow that IUI will typically decide to make the app visible and will instruct (preferably through ALM) to make the App window visible  on the Westeros window manager. IUI will then typically also stop rendering possible App spinner or splash screen it may have rendered to avoid black screen transitions during Apploading transition.
Upon setVisible instruction from IUI ALM will send onActivate (4)  notification to the App and do set_visible for that window on windowmanager (typically via westeros simple shell). At wayland level, wayland client app will receive wl_surface.enter event for its surface.
At same time ALM will send event to RialoServer associated with the App to allow active AV sessions. Because App moved to Active state it can now setup actual audio/video sessions through Rialto
Also important is that we require that the App/Appengine first rendered frame is splash screen or a like and does not lead to bad frame-blinking experience for user

3.5. 5 App deactivation

Switch from ACTIVE to PAUSED can be quasi atomic only for those Apps that use Rialto because ALM can force AV tear down via RialtoServerManager instantly. Feedback from rialto/experts is that this force tear down will not have negative impact on such app itself (rialto client takes care?, need to confirm that in testing)
Upon switch to Paused state. onPaused(5) event is sent

3.6. 6 suspending

In suspended mode we expect APP/Appengine to reduce RAM of app, destroy its associated wayland-egl surface (to release associated GFX buffer), release its GPU textures and vertices and shaders in GPU and  release Rialto Client, ALM will release/tear down associated Rialto Server instance. 
(this states corresponds to Frozen state for WebApps in W3C PageLifecycle - Javascript execution of WebApplications within browser engine will be halted)

All these resouces cannot be atomically released by the app all at once. It will take some transition time (x ms). Also how does ALM know when App has reached the defined suspend mode?

To signal and start that transition to suspended state we send onSuspend (6a) Notification with optionally time in ms we expect App to reach suspended mode. App has now x ms to release resources. Value of sending expected time is in debate. 
From App point of view, we consider the app in "suspended state" also during transition state towards "suspended" state. On the ALM side those will remain 2 different states though. (suspending vs suspended)

Around expected transition time, ALM should check, police actual resource deallocation of App. If resouce allocation is still above what is expected the ALM can decided to trigger destroy of the app.

ALM monitor can monitor releasing of
-RAM : monitor PID ram usage:Yes
-EGL surface destroy: event from WesterosWindow Manager : Yes 
-releasing GPU memory textures, release GPU objects (triangles) & operations. : Currently RDK has no tools/HAL defined that allows that. to Investigate. Android AOSP is doing it see "adb shell dumpsys gfxinfo <package_name>" and is using Gralloc module for that in its HAL. Sky has addeded cgroup gpu resouce extension and did  modifs/adds on gfx driver code to measure usage

Alternative to Full EGL surface destroy by application is reducing its size to 1x1 pixel by the platform Window Manager under the hood. That also releases quasi all memory associated with double/tripple buffer app renders in. Comcast has done positive PoC with that.

3.7. 7 hibernating

App should have released all GPU objects, EGL surfaces and reduced its RAM already in suspended mode. That is pre-requisite and abosolute MUST (No GPU textures, W-EGL surfaces anymore associated wit the App) before app can be transitioned to hibernated mode.  
Other pre-requisite is that App/AppEngine is designed to handle restoring from hibernate.

Same pattern. onHibernate (7) notification Event to signal to app that we are about to hibernate within x ms. 
Most apps will already have done the necessary things for it in suspended mode. (eg WebApps themselves will have done that,)? A few apps might still have to close few remaining files, nework connections. Platform may decide to tweek those x ms wait for hibernate per app type/platform. The actual technology & component used by the Platform to do App hibernation is MEMCR in RDK. 

3.8. 8 restoring from Hibernated

is about restoring App from Hibernate mode. ALM triggers restore of App processes on MEMCR deamon (eg via wakeup container on dobby)
(question: AML does get success/failure back from  MemCR/Dobby when triggering restore but is success always really a success?)
Effectively when restore happend successfully, the App is back in RAM and gets CPU cycles.
ALM then sends onRestore (8) notification ( to App (perhaps with info params like period App was hibernated ) to make App aware it was hibernated, can communicate agan with ALM and can act as trigger for App to do some App component specific refresh/restore logic
We assume that websocket connection between App and FireboltServer was not torn down.  Hope that is safe and rocksolid assumption also in corner cases. Will need to be confirmed and well tested, otherwise it will create problems

3.9. 9 resuming from suspended

ALM sends onResume (9a) notification to signal the app to resume and allocate resources again RAM, W-EGL surface, GFX textures, Rialto Client. ALM will reinstantiated associated RialtoServer and set new NavigationIntent prior to onResume Notification.
App can assume it is in PAUSED state when receiving this Notification even though in reality it is still transitioning to stable PAUSED state (in ALM we will make diff between transition & state at first frame rend)
The Notification also serves as trigger for the App to get the Disovery.getNavigationIntent value (see 9b) (which is singleton for each App_id) which App needs to know what screen to load

3.10. 10 hotstart

User/IUM wants to launch app that is PAUZED stated, Since in PAUSED state App is already well preloaded (is hot) transition is quasi instant. Associated new NavigationIntent should set by ALM prior to onActivate (10a) Notification.
onActive Notification is sent by ALM upon IUI trigger together with setVisible on Windowmanager. In this scenario the OnActive Notification also serves as trigger for the App to get the Disovery.getNavigationIntent value (see 10b)

3.11. 11 user exit within App

User is interacting with app and uses App menu to exit it. App must use .Close (11) method on FireboltServer to tell ALM and then ALM will initiate either onDestroy, onPaused (and possibly then further OnSuspend) depending on its chosen policy

3.12. 12 destroy App

There can be several reasons why ALM decides to destroy an App. If it decides to destroy the app. It sends onDestroy (12) notification giving Application some time to close some of its internal resources before actually shutting down the AppContainer/killing the App process and providing reason string for destoring it

4. PRD

4.1. Use-cases

Acceptance criteria reference the flow diagrams above with a number, (#), next to each MUST/SHOULD/MAY statement. 


P0

Group: I want to support launching & deep-linking with a good user experience

1


Given an app is loaded, I want to tell the app what level of loading is expected


...so that the app can load the correct level of resources for the intended use case, no more, no less.

WHEN an app is loaded

THEN the platform MUST be able to return the desired deep-link to the app as soon as the app calls Discovery.getNavigationIntent

AND there MUST be a valid, non null value for the intent


WHEN an app is loaded

  AND the platform is doing a standard pre-load to Paused

THEN the intent MUST be a PreloadIntent

AND the data.graphics value of the intent MUST be true

AND the platform MUST fire a more specific intent some time before dispatching an onActivate notification


WHEN an app is loaded

  AND the platform is doing a pre-load to Suspended

THEN the intent MUST be a PreloadIntent

AND the data.graphics value of the intent MUST be false

AND the platform MAY fire a more specific intent some time before dispatching an onResume notification


WHEN an app is loaded

  AND the platform is doing a cold launch to Paused and then Active

  AND the platform doesn't have a specific deep-link for the launch

THEN the intent MUST be a LaunchIntent

AND the platform MAY activate the app or not


WHEN an app is loaded

  AND the platform is doing a cold launch to Paused and then Active

  AND the platform has a specific deep-link for the launch

THEN the intent MUST represent the the deep-link that is desired*

AND the platform MAY activate the app or not 


*Complete list of NavigationIntents is out of scope for this document.

2


Given an app has initialized Firebolt, I want to immediately send the next state change


...so that the app can continue to load.

WHEN an app is loading / initializing

THEN the app MUST call Lifecycle.ready() as soon as it has set up it's Firebolt event listeners

AND the app MUST NOT wait for any asynchronous or CPU intensive process to complete before doing so


WHEN an app calls Lifecycle.ready()

  AND it has already called Lifecycle.ready()

THEN the platform MUST send an error response


WHEN an app calls Lifecycle.ready()

  AND it has already registered for the Lifecycle.onStart notification

  AND the platform is doing a cold launch or pre-load to Paused

THEN the platform MUST send a Lifecycle.onStart notification to the app as quickly as possible


WHEN an app calls Lifecycle.ready()

  AND it has already registered for the  Lifecycle.onSuspended notification

  AND the platform is doing a pre-load to Suspended

THEN the platform MUST send a Lifecycle.onSuspended notification to the app as quickly as possible 

3


Given an app is loaded, but not yet active, I want it to render a good user experience as quickly as possible


...so that the platform can make it visible any time and the user will have a visual cue that the app is starting up

WHEN an app is Paused (2)

THEN the platform MAY make the app visible at any point (3a)

AND the platform MUST notify the app of this (1, 8b, 4b)

AND the app MUST present graphics which provide a good* user experience as quickly as possible (2)

AND any animations for said experience MUST be ready, but not actively drawing frames (2)

4


Given an app moves into the foreground, it should have loaded and rendered any deep-links as quickly as possible


... so that the user can get to their intended use case quickly.

WHEN an app receives an onNavigateTo notification

AND the app SHOULD immediately begin to fetch and compose the appropriate UX (3b)

5


Given an app moves into the foreground, it should be made visible quickly and with a good user experience


...so that the user can be presented with the app's experience.

WHEN an app is launched with a deep-link

  AND the app is already in the Paused state

THEN the platform MUST dispatch a Discovery.onNavigateTo with the new intent

AND the platform MUST wait to make the app visible until after the onNavigateTo is sent (3a)

AND the platform MUST wait to make the app visible until after the has drawn something* (3a)

AND the shared requirements below... 


WHEN an app is launched without a deep-link

  AND the app is already in the Paused state

  AND the most recent intent was a PreloadIntent

THEN the platform MUST dispatch a Discovery.onNavigateTo with a LaunchIntent

AND the platform MUST wait to make the app visible until after the onNavigateTo is sent (3a)

AND the platform MUST wait to make the app visible until after the has drawn something* (3a)

AND the shared requirements below...


WHEN an app is launched without a deep-link

  AND the app is already in the Paused state

  AND the most recent intent was not a PreloadIntent

THEN the platform MUST wait to make the app visible until after the has drawn something* (3a)

AND the shared requirements below...


Shared requirements:


AND the app MUST now be in the Active state

AND the platform  MUST notify the app of this transition (3b)

AND the app MAY call getNavigationIntent() to check if there is an intent that it missed the event for (3b)

AND the app SHOULD immediately begin to fetch and compose the appropriate UX if it has not already (3b)

AND the app SHOULD render a UX indicated by the most recent Intent within a reasonable time (3c)


*detection of when the app has "drawn something" is an engineering effort, not in scope for this document.

6

 

Given an app moves out of the foreground, it should remain in it's current UX state for a short amount of time


...so that the user can navigate back quickly to the same experience

WHEN an app is explicitly exited, e.g. by an exit option in the app's navigation

THEN the platform MUST make the app invisible (4a)

AND the app MUST be moved to the Paused state (2)

AND the app MUST be informed of the exit (4b)

AND the app MUST keep it's most recent UX displayed on the screen (4b)

AND the platform MUST stop and destroy any audio / video sessions belong to the app (2)

AND the platform MAY decide to exit to app for any reason*

AND the rest of the acceptance criteria from requirement #3


*Details out of scope for this doc

7

 

Given an app has been paused for a while, I want to tell the app to clear out it's last UX and prepare for a new intent


...so that the app can take less memory and be ready with a good user experience.

WHEN an app has been paused for a set amount of time*

THEN the platform MAY send a "Preload" intent via the onNavigateTo notification

AND the rest of the acceptance criteria from requirement #3


*Details out of scope for this doc


P1

Group: I want the active app to get the most resources without giving up fast (hot) launches of other apps (aka Suspended)

8

 

Given an app is loaded but not active, I want to ensure it does not negatively impact performance of active apps


...so that the user has a fast, responsive experience

WHEN an app is Paused (2)

    AND the app is no longer needed*

THEN the app MUST be moved to the Suspended state (6)

AND the app MUST be informed of the transition (5)

AND the app MUST deallocate it's EGL surface (5)

AND the app MUST deallocate GPU textures and other GPU memory (5)

AND the app MUST deallocate any other memory not necessary for a hot launch (5)

AND the platform SHOULD reduce CPU cycles given to the app (5)

AND the platform SHOULD reduce platform resources given to the app's graphics surface, e.g. destroy or set it 1x1 (5)

AND the platform MAY reduce Network bandwidth available to the app (5)

AND the platform MAY decide to suspend the app for any reason*

*Details out of scope for this doc

9

 

Given the user launches a suspended app, I want to bring it back to the running state and activate it


...so that the user has a faster launch time

WHEN an app is launched

    AND the app is in the Suspended state

THEN the platform MUST resize the app's graphics plane to full screen (8a)

AND the app MUST be moved to the Paused state (8a)

AND the app MUST be informed that is is resuming (8b)


AND the rest of the acceptance criteria from requirement #3

AND the rest of the acceptance criteria from requirement #4

10

 

Given the user launches many apps, I want to keep the platform running smoothly and manage resources


...so that the user has a fast, responsive experience

WHEN an app is Suspended

    AND the platform needs more resources*

THEN the platform MAY hibernate if appropriate* (7a)

OR the platform MAY destroy the app if appropriate* (10)

OR the platform MAY leave the app Suspended if appropriate*


*Details out of scope for this document

11

 

Given a platform pre-loads an app due to contractual obligations, I want to load it directly to suspended


...so that we don't waste platform resources on apps that might never be launched

WHEN an app is loaded

    AND the platform wants to save additional resources

    AND the app supports these criteria

    AND the platform decides to do so*

THEN the platform MUST load the app directly into the Suspended state (9)

AND the app MUST be informed (5)

AND the app SHOULD NOT allocate it's EGL surface (5)

AND the app SHOULD NOT allocate GPU textures and other GPU memory (5)

AND the app SHOULD NOT allocate any other memory not necessary for a hot launch (5)

AND the platform SHOULD reduce CPU cycles given to the app (5)

AND the platform SHOULD reduce platform resources given to the app's graphics surface, e.g. destroy or set it 1x1 (5)

AND the platform MAY reduce Network bandwidth available to the app (5)

AND the platform MAY decide to suspend the app for any reason*

*Details out of scope for this doc


P1

Group: I want to have more apps preloaded than available RAM allows (aka Hibernated)

12

 

Given the user launches many apps, I want to keep as many of them pre-loaded as possible


...so that the user has a faster launch time

 

WHEN a Suspended app is a candidate for hibernation*

    AND the platform has determined that the app has released sufficient resources*

THEN the app MUST be moved to the Hibernated state (7a)

AND the app MUST be informed of the transition (7b) TODO is this a SHOULD?

AND the platform MUST execute the MemCR routine to store the app's state (7c)

AND the platform MUST terminate the original app process and free up its resources TODO is this right?

13

 

Given a user launches a hibernated app, I want to restore it to memory and activate it


...so that the user has a faster launch time

WHEN an app is launched

    AND the app is in the Hibernated state

THEN the platform MUST execute the reverse MemCR routine to restore the app's state (7d)

AND the app MUST be moved to the Suspended state (7d)


AND the rest of the acceptance criteria from requirement #11


P0

As a W3C App Developer I want to get all of the benefits of the Firebolt Lifecycle through my existing integration with the W3C Page Lifecycle

14

 

Given my app is loading, I want access to the Firebolt ENV variables

WHEN JS execution begins (0)

THEN

document._firebolt.environment

MUST already have the ENV values set.

15

 

Given Lifecycle.onStart happens, I want to be notified via Window.load


WHEN Lifecycle.onActivate is invoked on WPE

THEN Window.load MUST be fired

16

P0

Given Lifecycle.onActivate happens, I want to be notified via Document.visibilityChange

WHEN Lifecycle.onActivate is invoked on WPE

THEN Document.visibilityState MUST be fired

AND

document.visibilityState = 'visible'

AND Discovery.getNavigationIntent() MUST return the current Intent

WHEN the Intent is not null

THEN my app MUST do all of the responsibilities denoted in Lifecycle.activate() (requirement #4)

WHEN the Intent is a Launch Intent

  AND the platform had previously dispatched an Lifecycle.onPause notification to the app

THEN any HTMLMediaElements that were paused by WPE MUST have their play method invoked by WPE

17

P2

Given Lifecycle.onPause happens, I want to be notified via standard HTML events

WHEN Lifecycle.onPause is invoked

THEN Document.visibilityState MUST be fired

AND

document.visibilityState = 'hidden'

AND any HTMLMediaElements MUST have their pause method invoked by WPE

18 P1 Given Lifecycle.onSuspend happens, I want to be notified via standard HTML events WHEN Lifecycle.onSuspend is invoked on WPE

THEN Window.freeze MUST be fired

AND Canvas.onContextLost MUST be fired on all Canvas elements

19

P1

Given Lifecycle.onResume happens, I want to be notified via standard HTML events

WHEN Lifecycle.onResume is invoked on WPE

THEN Window.resume MUST be fired

20

P1

Given Lifecycle.onHibernate happens, I want to not worry about it

WHEN Lifecycle.onHibernate is invoked on WPE

THEN the WPE browser MUST handle all necessary work 

21

P1

Given Lifecycle.onRestore happens,  I want to not worry about it

 WHEN Lifecycle.onRestore is invoked on WPE

THEN the WPE browser MUST handle all necessary work

4.2. Container Notes

4.2.1. Netflix

Can't share the Neflix info on public site, requires appropriate access control 

Referring to restricted pages behind access control

Simplified Lifecycle 2.0#ApplicationStates  

https://docs.netflixpartners.com/docs/nrdp/nrdp2024/application-states-and-management/

4.2.2.  Youtube Cobalt

4.2.2.1. 4.2.2.1. Application States

https://developers.google.com/youtube/cobalt/docs/reference/starboard/modules/16/event
https://developers.google.com/youtube/cobalt/docs/reference/starboard/modules/16/system
https://developers.google.com/youtube/cobalt/docs/gen/cobalt/doc/lifecycle


Application State Description Diagram
Started

Visible; focused; foregrounded

The Started state; this should roughly correspond to a "focused application" in a traditional window manager, where the application is fully visible and the primary receiver of input events.

Blurred

Previously called paused

Visible, unfocused; foregrounded

This should roughly correspond to "unfocused application" in a traditional window manager, where the application may be partially visible.

Concealed

Previously called suspended (and preloading)

Hidden, unfocused; backgrounded

This is a intermediate state between blurred and frozen.

This should roughly correspond to "minimization" in a traditional window manager, where the application is no longer visible. However, the background tasks can still be running.

Frozen

Previously called suspended

Hidden, unfocused; backgrounded

In the Frozen state, the application will be resident, but probably not running and has no network access. The expectation is that an external system event will bring the application out of the Frozen state.

4.2.2.2. Shutdown Reasons

Cobalt does not support any particular shutdown reasons–the app can be killed or transitioned between states without specifying a reason.

4.2.3. Prime

Can't share the Amazon info on public site, requires appropriate access control 

Referring to restricted pages behind access control

Simplified Lifecycle 2.0#Prime

https://partnercentral.amazon.com/docs/avpkv6/display.html





  • No labels