Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: SDK detects OutOfMemory after device reboot #3352

Merged
merged 4 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Features

- Improve OOM detection by ignoring system reboot (#3352)

### Fixes

- Missing `mechanism.handled` is not considered crash (#3353)
Expand Down
5 changes: 5 additions & 0 deletions Sources/Sentry/SentryWatchdogTerminationLogic.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ - (BOOL)isWatchdogTermination
return NO;
}

// The app may have been terminated due to device reboot
if (previousAppState.systemBootTimestamp != currentAppState.systemBootTimestamp) {
return NO;
}

// This value can change when installing test builds using Xcode or when installing an app
// on a device using ad-hoc distribution.
if (![currentAppState.vendorId isEqualToString:previousAppState.vendorId]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class SentryCrashIntegrationTests: NotificationCenterTestCase {
let sentryCrash: TestSentryCrashWrapper

init() {
SentryDependencyContainer.sharedInstance().sysctlWrapper = TestSysctl()
sentryCrash = TestSentryCrashWrapper.sharedInstance()
sentryCrash.internalActiveDurationSinceLastCrash = 5.0
sentryCrash.internalCrashedLastLaunch = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,18 @@ class SentryWatchdogTerminationTrackerTests: NotificationCenterTestCase {
sut.start()
assertNoOOMSent()
}


func testDifferentBootTime_NoOOM() {
sut = fixture.getSut(usingRealFileManager: true)
sut.start()
let appState = SentryAppState(releaseName: fixture.options.releaseName ?? "", osVersion: UIDevice.current.systemVersion, vendorId: TestData.someUUID, isDebugging: false, systemBootTimestamp: fixture.sysctl.systemBootTimestamp.addingTimeInterval(1))

givenPreviousAppState(appState: appState)
fixture.mockFileManager.moveAppStateToPreviousAppState()
sut.start()
assertNoOOMSent()
}

func testAppWasInForeground_OOM() {
sut = fixture.getSut(usingRealFileManager: true)

Expand Down
Loading