Android 12 - tracking weapon WinScope

1. Introduction

In the development process, we often encounter various window problems, such as animation exception, window exception, flashing screen, black screen, misplaced display

In the past, we can solve these problems by adding logs, debugging and analyzing code, but these UI problems often appear in a moment, and it is difficult to grasp the opportunity. The recorded logs are often huge. Extracting effective information from a large number of logs is a boring and cumbersome thing.

Android is also aware of this problem. The emergence of WinScope effectively helps us track window and display problems. It provides developers with a visual tool, so that developers can use the tool to track the change process of the whole interface, so that we can observe subtle changes. After iterating over several versions, WinScope on Android 12 becomes better. Let's see the general effect:

2. Tool acquisition

WinScope tools for Android 12 platform can be obtained through source code compilation. For details, please refer to the README.md document in the development/tools/winscope directory. Here is a compilation step for Ubuntu platform:

1. cd development/tools/winscope
2. sudo apt install nodejs npm
3. npm install -g yarn
4. yarn install
5. yarn build

There is a problem encountered during compilation. It seems that there is a problem of insufficient memory during kotlin Optimization:

Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded
	at com.google.gwt.dev.js.ScopeContext.referenceFor(ScopeContext.kt:68)
	at com.google.gwt.dev.js.JsAstMapper.mapAsPropertyNameRef(JsAstMapper.java:247)
	at com.google.gwt.dev.js.JsAstMapper.mapGetProp(JsAstMapper.java:608)
	at com.google.gwt.dev.js.JsAstMapper.mapWithoutLocation(JsAstMapper.java:138)
	at com.google.gwt.dev.js.JsAstMapper.map(JsAstMapper.java:47)
	at com.google.gwt.dev.js.JsAstMapper.mapExpression(JsAstMapper.java:466)
	at com.google.gwt.dev.js.JsAstMapper.mapBinaryOperation(JsAstMapper.java:304)
	at com.google.gwt.dev.js.JsAstMapper.mapAssignmentVariant(JsAstMapper.java:258)
	at com.google.gwt.dev.js.JsAstMapper.mapWithoutLocation(JsAstMapper.java:102)
	at com.google.gwt.dev.js.JsAstMapper.map(JsAstMapper.java:47)

You can use export Java before executing yarn build_ Opts = "- XX: - usegcoverhead limit" disable GC overhead limit exceeded detection

After compiling, a dist directory will be in the current directory, and then add ADB_ proxy/winscope_ Proxy.py (a script that helps us open the trace grab command, so that we can say goodbye to the cumbersome commands), and the file is also copied into the dist directory for our later use

3. Use

It is easy to use. After connecting the mobile phone:

  • Double click to open the index.html file in the dist directory
  • Execute Python 3 winscope on the terminal_ proxy.py

PS: it is suggested that you can set an alias for one click use, for example:

alias winscope_s="xdg-open ~/tools/winscope_s/index.html && python3 ~/tools/winscope_s/winscope_proxy.py"

After entering the python command, the terminal may generate a token and copy it to the browser

The following interface will appear:

After selecting START TRACE, you can record on the mobile phone, and then end the recording

4. Function improvement

Compared with Android 11, the new WinScope tool is more user-friendly on the interface. Important improvements are as follows:

  • Timeline control is more convenient. You can select different types of timeline for control. Otherwise, it is too difficult to control the time passage through the arrow after recording ProtoLog in the past
  • New Transaction and Log browsing interface
  • It supports the diff function. It has to be said that there are too many parameters in each frame. If there is no diff function, it is difficult to see that those parameters have changed at a glance
  • The recording of IME is added to record events of InputMethodService, InputMethodManagerService and Client
  • The screen recording interface can be displayed on the browser interface in the form of PIP
  • ...

I have to say it's really better than before. Try it quickly~

Tags: Android

Posted on Thu, 25 Nov 2021 00:16:06 -0500 by tannerc