-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Cleanup AppHangTracking properly when closing SDK (#2671)
When closing the SDK directly after starting it, it could happen that the ANRTracker didn't start its watchdog thread yet. Canceling the ANRTrackers thread required the instance of the watchdog thread and didn't work correctly. This is fixed now by using simple state management in the ANRTracker. While this is an edge case, it can help with flaky tests, as the test logs showed signs of the ANRTracker running in the background.
- Loading branch information
1 parent
ddc9b9a
commit 075a044
Showing
6 changed files
with
100 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
import Foundation | ||
import XCTest | ||
|
||
class SentryTestThreadWrapper: SentryThreadWrapper { | ||
|
||
var threadFinishedExpectation = XCTestExpectation(description: "Thread Finished Expectation") | ||
var threads: Set<UUID> = Set() | ||
var threadStartedInvocations = Invocations<UUID>() | ||
var threadFinishedInvocations = Invocations<UUID>() | ||
|
||
override func sleep(forTimeInterval timeInterval: TimeInterval) { | ||
// Don't sleep. Do nothing. | ||
} | ||
|
||
override func threadStarted(_ threadID: UUID) { | ||
threadStartedInvocations.record(threadID) | ||
threads.insert(threadID) | ||
} | ||
|
||
override func threadFinished(_ threadID: UUID) { | ||
threadFinishedInvocations.record(threadID) | ||
threads.remove(threadID) | ||
threadFinishedExpectation.fulfill() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters