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

Prevent unnecessary free disk calculations on initialisation #409

Merged
merged 2 commits into from
Jan 14, 2019

Conversation

fractalwrench
Copy link
Contributor

Goal

On initialisation of bugsnag-android, calculateFreeDisk was indirectly invoked, which performs IO on the main thread. This triggers unnecessary StrictMode violations, which can be observed by integrating the SDK into any app, and viewing logcat output on launch.

Design

getDeviceData() triggers these calculations. In the case of initialisation, the free disk information is not actually required, so the DeviceData class was adapted to add accessors for only the necessary information.

It's worth noting that there will still be a violation when notifying of an error, as we need to calculate the freeDisk information each time at this point.

Changeset

Added accessors for device.id and device.cpuAbi.

Tests

Enabled StrictMode in the example app and verified that stacktraces were no longer logged on initialisation, when filtering by 'calculateFreeDisk'.

on initialisation calculateFreeDisk was indirectly invoked, which performs IO on the main thread.
This change avoids calls to getDeviceData() which would trigger these calculations, and adds getters
for the necessary fields instead. This stops StrictMode violations being reported when initialising
the SDK.
@fractalwrench fractalwrench mentioned this pull request Jan 14, 2019
@fractalwrench fractalwrench merged commit 9e0e708 into master Jan 14, 2019
@fractalwrench fractalwrench deleted the strictmode-disk-fix branch January 15, 2019 13:31
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.

2 participants