-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix app start trace outliers from network delays (#10733) #15409
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
base: main
Are you sure you want to change the base?
Conversation
@visumickey @eBlender Draft pull request While I test |
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.
Code Review
This pull request aims to fix outliers in app start traces caused by network delays or other interruptions by introducing a 'reasonable' timeout (30 seconds) after which the app start trace is cancelled. The changes include replacing a static flag with an instance property for better state management and modifying the trace completion logic.
My review focuses on improving code clarity and simplifying the asynchronous execution. I've suggested removing a piece of uncertain-looking comment and simplifying a nested dispatch_async
call that adds unnecessary complexity. The core logic for cancelling long-running app start traces appears sound and should address the reported issue.
FirebasePerformance/Sources/AppActivity/FPRAppActivityTracker.m
Outdated
Show resolved
Hide resolved
FirebasePerformance/Sources/AppActivity/FPRAppActivityTracker.m
Outdated
Show resolved
Hide resolved
/gemini review |
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.
Code Review
This pull request introduces several improvements to fix outliers in the _app_start
metric, particularly those caused by network delays or background launches. The changes include detecting background launches to invalidate the app start time, and introducing a 30-second 'reasonable' duration limit to cancel excessively long app start traces instead of reporting them. The code quality is also improved by converting a static variable to an instance property and ensuring traces are properly cancelled. The overall approach is solid and effectively addresses the stated issues. I have a couple of minor suggestions to improve code comments.
FirebasePerformance/Sources/AppActivity/FPRAppActivityTracker.m
Outdated
Show resolved
Hide resolved
FirebasePerformance/Sources/AppActivity/FPRAppActivityTracker.m
Outdated
Show resolved
Hide resolved
FirebasePerformance/Sources/AppActivity/FPRAppActivityTracker.m
Outdated
Show resolved
Hide resolved
FirebasePerformance/Sources/AppActivity/FPRAppActivityTracker.m
Outdated
Show resolved
Hide resolved
FirebasePerformance/Sources/AppActivity/FPRAppActivityTracker.m
Outdated
Show resolved
Hide resolved
@visumickey Done Now my fix only addresses the static variable bug that prevented multiple app launches from being measured (original static var TTIStageStarted could last until the end of the app life cycle vs the new instance var appStartTraceCompleted named like that to not confuse it with the stages concepts we want to avoid), I removed the aggressive timing reduction and I addressed the logs (I hope in the right manner, or If I need to add constants for these LMK) and I add the ability to detect background launches |
FirebasePerformance/Sources/AppActivity/FPRAppActivityTracker.m
Outdated
Show resolved
Hide resolved
FirebasePerformance/Sources/AppActivity/FPRAppActivityTracker.m
Outdated
Show resolved
Hide resolved
FirebasePerformance/Sources/AppActivity/FPRAppActivityTracker.m
Outdated
Show resolved
Hide resolved
FirebasePerformance/Sources/AppActivity/FPRAppActivityTracker.m
Outdated
Show resolved
Hide resolved
@visumickey ready for review, and nit picks addressed |
WIP!!! - Fix app start trace outliers from network delays (#10733)
Discussion
Fix _app_start outliers mentioned in #10733 (Still Draft, Work In Progress Ongoing testing, seems good)
User Statements:
Long time reported in the _app_start metric in the 90 to 95 percentile of data in firebase console (up to 1000+ Seconds)
Issues seems to be appearing from background tasks that kick in the activity and ends until the first run loop runs successfully
Some reports have mentioned been able to have long _app_star metric when app launch is interrupted (Via locking the device or receiving a phone call)
What this fixes? (My possible reproduction ideas on why this is happening):
Case 1 - Spotty network right at cold launch
Case 2 - Targeted failures for early endpoints (e.g. Like if your App depended on many endpoints to launch and one of them was down)
Case 3 - Background launch before foreground
Case 4 - Sature GDC Workers to limit the available thread pool
Testing
API Changes