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

[PLAT-6134] Fix inaccurate app.duration values #1014

Merged
merged 2 commits into from
Mar 1, 2021

Conversation

nickdowell
Copy link
Contributor

@nickdowell nickdowell commented Feb 26, 2021

Goal

Fix the calculation of app.duration and app.durationInForeground when multiple calls to notify() are made.

Changeset

The root cause was that each call to bsg_kscrashstate_updateDurationStats() was incrementing the duration by adding the time elapsed since appStateTransitionTime.

The fix is to make sure each call to bsg_kscrashstate_updateDurationStats() only adds the time elapsed since it was last called.

To make this clearer, appStateTransitionTime has been renamed to lastUpdateDurationsTime.

The accuracy has also been improved - the values were previously being rounded to the nearest second.

Testing

Added an E2E scenario that can replicate the original issue, and verified that it now passes.

@github-actions
Copy link

Infer: No issues found 🎉

OCLint: No issues found 🎉

Bugsnag.framework binary size did not change - 1,061,824 bytes

Generated by 🚫 Danger

@nickdowell nickdowell force-pushed the nickdowell/fix-app-duration branch from 17f619e to 7ab48fe Compare February 26, 2021 11:45
@nickdowell nickdowell force-pushed the nickdowell/fix-app-duration branch from 7ab48fe to 9788c93 Compare February 26, 2021 11:53
@nickdowell nickdowell marked this pull request as ready for review February 26, 2021 11:53
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