Skip to content

Minigame Runtime Mechanism ​

Minigames follow specific state-switching logic during the startup, running, and destruction processes.

Foreground and Background States ​

  • Foreground state: after a minigame starts, the 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 but instead enters the background state.
  • Running restrictions: after entering the background, the minigame can keep running for a short period of time.

Startup Methods ​

Depending on whether the minigame has already been destroyed, startup falls into two cases:

Startup MethodDefinition and Description
Cold StartThe user opens it for the first time, or opens the minigame again after it has been destroyed. In this case it needs to be reloaded and started.
Hot StartThe user has already opened a minigame and opens it again within a certain period of time; the minigame moves from the background to the foreground.

Destruction Timing ​

A minigame does not stay resident in memory indefinitely. It will be destroyed in the following cases:

  1. Long stay in the background: it remains unopened for a certain period after entering the background.
  2. System resource reclamation: when system memory is tight or the minigame occupies too many resources.
  3. iOS memory warning: on iOS, if system memory warnings are received continuously, the minigame will be proactively destroyed.

Optimization suggestion: developers should use sud.onMemoryWarning to listen for memory warning events and proactively perform memory cleanup when necessary.

Logic Rules for Reopening ​

There are two types of scenarios in which the user expects to open a minigame:

Scenario Classification ​

  • Scenario A: opening the home page. The scene values are as follows:
Scene TypeDescription
1Minigame main entry
2Android system desktop icon
3Returning from another minigame
  • Scenario B: opening a specific page designated by the minigame, with scene values other than those in Scenario A The logic for reopening a minigame is as follows:
Previous ScenarioCurrent Opening ScenarioFinal Behavior
Scenario AScenario ARetain the original state (continue from last progress)
Scenario BScenario AClear the page stack and reopen the home page (reStart)
Scenario A or BScenario BClear the page stack and open the specified page (reStart)