ANR Trace
is used to capture the main thread stalling event, and will sampling the main thread stack frame when the jam occurs.
After add ANR Trace
to MTHawkeyeClient
, by default it'll start after MTHawkeyeClient
run, you can change it by following steps:
- Tap MTHawkeye floating window, enter the main panel.
- Tap navigation title view, show the MTHawkeye panel switching view.
- Tap
Setting
in the upper right corner of the switching view, enter the Setting view home. - Find
TimeConsuming
and go toANR Trace
, turn offTrace ANR
, configureANR Threshold
When a method executed on main thread takes longer than the specified threshold (the default is 400ms), ANR Trace
will capture a stalling event, and sampling the stack frame of main thread. You can see the recorded stalling events and details within the App while development.
If you need a accurate duration time while stalling and the detail calls, consider using UI Time Profiler
When the app run into hard stall, it may killed without any logs, you can use MTHANRTracingBuffer
to cache and restore the last running context.
ANR records is store under Records file. Use a collection
name anr
, key
as the time stalling event generated (The version after 0.12.1 optimizes it, it will split the >16kb or more of the Carton data and store it again. The key
will become the timestamp_serial number
, which needs to be merged when used externally. Please refer to the merge method in readANRRecords
), value
is a JSON string with the following fields:
duration
: stalling duration, in millisecondinBackground
: whether it is running in the backgroundstacks
: all stack frame during stalling eventcapturedCount
: the number of times recorded, the same record will be deduplicatedstackframes
: sampling stack frame when the stalling event captured (symbolic needed), hexadecimal address string separated by,
threadCount
: current thread counttime
: the time stalling event generatedtitleframe
: stall event stack title string
startFrom
: stalling start time, in seconds
examples:
{
duration = "610.3181838989258";
inBackground = 0;
stacks = {
capturedCount = 1;
stackframes = "0x10d8fe55e,0x10d896497,0x108455f9a,0x108455c01,0x108455620,0x116a5d3d4,0x116a5d7b1,0x116888611,0x11687945f,0x1168a8865,0x10d8c4856,0x10d8bf2ed,0x10d8bf969,0x10d8bf055,0x10fa8fbaf,0x11687f88c,0x108460821,0x10e0084ac";
threadCount = 6;
time = "1565256930.870066";
titleframe = 0x108455f9a;
},
{
capturedCount = 1;
stackframes = "0x10d90461b,0x10d8fe6f5";
threadCount = 6;
time = "1565256930.975193";
titleframe = 0x10d90461b;
}
startFrom = "1565256930.414564";
}
ANR Trace
records raw stack frame need to symbolized for reading.
If the running App do have DWARF within, you can directly use ANR Trace
panel to view the symbolized result generated internal.
In other cases, if you have your own remote symbolization service and did set, switch on the Remote Symbolics
, and then you can view the symbolized stack frame directly in the App.
If you wanna get the raw data from the sandbox, manual symbolize yourself as follows:
- Get the
dyld-images
file in the MTHawkeye storage directory. - Get the raw stack frame data from the records.
- Get the
dSYM
files - for each
frame
- find the match
dyld-image
byframe
value, then match adSYM
file. - Use
atos
command to symbolize theframe
.
- find the match