laitimes

In-depth rendering of the impact of the mechanism on stuttering, one-time solution to the pain points of stuttering in interviews and work

author:Android architecture

preface

Caton has always been the core pain point in the interview and work process, as a developer wants to become a master of performance optimization, because all app development is inseparable from the optimization of this important link, but throughout the Many related posts on the Internet, it seems that there is no blog that can make people from a completely ignorant optimization routine of the students, after reading it can directly get started, and often need to piece together a little bit to solve the problem, resulting in a lot of time being wasted, but also can not get the substantive problem solved , then this time to bring you is the core problems in the interview Android rendering mechanism, and for the Caton optimization problem, how to find the problem, locate the problem, solve the problem strategy.

In-depth rendering of the impact of the mechanism on stuttering, one-time solution to the pain points of stuttering in interviews and work

Have you encountered the following questions at work or in interviews?

  1. Are you often asked about rendering mechanisms during interviews? And your answer is often talking about the drawing process?
  2. Are you often asked vs YNC and Choreographer without being able to speak clearly?
  3. Do you often have stuttering problems at work, but you don't know where to deal with it?
  4. Do you not understand the report after analyzing it with systrace or other tools?
  5. ……

Most developers are still doing business development, and performance optimization is basically stuck in the "heard" or "simple use tools" stage, including some Android engineers who have worked for many years.

If you want to improve, you must not only know how to use the tool to optimize performance, but also fully understand the underlying principles, and fully understand the underlying knowledge of Linux.

The following is to take the stuttering optimization as an example to analyze with you:

1. The Android Framework is absolutely core --- rendering mechanism

There are many students who will associate the rendering mechanism with the measurement, layout, and drawing process in the Android drawing process, in fact, the core of Android's rendering mechanism is a view process that converts from text data (layout xml) to instance data (View object) and then into image data (bitmap data generated by OPENGL calling GPU) and then pushed to the screen display. The middle also involves the processing of the surfacefilnger process for the driver, the specific process is roughly as shown in the following figure,

In-depth rendering of the impact of the mechanism on stuttering, one-time solution to the pain points of stuttering in interviews and work

After understanding the completion of the rendering mechanism, we can understand the production principle of stuttering through the rendering mechanism principle, then in combination with the STW phenomenon of memory management GC and the lock mechanism problem in thread management, the core causes that may cause stuttering are analyzed, as shown in the following figure

In-depth rendering of the impact of the mechanism on stuttering, one-time solution to the pain points of stuttering in interviews and work

For specific details, if you are interested, you can refer to the mind map I gave, which has the source code analysis and principle description of the full process of the rendering mechanism. Due to the fact that the picture is too large to load, the private message replies: 666 Get view !!!

2. Stuttering optimization?

Many small partners do not have a clear understanding of the optimization of content, performance optimization looks very tall, but in fact, it is the concept of "details determine success or failure". It is necessary to understand the principle of things clearly, what is different at each step, and to optimize each step in detail. Performance optimization is a thought, not a specific set of methods of operation.

Its main operating routines follow three principles

  • Finding Problems (Core Principles)
  • Positioning problems (principle practice)
  • Problem Solving (Principle Practice)

Through the principle to find the problem, and then use the tool to analyze the problem and quickly locate the problem, here the need for the principle of support and finally after the analysis of the principle according to the actual situation to solve

The pain point of Caton is that many times people can't find the problem, so the support of the previous rendering mechanism is very critical, through rendering can get the problem of the essence of the Caton, and then use the tool to quickly analyze

Have many students ever encountered getting tools and not knowing how to use them? Here's an idea that can generally solve all your problems in your work with three sets of tools:

1.systrace is able to quickly locate the type of accident

2. Choreographer can quickly monitor frame rate changes

3. The Looper mechanism can quickly locate the code stack information

The use of the above strategy can basically solve everyone's routine problems, the specific details are shown in the following mind map

In-depth rendering of the impact of the mechanism on stuttering, one-time solution to the pain points of stuttering in interviews and work

Since the HD picture you can reply in the background private message :666 Get view !!!

As a passer-by, I found that many learners and practitioners are facing a lot of problems in Android performance optimization, such as:

  • When encountering the problem of "performance optimization" in the work scene, often can only rely on blind guessing and feeling, and cover up with temporary remedies, which seems to solve the problem, but the next time the same problem will occur, the reason is the lack of methodology, architectural thinking guidance and tool support;
  • In the cultivation of ability, the practical environment of the Internet project is lacking, and the "performance optimization" can only be imagined through theoretical knowledge, and it is impossible to recognize its true face and practical operation process in the actual combat of the work;
  • In the workplace promotion, only functional development, do not understand the principle of component design, lack of in-depth thinking and summary, can not complete high-level work such as high concurrency, high-performance system design, it is difficult to show their fists in the work, and challenging work is often left to those who are prepared.

In short, once the performance problem is encountered, few people can reverse the analysis from the point and surface, and finally find the bottleneck point and optimization method, which shows that performance optimization needs to be comprehensively mastered and flexibly applied to the knowledge, which belongs to the deep water area of the Android knowledge field, and is also one of the criteria for measuring the level of a research and development capability.

In order to let everyone better understand the knowledge points related to Android performance optimization, Xiaobian sorted out a PDF learning document of Android performance optimization knowledge points for everyone, which contains startup optimization, UI rendering optimization, crash optimization, memory optimization, Caton optimization, storage optimization, weak network optimization, power consumption optimization, etc. Some technical points of the analysis, need to refer to the learning can be learned can be the background private message reply: 666 get to view !!!
In-depth rendering of the impact of the mechanism on stuttering, one-time solution to the pain points of stuttering in interviews and work
Job

Read on