setData Is the most frequently used interface in Mini Program development, and is also the most likely to cause performance problems. A brief introduction before introducing common incorrect usage
setData How it works behind it.
Common setData Operation error
1. Frequent going setData
In some cases we have analyzed, some Mini Programs go very frequently (in milliseconds)
setData, which leads to two consequences:
- Android Lower users will feel Caton when swiping, and the operational feedback delay is severe because JS The thread has been compiling and performing rendering, and failed to pass user action events to logical layer in time, and logical layer failed to deliver action processing results to view layer
- Rendering has a delay due to WebView of JS The thread is busy all the time, the communication from the logic layer to the page layer is time-consuming, the data message received by the view layer is hundreds of milliseconds from the time it was sent out, the rendering result is not real-time
2. every time setData Are passing lots of new data
setDataOur data transfer is actually one time
3. Background state page setData
When the page is in the background state (not visible to the user), it should not proceed
setData, background state page rendering users are unable to feel, in addition background state pages to
setDataAlso preempts the execution of the foreground page.
The main performance problems with image resources at present are on large images and long list images, both of which can cause iOS The client memory footprint rises, which triggers the system recycling Mini Program page.
Effect of pictures on memory
in iOS Up, the Mini Program's page is composed of multiple WKWebView Composed of, when the system memory is tight, will recover a portion WKWebView。 From past cases we have analyzed, the use of large pictures and long list pictures can cause WKWebView Of recycling.
The Effect of Images on Page Switching
In addition to memory problems, large images can also cause page switching Caton. We have analyzed the case, there are some Mini Programs in the page will reference large images, in the back of the page switch will appear to drop frame caton.
Currently we recommend that developers minimize the use of large image resources.