Minigame Running Mechanism
During startup, running, and destruction, a minigame follows a specific state-switching logic.
Foreground and Background States
- Foreground state: after the minigame starts, its interface is displayed to the user.
- Background state: when the user taps the capsule button in the top-right corner to close the minigame, or presses the device Home key to leave the platform, the minigame does not fully terminate; instead it enters the background state.
- Running restriction: after entering the background, the minigame can keep running for a short period.
Startup Methods
Depending on whether the minigame has already been destroyed, startup falls into two cases:
| Startup Method | Definition and Description |
|---|---|
| Cold Start | The user opens the minigame for the first time, or reopens it after it was destroyed. In this case it must be reloaded and started. |
| Hot Start | The user has already opened a minigame and reopens it within a certain period; the minigame moves from the background to the foreground. |
Destruction Timing
A minigame does not stay resident in memory indefinitely. It is destroyed in the following situations:
- Long stay in the background: it remains in the background for a certain period without being reopened.
- System resource reclamation: when system memory is tight or the minigame consumes excessive resources.
- iOS memory warning: on iOS, if system memory warnings are received consecutively, the minigame is proactively destroyed.
Logic Rules for Reopening
There are two categories of user expectations when opening a minigame, described as scenes:
Scene Categories
- Scene A: opening the home page. The scene values are as follows:
| Scene Type | Description |
|---|---|
| 1 | Minigame main entry |
| 2 | Android system desktop icon |
| 3 | Returning from another minigame |
- Scene B: opening a specific page designated by the minigame, with a scene value other than those of Scene A. When reopening a minigame, the logic is as follows:
| Previous Scene | Current Opening Scene | Final Behavior |
|---|---|---|
| Scene A | Scene A | Retain the original state (continue from last progress) |
| Scene B | Scene A | Clear the page stack and reopen the home page (reStart) |
| Scene A or B | Scene B | Clear the page stack and open the specified page (reStart) |
