Mini App operation mechanism
Depending on the host application environment in which the Mini App is running, the Mini App may also have different startup mechanisms.
# 1. The Mini App starts
The Mini App will have two situations, one is cold startup, and the other is hot startup.
- Cold startup: The situation in which the user opens it for the first time or the Mini App is actively destroyed by the host application and then opens it again, at which time the Mini App needs to be reloaded and started, that is, a cold start.
- Hot startup: If the user has opened a Mini App and then opened the Mini App again within a certain period of time, there is no need to restart at this time, just switch the Mini App in the background state to the Foreground, the process is a warm start.
# 2. Front and back office status
After the Mini App is launched, the user can directly see the interface of the Mini App, and the Mini App is in the Foreground state.
When the user clicks the 'capsule button in the upper right corner' to close the Mini App, or presses the 'Device Home Button' to leave the host application, the Mini App is not directly destroyed, but enters the Background state; When the user opens the client again or opens the Mini App again, the Mini App enters the Foreground from the background.
# 3. Mini App destruction mechanism
# 3.1 Mobile
Usually, only when the Mini App enters the background for a certain period of time, or the system resources are too high, it will be destroyed, and the destruction mechanism of the mobile Mini App is as follows:
- When the Mini App occupies too much system resources, it may be destroyed by the system or actively recycled by the client.
- On iOS, a maximum of 5 Mini Apps are allowed to exist at the same time, and if there are more than 5 Mini Apps, the MiniApp that has not been used for the longest time will be destroyed. In addition, when the client receives a memory alarm, it will actively destroy all background MiniApps.
- On Android, up to 5 Mini Apps are allowed to exist at the same time, and if there are more than 5, the One that has not been used for the longest time will be destroyed. In addition, when the memory is insufficient, the system will directly reclaim the memory and destroy the small program that has not been used for a long time in the background.
# 3.2 Desktop
On the desktop side, as long as the Mini App is not closed, the Mini App will always be in a running state, and if it is closed, it will be directly destroyed.
# 4. The MiniApp opens the logic
The MiniApp cold boot page opening logic is better understood, and the hot boot is more complicated because some jumps may be generated automatically.
Depending on the startup parameters, these jumps can be summarized as:
| Specify a page or parameter that is different | Effect |
|---|---|
| Yes | Empty the original page stack and open the specified page |
| No | Leave the original state |