Skip to content

Commit 60572c7

Browse files
authored
Make hang triggering more deterministic (#5413)
1 parent 5741a3f commit 60572c7

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

Samples/iOS-Swift/iOS-Swift/Tools/TriggerAppHang.swift

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,7 @@ func triggerNonFullyBlockingAppHang() {
2020
}
2121
}
2222

23-
/// Schedules heavy UI rendering work on the main thread in a tight loop, which causes
24-
/// a fully blocking app hang without frames being rendered.
23+
/// Sleep on the main thread for long enough to trigger a hang
2524
func triggerFullyBlockingAppHang(button: UIButton) {
26-
let buttonTitle = button.currentTitle
27-
var i = 0
28-
29-
for _ in 0...5_000_000 {
30-
i += Int.random(in: 0...10)
31-
i -= 1
32-
33-
button.setTitle("\(i)", for: .normal)
34-
}
35-
36-
button.setTitle(buttonTitle, for: .normal)
25+
sleep(5)
3726
}

0 commit comments

Comments
 (0)