This page illustrates sequence diagrams to be implemented by RDK App Infrastructure Thunder plugins.

References

Repository: https://github.com/rdkcentral/entservices-infra

Firebolt Lifecycle 2.0: Simplified Lifecycle 2.0 

Step 0-3 Common Prelaunch


For simplicity sequence diagrams are categorized yet the order of operation is numbered in sequence for continuity.

Step 0 - 3 are common for any type of launches with small adjustments.

For eg if Step 3 ends with 38 the next set of processing will continue from 39.

Step 0 : Setting up the listeners


@startuml

autonumber "[0]"
'hide footbox

title Setup Listeners for AI 2.0

participant ":SystemApp" as SystemApp
participant ":Package Manager" as PM
participant ":App Manager" as AM
participant ":Lifecycle Manager" as LM
participant ":Runtime Manager" as RM
participant ":Window Manager" as WM
participant ":Ripple" as Ripple

SystemApp -> AM: Listen for \nonAppLifecycleStateChanged()
AM -> LM: Listen for\nonAppLifecycleStateChanged()
AM -> PM: Listen for\nonAppInstallationStatus()
Ripple -> LM:  Listen for\nonAppLifecycleStateChanged()
LM -> WM: Listen for\n onReady()
LM -> WM: Listen for\n onVisible()
LM -> RM: Listen for\n onStateChanged()
@enduml


Step 1: Prelaunch: Package Locking 

@startuml

autonumber 8 "[0]"
'hide footbox

title General Package Handling

participant ":SystemApp" as SystemApp
participant ":Package Manager" as PM
participant ":App Manager" as AM
participant ":Lifecycle Manager" as LM

SystemApp -> AM: launchApp/preloadApp
AM -> LM: isAppLoaded( appId )

LM -->> AM: false
AM -> AM: Check Package loaded
AM -> PM: lock( packageId )
opt For Browser/Cobalt apps with runtime
	note right of PM: Package is already locked so replies faster
    PM -> PM: lock( runtimePackageId )
end 
PM -->> AM: 1. Unpacked path \n2. Configuration Object\n3. App Metadata
@enduml


Step 2: Prelaunch: Spawning

@startuml

autonumber 15 "[0]"
'hide footbox

title Spawning

participant ":SystemApp" as SystemApp
participant ":App Manager" as AM
participant ":Lifecycle Manager" as LM
participant ":Ripple" as Ripple

AM -> LM: spawnApp( appId, targetLifecycleState X )
note right of AM: Target lifecycle state could be ACTIVE/PAUSED/SUSPEND
AM --> SystemApp: return true 
activate LM
LM -> LM: allocate appInstanceId
LM -> LM: newAppLifecycleState = LOADING
LM ->> AM: onAppLifecycleStateChanged LOADING
AM ->> SystemApp: onAppLifecycleStateChanged LOADING
note left LM: Need to pass appId - for SecureStorage integration
LM ->> Ripple: onAppLifecycleStateChanged\nLOADING
Ripple -> Ripple: createSession
note right of Ripple: Use appInstanceId for Session
LM -> LM: Add environment variable\n for FIREBOLT_ENDPOINT and \npreload target state
deactivate LM
@enduml

Step 3: Prelaunch: Container Launch


@startuml

autonumber 24 "[0]"
'hide footbox

title Container Launch

participant ":App Manager" as AM
participant ":Lifecycle Manager" as LM
participant ":Runtime Manager" as RM
participant ":Window Manager" as WM
participant ":OCI" as OCI
participant ":Ripple" as Ripple

LM -> RM: run( appId, env )
activate RM
RM ->> LM: onStateChanged(Starting)
RM -> RM: Create Dobby Spec\n from Config Object
RM -> RM: Create User Id
 Note left of RM: Add Storage Manager.get using user Id
RM -> WM: createDisplay(appInstanceId)
WM --> RM: Wayland env variable display name
RM -> RM : Update display name
RM -> OCI: startContainer(spec)
OCI -> App: exec()
OCI ->> RM: onStarted
RM ->> LM : onStateChanged(Running)
LM -> LM: newAppLifecycleState = INITIALIZING
LM ->> AM: onAppLifecycleStateChanged\nINITIALIZING
LM ->> Ripple: onAppLifecycleStateChanged\n INITIALIZING 
Ripple ->> Ripple: Update app state
deactivate RM
@enduml

Step 4: Launch

Step 4A: Interactive App launched to Active


@startuml

autonumber 39 "[0]"
'hide footbox

title Launch for an Active Interactive App

participant ":SystemApp" as SystemApp
participant ":App Manager" as AM
participant ":Lifecycle Manager" as LM
participant ":Runtime Manager" as RM
participant ":Window Manager" as WM
participant ":Ripple" as Ripple
participant ":Firebolt App" as App

note right of SystemApp: Launch with target lifecycle state of ACTIVE
== 1. App Lifecycle Start up ==

activate App
note right of Ripple: url = getenv( "FIREBOLT_ENDPOINT" )
activate Ripple
App -> Ripple: Setup Lifecycle Listeners
App -> Ripple: Lifecycle.ready
Ripple -> LM: appReady() [JQ]
LM -> LM: newAppLifecycleState = PAUSED
LM ->> AM: onAppLifecycleStateChanged\nPAUSED
LM ->> Ripple: onAppLifecycleStateChanged\n PAUSED 
Ripple ->> App: onStart()
opt If frame is already rendered
LM -> WM: renderReady()
WM --> LM: true
end
opt else
note right of WM: Render first frame
App ->> WM: Wayland event
WM ->> LM: onReady(appInstanceId)
end
LM -> LM: newAppLifecycleState = ACTIVE
LM ->> Ripple : onAppLifecycleStateChanged\nACTIVE
Ripple ->> App: onActivate()
LM ->> AM: onAppLifecycleStateChanged\nACTIVE
AM ->> SystemApp: onAppLifecycleStateChanged\nACTIVE

opt SystemApp handling visibility and focus
SystemApp -> WM: wayland set_properties(appInstanceId,visible)
WM ->> LM: onVisible(appInstanceId)
SystemApp -> WM: wayland set_client_focus(appInstanceId)
end

deactivate Ripple
deactivate App


@enduml


Step 4B: Interactive App launched to Suspend

@startuml

autonumber 39 "[0]"
'hide footbox

title Launch for an Suspended Interactive App

participant ":SystemApp" as SystemApp
participant ":App Manager" as AM
participant ":Lifecycle Manager" as LM
participant ":Runtime Manager" as RM
participant ":Window Manager" as WM
participant ":Ripple" as Ripple
participant ":Firebolt App" as App

note right of SystemApp: Preloaded with target lifecycle state of SUSPENDED
activate App
note right of Ripple: url = getenv( "FIREBOLT_ENDPOINT" )
activate Ripple
App -> Ripple: Setup Lifecycle Listeners
App -> Ripple: Lifecycle.ready
Ripple -> LM: appReady() [JQ]
LM -> LM: newAppLifecycleState = SUSPENDED
LM -> RM: suspend(appInstanceId)
LM ->> AM: onAppLifecycleStateChanged\nSUSPENDED
LM ->> Ripple: onAppLifecycleStateChanged\n SUSPENDED 
Ripple ->> App: onStartSuspend

deactivate Ripple
deactivate App


@enduml


Step 4B Contd: Resume Suspended Interactive Launched App 

@startuml

autonumber 46 "[0]"
'hide footbox

title Launch for an Suspended Interactive App

participant ":SystemApp" as SystemApp
participant ":App Manager" as AM
participant ":Lifecycle Manager" as LM
participant ":Runtime Manager" as RM
participant ":Window Manager" as WM
participant ":Ripple" as Ripple
participant ":Firebolt App" as App

note right of SystemApp: Contd from Step 4B
SystemApp -> AM: launchApp
AM -> AM : isAppLoaded(appId) = true
AM -> LM: setTargetAppState(ACTIVE)

note right of LM: Current state is SUSPENDED
LM -> LM: newAppLifecycleState = PAUSED
LM -> RM: resume(appInstanceId)
LM ->> AM: onAppLifecycleStateChanged\nPAUSED
LM ->> Ripple: onAppLifecycleStateChanged\n PAUSED  
Ripple ->> App: onResume()

opt If frame is already rendered
LM -> WM: renderReady()
WM --> LM: true
end
opt else
note right of WM: Render first frame
App ->> WM: Wayland event
WM ->> LM: onReady(appInstanceId)
end
LM -> LM: newAppLifecycleState = ACTIVE
LM ->> Ripple : onAppLifecycleStateChanged\nACTIVE
Ripple ->> App: onActivate()
LM ->> AM: onAppLifecycleStateChanged\nACTIVE
AM ->> SystemApp: onAppLifecycleStateChanged\nACTIVE

opt SystemApp handling visibility and focus
SystemApp -> WM: wayland set_properties(appInstanceId,visible)
WM ->> LM: onVisible(appInstanceId)
SystemApp -> WM: wayland set_client_focus(appInstanceId)
end


@enduml


Step 5 Deactivation

Step 5A Deactivate for Non Suspendable Apps


@startuml

autonumber 58 "[0]"
'hide footbox

title Launch for an Suspended Interactive App

participant ":SystemApp" as SystemApp
participant ":App Manager" as AM
participant ":Lifecycle Manager" as LM
participant ":Window Manager" as WM
participant ":Ripple" as Ripple
participant ":Firebolt App" as App

note right of SystemApp: Contd from Step 4A
SystemApp -> AM: closeApp
AM -> LM: setTargetAppState(PAUSED)
LM -> LM: newAppLifecycleState = PAUSED
LM ->> Ripple: onAppLifecycleStateChanged\n PAUSED 
Ripple ->> App: onPause
LM ->> AM: onAppLifecycleStateChanged\nPAUSED
AM ->> SystemApp: onAppLifecycleStateChanged\nPAUSED
opt Termination
SystemApp -> AM: terminateApp
AM -> LM: unloadApp
LM -> LM: newAppLifecycleState = TERMINATING
LM ->> Ripple: onAppLifecycleStateChanged\n TERMINATING 
note right of Ripple: No guarantee for this dispatch
Ripple -> Ripple: Cleanup
Ripple ->> App: onDestroy
LM -> LM: Cleanup
end
@enduml


Step 5B Deactivate for Suspendable Apps


@startuml

autonumber 65 "[0]"
'hide footbox

title Launch for an Suspended Interactive App

participant ":SystemApp" as SystemApp
participant ":App Manager" as AM
participant ":Lifecycle Manager" as LM
participant ":Runtime Manager" as RM
participant ":Window Manager" as WM
participant ":Ripple" as Ripple
participant ":Firebolt App" as App

note right of SystemApp: Contd from Step 4B contd
SystemApp -> AM: closeApp
AM -> LM: setTargetAppState(PAUSED)
LM -> LM: newAppLifecycleState = PAUSED
LM ->> Ripple: onAppLifecycleStateChanged\n PAUSED 
Ripple ->> App: onPause
LM ->> AM: onAppLifecycleStateChanged\nPAUSED
AM ->> SystemApp: onAppLifecycleStateChanged\nPAUSED

note right of AM: Based on Suspension Policy
note right of AM: Need some methods in App Manager to support this TBD
AM -> LM: setAppTargetState(SUSPENDED)
LM -> LM: newAppLifecycleState = SUSPENDED
LM -> RM: suspend(appInstanceId)
LM ->> Ripple: onAppLifecycleStateChanged\n SUSPENDED 
Ripple ->> App: onSuspend
opt If App is enabled for Hibernation
note right of AM: Based on Hibernation Policy
note right of AM: Need some methods in App Manager to support this TBD
AM -> LM: setAppTargetState(HIBERNATED)
LM -> LM: newAppLifecycleState = HIBERNATED
LM -> RM: hibernate(appInstanceId)
end 


opt Termination
SystemApp -> AM: terminateApp
AM -> LM: unloadApp
opt Given current state is HIBERNATED
LM -> LM: newAppLifecycleState = SUSPENDED
LM -> RM: wake(appInstanceId,suspended)
LM -> LM: newAppLifecycleState = SUSPENDED
LM ->> Ripple: onAppLifecycleStateChanged\n SUSPENDED 
Ripple ->> App: onRestore
end
LM -> LM: newAppLifecycleState = TERMINATING
LM ->> Ripple: onAppLifecycleStateChanged\n TERMINATING 
note right of Ripple: No guarantee for this dispatch
Ripple -> Ripple: Cleanup
Ripple ->> App: onDestroy
LM -> LM: Cleanup
end
@enduml