-
-
Notifications
You must be signed in to change notification settings - Fork 442
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
Calculate frame count delta when another activity starts to avoid double counting #2273
Calculate frame count delta when another activity starts to avoid double counting #2273
Conversation
FrameCounts frameCountDiffOfLastKnownActivity = | ||
diffFrameCountsAtEnd(lastKnownActivityUnwrapped, frameCounts); | ||
if (frameCountDiffOfLastKnownActivity == null) { | ||
frameDiffsAtEnd.put(lastKnownActivityUnwrapped, new FrameCounts(0, 0, 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We fall back to FrameCounts(0, 0, 0)
so we don't calculate later but freeze it now. This is to avoid double counting.
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
- Calculate frame count delta when another activity starts to avoid double counting ([#2273](https://github.com/getsentry/sentry-java/pull/2273)) If none of the above apply, you can opt out of this check by adding |
What happens if the user finishes the activity transaction manually at a random point, such as |
Codecov ReportBase: 80.62% // Head: 80.62% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## fix/6_4_fix_frames_tracking_delta #2273 +/- ##
====================================================================
Coverage 80.62% 80.62%
Complexity 3368 3368
====================================================================
Files 240 240
Lines 12388 12388
Branches 1646 1646
====================================================================
Hits 9988 9988
Misses 1791 1791
Partials 609 609 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Then the |
@philipphofmann @romtsn @brustolin @markushi and me just discussed the PR and decided we don't want to merge it as we think it's easier to find the root problem (causing slow / frozen frames) if we show them on any transaction that is running when the slow / frozen frames occur. It's OK that the SDK double counts slow and frozen frames for overlapping transactions. The SDK can't track down its root cause when a slow or frozen frame happens. If the SDK adds them two both transactions, the transaction with the root cause will always have a higher slow and frozen frames rate, and users know to address this transaction first. Suppose the SDK would only add them to the transactions generated by the visible activity. In that case, it could happen that a background task kicked off by a previous activity puts slow and frozen frames on multiple activities loaded after it but never on the activity causing the slow and frozen frames. Long term it would be nice to know about all transactions that are running at the same time as it would make it easier to spot the root cause. The tracking code keeps counting frames until a transaction is finished and then takes all the frame counts since the transaction was started. Due to the fact that any Activity being started causes frames to be tracked in the same global place, all previous transactions also receive the counts until they finish. For the future we could change the code to always track slow and frozen frames for every Activity. Then anyone interested can ask for snapshots of the counts at any point in time and calculate a diff. This would then allow us to calculate slow / frozen frames for UI events and any other transaction (see #2061 and #2101). |
Thank you, @adinauer, for the detailed comment. |
📜 Description
Builds on top of the delta calculation for frame counts but calculates the delta earlier in case another Activity is started before tracking of the previous one has ended.
💡 Motivation and Context
If users turn off auto finish of transactions and instead finish them manually in
onStop
of the activity we would be double reporting some of the frames that occur betweenonStart
of the next Activity andonStop
of the previous Activity.💚 How did you test it?
Unit tests; Sample App
📝 Checklist
🔮 Next steps