File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
Tests/SentryTests/Integrations/ANR Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,9 @@ final class DefaultHangTracker<T: RunLoopObserver> {
7676 mainQueueState = . init( )
7777 }
7878
79+ // It's safe to access mainQueueState here regardless of the thread
80+ // because this is the only reference to `self` while
81+ // it is being deallocated.
7982 deinit {
8083 guard let observer = mainQueueState. observer else {
8184 return
Original file line number Diff line number Diff line change @@ -208,6 +208,14 @@ final class HangTrackerTests: XCTestCase {
208208
209209 sut = nil
210210
211+ // Allow the hang tracker's background thread to finish since it holds
212+ // a strong reference while it is running
213+ let expectation = XCTestExpectation ( )
214+ queue. async {
215+ expectation. fulfill ( )
216+ }
217+ wait ( for: [ expectation] )
218+
211219 XCTAssertNil ( weakSut, " Expected observer to be deallocated " )
212220 }
213221
You can’t perform that action at this time.
0 commit comments