Matrix code zero intrusion automatic burial

Matrix code zero intrusion automatic burial

Link to this article: https://blog.csdn.net/feather_wch/article/details/131693055

Included content:
The relationship between the application startup process and freeze monitoring
Principle analysis and defects of freeze monitoring
How WeChat realizes freeze monitoring
Practice of non-intrusive embedding technology

raise a question

What should I do if I encounter a Caton problem?

  • Analyze with tools
  1. CPU Profile
  2. Systrace
  3. layoutinspect

The difference between performance optimization and framework principle learning

  • FM changes less
  • Performance problems may have various causes, which require rich practical experience

** The user is very stuck in using the App, how to solve it? **

  • online monitoring
  • Reappear offline

1. What is Bugly? Umeng?

  1. Abnormal monitoring platform (Crash, exception)

Caton monitoring

2. Caton monitoring?

  1. Purpose: When the user is stuck, until what code is currently being executed, to help analyze and solve the stuck problem

How to judge whether the program freezes?

How to stack collection?

Caton judgment

3. Based on the principle of Looper freeze determination

  1. Andorid things process messages based on Looper, which takes time to process messages, which will inevitably lead to lag
  2. Set Printer-setMessageLogging(xxx), the first callback logging.println records the start time and startDump, the second callback records the end time and stopDump, you can estimate the MSG execution time
  3. [Matrix solution] Looper freeze monitoring, Choreographer for frame rate monitoring
  4. 【BlockCanary】Looper freeze monitoring
  5. 【360 Argus Apm】Choreographer

4. BlockCanary freeze monitoring defect

  1. There is no way to judge which method has the problem, the granularity is too large and imprecise

5. How to optimize Looper freeze monitoring

  1. For each business code, bytecode instrumentation

6. Use of Matrix

  1. The log in the matrix has become a number and time, and the mapping file is required for restoration. reduce data volume

7. How to implement time statistics when each business method of Matrix adds entry and exit methods?

  1. Bytecode Chazhuang added I and O methods, and the performance of each time query is too poor.
  2. There is a HandlerThread time bus to obtain a 5ms update
    time bus

expand knowledge

App startup process

  1. Launcher process -> SystemServer process -> (LocalSocket) fork process -> App process <—> SystemServer (AMS/ATMS)
  2. startActivity->startProcessLocked->fork->attachApplication->bindApplication->schduleLauchActivity
  3. ApplicationThread和ActivityThread

fork and multithreading

  1. The system cannot use Binder
  2. Divergence => KOOM online memory monitoring, Leakcanary Dump consumes performance, suspend all threads
  3. Use fork to create a child process and dump, because the memory information is exactly the same, so it can be used for analysis.
  4. In actual combat: the child process cannot be executed normally -> Java is inherently multi-threaded, with daemon threads, fork and multi-threading
  5. The dump source code will suspendAllThread, but the thread in the child process is just an object and does not run, and an error will occur.
  6. Before the fork, suspendAllThread, and then fork, the thread itself in the forked child process is already in the suspend state, so calling the suspendAll method will not cause problems.
  7. The main process can resume the thread immediately after fork, and can do its own thing
  8. fork => comes from the fork technology used before Android 6.0 keep-alive technology

Relinker

  1. The Apk is deployed on site, but the so needs to be updated. If there is a problem with the device, just configure the so on the network, download and load it? ? ?

Tencent's small video live broadcast uses LocalSocket on the Android side

  1. IPC communication scheme: Binder, LocalSocket, MMKV, SharedMemory, Pipe
  2. Analog audio and video transmission, send the serialized data object every 16ms, the size is 3K/4M/10M three gears
  3. Time range: the timestamp before sending, the timestamp received and deserialized into an object, the difference between them is the transmission delay
  4. LocalSocket is the best among the three data gears. Well below 10ms.
  5. Binder (XIPCInvoker) and MMKV: 10M data delay is too large

Guess you like

Origin blog.csdn.net/feather_wch/article/details/131693055