Cocos AIR application lifecycle
Stop once you can answer the task. Do not read another same-topic reference for the same question.
Scope: App admission, validated options, scene release, session cleanup and context health.
Environment: use package imports in apps; source paths require an AIR checkout. See context.
Quick Start
For complete setup and teardown, read Quick Start.
Siblings: direct dependencies; reuse loaded skills.
Triggers
- Choose valid createAirApp options and defaults
- Diagnose AIR_E_ or WEBGL2_REQUIRED startup errors
- Replace or release a running scene
- Inspect lost WebGL context health
- Own assets, listeners and timers during cleanup
- Fit a container or set design resolution
Exact API and symptom mappings: triggers.
Contracts
One runtime is admitted per document; a closed or failed runtime needs a page reload. Validate options before loading the engine. HEADLESS produces no pixels; context-health observation does not rebuild GPU resources.
Read references/contracts.md only when the task needs exact option rules, limits, error behavior or source annotations. Prefer the topic references below for a narrower question.
Common Mistakes
- [HIGH] Pass canvas to createAirApp; main import may precede canvas creation.
- [HIGH] A closed runtime cannot restart in the same document.
- [HIGH] HEADLESS renderMode 3 produces no rendered pixels.
- [MEDIUM] Context-health observation does not restore the device.
Read relevant wrong/right examples before implementation.
Reference map
- Configure startup? - Options and lifecycle
- Why did startup fail? - Codes and remedies
- Was context lost? - States and reload gate
- Who cleans up? - Ownership and disposal