Q: Why interface optimization?
A: APP will be stuck in actual operation, which is called frame drop.
Q: Why do I drop frames?
A: The page rendering process is CPU->GPU-> Frame cache pool ->videoController-> display. When the videController reads frame by frame in the frame cache pool, the CPU’s calculation and THE GPU’s frame conversion can’t keep up, and there will be a frame drop, namely a frame lag.
There are three ways to carry out caton detection:
1. Use THE FPS tool for detection
2. Use Runloop status detection for listening
3. The upgrade mode of Runloop is detected by the Wechat Card detection tool
So avoid these problems first of all
One: we should try to reduce the operation of complex logic, so that the CPU burden is not so big.
Two: preloading, that is, the data processing of the frame and model data of its own and its subordinate controls is calculated and then rendered to the main thread.
3. The image loading process is not just to get the image data and display it on the layer. In fact, a codec process is carried out during the loading process, which is executed on the main thread by default, thus increasing the consumption of performance. SDWebImage performs this process well.
Four: asynchronous rendering
Example: open thread network request data, open another thread for asynchronous rendering, and then return to the main thread display.