Skip to content

Catch All Exception to fix DeadSystemException#1902

Closed
puderty wants to merge 5 commits intoOneSignal:mainfrom
puderty:ok471
Closed

Catch All Exception to fix DeadSystemException#1902
puderty wants to merge 5 commits intoOneSignal:mainfrom
puderty:ok471

Conversation

@puderty
Copy link
Copy Markdown

@puderty puderty commented Nov 7, 2023

Description

One Line Summary

On some device like Huawei, there's a lot of DeadSystemException when calling getPackageInfo, we can just ignore it.

Details

Motivation

We can all ignore that exception, by merge this PR, we don't need to compile this library by ourself anymore.

Scope

Testing

Unit testing

Not answered

Manual testing

Not answered

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
    • If it is hard to explain how any codes changes are related to each other then it most likely needs to be more than one PR
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
    • Simplify with less code, followed by splitting up code into well named functions and variables, followed by adding comments to the code.
  • I have reviewed this PR myself, ensuring it meets each checklist item
    • WIP (Work In Progress) is ok, but explain what is still in progress and what you would like feedback on. Start the PR title with "WIP" to indicate this.

This change is Reviewable

@emawby emawby requested review from emawby, jkasten2 and nan-li November 10, 2023 00:01
Copy link
Copy Markdown
Member

@jkasten2 jkasten2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding some technical background here for reference. Android's documentation notes that the DeadSystemException is:

The core Android system has died and is going through a runtime restart. All running apps will be promptly killed.

Since this exception is not the fault of the app (or SDK) there isn't anything the app (or SDK) can do to recover from such a state. Catching and ignoring these won't improve the end-user experience since the app is already being killed, however doing so will clean up the noise from crash statistics.

Copy link
Copy Markdown
Member

@jkasten2 jkasten2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching Exception (or Throwable) can hide other issues which could result in broken states that make finding root issues difficult. Can you add catches for DeadSystemException here instead of changing all these to catch all exceptions?

@nan-li nan-li self-assigned this Dec 4, 2023
@jkasten2
Copy link
Copy Markdown
Member

@puderty Thanks for pointing out the places where DeadSystemException can be thrown. A PR was created based on this:
#1937

It has been merged in, and will be in the next 4.x.x release.

@jkasten2 jkasten2 closed this Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants