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

Avoid crash when initializing bugsnag in attachBaseContext #953

Merged
merged 1 commit into from
Oct 16, 2020

Conversation

fractalwrench
Copy link
Contributor

Goal

Avoids a crash when initializing Bugsnag in Application#attachBaseContext(). Previously Bugsnag always attempted to obtain the application context to avoid leaking short-lived activity context. However, at this point in time the application context will return null, resulting in an IllegalArgumentException within the Client constructor.

This changeset fixes this by adding a null check. If the context does return null then it is the base context, and its safe to initialize with as it won't leak memory unlike an Activity.

Testing

Tested manually in an example app as this is not a suitable scenario for mazerunner. Added unit tests to confirm that the original crash does not occur.

@bugsnagbot
Copy link
Collaborator

Android notifier sizes

Format Size impact of Bugsnag (kB) Size impact of Bugsnag when Minified (kB)
APK 1437.58 1358.81
arm64_v8a 369.25 287.33
armeabi 348.76 266.85
armeabi_v7a 328.3 250.46
x86 406.1 324.18
x86_64 389.72 307.81

Generated by 🚫 Danger

Copy link
Contributor

@twometresteve twometresteve left a comment

Choose a reason for hiding this comment

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

LGTM

@fractalwrench fractalwrench merged commit 7dd6fae into next Oct 16, 2020
@fractalwrench fractalwrench deleted the PLAT-5244/base-context branch October 16, 2020 11:17
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