Set warm start delay heuristic to 2 seconds #863
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goal
At 60 seconds, the heuristic we are using to determine whether we are experiencing a warm start vs a cold start, which previously measured the time between the last event before activity onCreate is called to the activity onCreate of the Activity we consider to be the activity whose rendering will end startup, is too generous, leaving too much time for background app startups followed by a user-invoked launcher startup to be considered a cold startup.
As such, we are going to shrink that to a more reasonable 2 seconds, which is quite a bit of time already if that last even is the end of the Application onCreate. We are also counting the FIRST activity onCreate being invoked, event if it is not the startup activity, because that indicates the startup is happening.
Even with this fix, though, the implementation is still imperfect, because if we don't know when application onCreate finishes (which we don't know out of the box), we simply use the end of the Embrace SDK's init time as that. We should look to improve this heuristic by getting customers to set this information, much like how they call
reportFullyDrawn()
to sent the end of time startup for GPC.Ideally, we don't even use this heuristic, but that is a longer term goal that we can't quite do it without some major time investment.
While this is not perfect, p99 should be plenty good enough - with a few false negatives leading to an actual cold start being tracked as a warm start. But that would still be better than the state of the startup traces now.
Testing
Added appropriate tests. I also did some consolidation so there is less repeats in the tests.