fix: Cleanup AppHangTracking properly when closing SDK #2671
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📜 Description
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.
💡 Motivation and Context
This came up while checking the raw test logs of failing tests on the main branch, see https://github.com/getsentry/sentry-cocoa/actions/runs/4045915250/jobs/6958149321. The logs contain several statements, although the ANRTracker shouldn't be running.
💚 How did you test it?
Unit tests.
📝 Checklist
sendDefaultPIIis enabled🔮 Next steps