Documentation comes from this release commit, without inheriting newer content. Commit: 371ee4692c.
App startup and lifecycle
Startup is process state, owned by the clean architecture slice:
useBootstrapEntrySDK → useAppLifecycleStore.start → AppLifecycleFacade →
StartAppLifecycle → injected lifecycle source, scheduler and startup services.
The UI hook forwards its mount event only. It does not read onboarding state, subscribe to AppState, initialize SDKs, schedule warmups, or choose startup gates. The facade starts once per JS process, including across React remounts. A new process creates the graph again and starts every required service; there is no persisted "services started" flag.
Policy
Edit AppStartupPolicy to change when
a task starts. Edit AppStartupServices
to change how it reaches the device. Native collaborators are selected in
app-lifecycle-app-container.ts.
The launch context is captured from the synchronously restored onboarding/tutorial flags. Completing onboarding mid-session does not reinterpret that launch as a returning launch.
This also covers a second cold launch when onboarding is still incomplete: the screen's
fn_intro_1 event releases deferred work in that new process. A completed player never waits
for that event, because they no longer visit onboarding. A player resuming the tutorial gets
the gameplay services without waiting for onboarding either.
The first-screen signal is emitted before analytics delivery, so disabled analytics collection does not block startup. Splash visibility and first-screen commit can arrive in either order; both are required. The gate waits for a committed screen, not for the film to decode or a network asset to load.
Lifecycle actions
AppLifecycleSource bridges intro completion, splash visibility, first FTUE commit, Remote
Config changes, and native AppState events into the same use case. Events do not update React
presentation state. Each task has one startup job; repeated events cannot start it twice.
Pending scheduled work is canceled on inactive/background and scheduled again when active.
Already started services remain process-wide.
On a transition back to active, the use case requests RC refresh (unless gameplay is active) and rechecks No Ads expiry. Consecutive active notifications do neither again. A changed RC snapshot schedules version prefetch again without restarting sampler, haptics or other services. The MIDI processor still enforces its existing tutorial/gameplay/audio/ad blocking and catalog sync retains its own foreground/TTL behavior.
Essential SDK operations and their guarded boot telemetry live in
start-app-bootstrap.ts. The Remote Config fetch
starts early because it selects the onboarding script and monetization flow, but only a player
past onboarding waits for it on the splash (AppLaunchContext.waitForRemoteConfig). A player
still before onboarding opens as soon as the rest is ready. Once its onboarding screen is seen,
the install's A/B-tested values are locked (decideExperimentsForNewPlayer,
experiment-decision.ts): the console's answer if
this launch's fetch lands within 3 s (or an earlier launch fetched it), else the in-app baseline.
Until then Start shows a loading state and no film is picked (is_public decides which a build
may show); the tutorial's songs and covers are fetched after it. Start waits for nothing else, and
never past 3 s from the screen being seen (selectStartReady, see onboarding.md).
Every launch then settles the
lock in publishRemoteConfigOutcome (settleExperimentsAtLaunch): a player past onboarding with
no lock locks while the splash is up, a bumped ab_lock_version locks again while the splash is
up, and a fallback lock learns the console's round without moving. Analytics/crash,
attribution, IAP initialization and monetization binding keep their early paths. IAP and
attribution do not gate fresh-install navigation; IAP initialization must begin before callers
can request offerings. Returning launches wait for haptics; completed-tutorial launches also
register sampler/SFX splash warmups. Fresh-install boot_timing does not wait for deferred
gameplay warmups. Each deferred task reports failures independently without skipping other tasks.
Validation
- Policy tests:
src/domain/__tests__/app-startup-policy.test.ts. - Facade integration tests with real domain classes and injected fakes:
src/infra/__tests__/app-lifecycle.test.ts. - Scheduling tests verify two frame boundaries, idle dispatch and cancellation:
src/infra/__tests__/app-startup-scheduler.test.ts. - Store and source contracts protect the thin UI and the existing native boot wiring.
Device validation remains manual/CI (bun run e2e:test): fresh install, relaunch before
finishing onboarding, resume tutorial, completed-player cold start, and background/foreground.
No on-device speedup is claimed by the unit tests.