-
-
Notifications
You must be signed in to change notification settings - Fork 375
Description
Platform
iOS
Environment
Production
Installed
Swift Package Manager
Version
8.46.0
Xcode Version
16.2
Did it work on previous versions?
No response
Steps to Reproduce
The way in which it is currently possible to determine whether an application has crashed in the last session has a design flaw that makes it impossible to reliably determine whether an application has not crashed.
Consider the following simple example to reproduce the issue:
NSLog("### [1] Crashed last run: \(SentrySDK.crashedLastRun)")
SentrySDK.start { options in
NSLog("### [2] Crashed last run: \(SentrySDK.crashedLastRun)")
}
NSLog("### [3] Crashed last run: \(SentrySDK.crashedLastRun)")The log outputs for [1], [2] and [3] will display false even if the app crashed in the last session.
Expected Result
crashedLastRun should not return false if it's currently unknown if the app did crash in the last session or not.
Returning false although the status is actually still unknown is at least unexpected and leads to the problem that you can never be sure in an app whether the app has actually not crashed in the last session.
An expected behavior would be that when attempting to retrieve crashedLastRun, although the status is currently still unknown, a value is returned that clearly signals this status, e.g. via a nil value or by returning an error.
In addition, the behaviour in this regard should also be documented, which it currently is not.
Now there is the onCrashedLastRun handler, which is called asynchronously as soon as the SDK knows that the app has crashed in the last session, but this method is not called if the app has not crashed.
In other words, there is no mechanism that signals the status as soon as the SDK knows that the app has not crashed in the last session.
A possible solution would be if onCrashedLastRun is also called at the moment when the SDK knows the actual status and passes this status via a parameter. However, you should probably then rename the handler method to avoid confusion.
Actual Result
SentrySDK.crashedLastRunalways returnsfalsebefore theSentrySDK.startmethod has been called, no matter if the app did crash in the last session or not.SentrySDK.crashedLastRunalways returnsfalsein the options closure of theSentrySDK.startmethod, no matter if the app did crash in the last session or not.SentrySDK.crashedLastRunmay returnfalseafter theSentrySDK.startcall even if the app did crash in the last session since thestartmethod is an asynchronous process.
Are you willing to submit a PR?
No response
Metadata
Metadata
Assignees
Projects
Status