# Performance and Experience Optimization
To make the user's answering and dialing experience smoother, the key is to reduce the time spent on Weixin Mini Program startup and some network requests when answering and dialing.
Weixin Mini Program A cold start takes some time, especially on poor performance devices.Impacts the user's experience of making and receiving audio and video calls.
# 1. Weixin Mini Program Side Start Performance Optimization
Developers are advised to refer to the Startup Performance Optimization Document to optimize the startup time of Weixin Mini Program.
# 2. Android WMPF Weixin Mini Program Warm up (recommended)
In device-side WMPF, we provide additional " Weixin Mini Program preheating " capability,Before the user uses the Mini Program, the Mini Program is pre- **started in the background in an interfaceless form and runs permanently in the background, so that the user can directly cut the Mini Program into the front desk when using it, without the need for a complete cold startup process.The process is as follows:
- After WMPF is activated, before the user uses Weixin Mini Program,
warmUpAppwarm-up Mini Program.- In general, it is recommended to specify the path as the Call / Receive page of the plug-in
plugin-private://wxf830863afde621eb/pages/call-page-plugin/call-page-plugin?isPreLaunch=1。If the developer needs Weixin Mini Program to open other pages on startup (such as a linked list page), you can also specify that other pages are preheated.
- In general, it is recommended to specify the path as the Call / Receive page of the plug-in
- When you need to use Weixin Mini Program, call [[ TAG-0-START]]
launchMiniProgram](https://developers.weixin.qq.com/doc/oplatform/Miniprogram_Frame/api/cli/miniprogram/launchMiniProgram.html) Pass in the normal start parameters such as path with query, you can reuse the preheated environment before, and pull the Mini Program to the foreground.- The path part of the path parameter passed in during preheating and formal use needs to be the same, and the query part can be different. Otherwise, it will trigger an additional reLaunch of the page
Weixin Mini Program Developers need to identify and adapt to the case of warm-up startup:
- It is recommended that developers add a
isPreLaunch = 1parameter to the preheat path (or use another name) to identify the preheat entry - In the query for the ApageonShow event, you need to determine if there is an isPreLaunch. When isPreLaunch is 1, it can be considered a warm start and should not initiate a call.
- No isPreLaunch is normal to boot and can be used from the plugin
getPluginEnterOptions ()Get the parameters callinitByCaller.
const wmpfVoip = requirePlugin('wmpf-voip').default
App({
onShow() {
const options = wmpfVoip.getPluginEnterOptions()
if (options.query.isPreLaunch) {
// 小程序预热场景,无需处理
} else {
// 正常启动场景,执行其他业务逻辑
}
}
})
Be careful
- Refer to section 4. If the
keepRunningparameter is not specified when you close Weixin Mini Program, the Mini Program needs to be warmed again after it is closed. - Warming or cutting background does not guarantee that Weixin Mini Program will run all the time. WMPF may be recycled because of the system's resource management policy, or WMPF may take the initiative to clean up the Mini Program when the background is cut for more than a certain time or resources are tight.
# 3. Android WMPF Weixin Mini Program Environment Preloaded
If you do Weixin Mini Program preheat, no more environment preload
If it is not possible to preheat the Weixin Mini Program background because of equipment resource constraints, you can preload the Mini Program environment using the preload interface. This interface only pre-creates a basic Mini Program runtime environment and Mini Program infrastructure, and does not start a specific Mini Program.
# 4. Android WMPF off Weixin Mini Program
By default, call WMPF closeWxaApp When the interface closes Weixin Mini Program, the instance of the Mini Program is directly destroyed, and the next use requires a cold start (or warm up).
Developers are advised to enterkeepRunningto true when Weixin Mini Program is turned off, where the Mini Program will cut directly into the background and can be reused the next time it is used to avoid repeated cold startup or repeated preheating.
# 5. Reservation of notes
Calling plug-in initByCaller deviceToken used to initiate a callandpushTokenBoth of these tokens need to be obtained from the WeChat background, and if they are obtained after the user clicks, they may prolong the time required to initiate a call.
Developers are advised to prepare these parameters in advance on the front page (e.g. contact page, etc.) where the user initiates the call. If the user initiated the call during the validity period of the bill, there is no need to re-obtain it.