[PLAT-5252] Prevent onCrashHandler being called for OOMs #874
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.
Goal
The
onCrashHandler
is not supposed to be called for OOMs - it's intended to be called when a crash occurs and not in the following launch of the app.Design
Temporarily setting
bsg_g_bugsnag_data.onCrash
toNULL
was the simplest and least intrusive solution.The alternative would entail deeper changes in KSCrash to allow
BSSerializeDataCrashHandler
to detect whether the crash is an OOM.Changeset
Updated
computeDidCrashLastLaunch
to preventonCrashHandler
being invoked.#if BSG_PLATFORM_TVOS || BSG_PLATFORM_IOS
was removed to allow the unit test to work on macOS.Testing
A unit test case (which reports a failure without the changes to BugsnagClient) has been added to verify this behaviour. It works by replacing the
shouldReportOOM
implementation to trigger an OOM to be sent - we may want to consider the use of a mocking framework such as OCMock if we need more of these kinds of tests.