You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/Swift/HangTracker.swift
+41-13Lines changed: 41 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,21 @@
3
3
import UIKit
4
4
#endif
5
5
6
-
finalclassRunLoopObserver{
6
+
// A hang is parameterized by the its minimum duration, HangDuration, and is defined by a period of time lasting longer than HangDuration*2 when the delay
7
+
// of all frames started during that time sums to more than HangDuration. If there is only one frame during this time that is delayed then it is a "fullyBlocking"
8
+
// hang, otherwise it is a "nonFullyBlocking" hang.
9
+
//
10
+
// We measure late frames using a runloop observer. Any frame that is more than 50% delayed has its stacktrace sampled once, when we first detect it is delayed.
11
+
// After the hang ends (or the app restarts in the case of fatal hangs) the most recently recorded stacktrace is used to report the hang. Since a hang is not one
12
+
// stacktrace, like a crash, but rather a period of time, it would make sense to talk about a flamegraph sampled during the hang but the API does not support this.
13
+
// Note that stacktraces are always sampled from a background thread, since it’s the main thread that gets sampled.
14
+
//
15
+
// There are two ways we trigger saving hang data. One is on the main thread, when the hang is over. When each frame finishes rendering we collect its delay and
16
+
// if the sum of delays during the last HangDuration*2 is greather than the threshold, we report the last stack trace as a hang. The other way is on a background
17
+
// thread. Once a frame is delayed more than 50% we sample the thread and start tracking it. If the total delay becomes more than our threshold the event
18
+
// is recorded. If the hang never ends (thus transfering us back to the previous main thread case) then the hang is saved on the filesystem and
19
+
// sent as a fatal hang the next time the app is launched.
0 commit comments