Skip to content

Use the draw complete time for missing activity init timestamps#2121

Merged
bidetofevil merged 1 commit intomainfrom
hho/app-startup-activity-init-cap
Apr 25, 2025
Merged

Use the draw complete time for missing activity init timestamps#2121
bidetofevil merged 1 commit intomainfrom
hho/app-startup-activity-init-cap

Conversation

@bidetofevil
Copy link
Contributor

@bidetofevil bidetofevil commented Apr 24, 2025

Goal

Activity init events might not be processed when the onDraw event fires because the latter jumps in front of the main thread handler queue. In these rare cases, use that timestamp in place of the activityInit timestamps.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 24, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@bidetofevil bidetofevil marked this pull request as ready for review April 24, 2025 23:05
@bidetofevil bidetofevil requested a review from a team as a code owner April 24, 2025 23:05
@@ -272,15 +272,30 @@ internal class AppStartupTraceEmitter(
val startupService = startupServiceProvider() ?: return
val sdkInitEndMs = startupService.getSdkInitEndMs()
if (sdkInitEndMs != null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main change. Everything else is renaming the callback method to be more appropriate

@codecov
Copy link

codecov bot commented Apr 24, 2025

Codecov Report

Attention: Patch coverage is 80.95238% with 4 lines in your changes missing coverage. Please review.

Project coverage is 85.35%. Comparing base (71fe19c) to head (d04bb37).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...internal/capture/startup/AppStartupTraceEmitter.kt 88.88% 0 Missing and 2 partials ⚠️
...ndroid/embracesdk/internal/ui/FirstDrawDetector.kt 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2121      +/-   ##
==========================================
+ Coverage   85.33%   85.35%   +0.01%     
==========================================
  Files         470      470              
  Lines       10578    10590      +12     
  Branches     1564     1565       +1     
==========================================
+ Hits         9027     9039      +12     
+ Misses        870      869       -1     
- Partials      681      682       +1     
Files with missing lines Coverage Δ
...android/embracesdk/internal/ui/DrawEventEmitter.kt 62.50% <ø> (ø)
...bracesdk/internal/ui/HandlerMessageDrawDetector.kt 87.50% <100.00%> (ø)
...internal/capture/startup/AppStartupTraceEmitter.kt 86.05% <88.88%> (+0.34%) ⬆️
...ndroid/embracesdk/internal/ui/FirstDrawDetector.kt 42.85% <0.00%> (ø)

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

} else {
startupActivityResumedMs
}
val activityInitStartMs = cappedBy(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really to deal with the activityInit end event being missing, which is fired on onStarted() fires.

I am not sure if the init start event will ever be missing - for the Activity onCreate() callback to be processed after the draw, but I am handling this case just in case. After this is released, we can detect whether we have zero-duration child spans for activity init to see if it actually happens.

Copy link
Member

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor Author

bidetofevil commented Apr 25, 2025

Merge activity

  • Apr 25, 10:31 AM EDT: A user started a stack merge that includes this pull request via Graphite.
  • Apr 25, 10:32 AM EDT: Graphite rebased this pull request as part of a merge.
  • Apr 25, 12:02 PM EDT: Graphite rebased this pull request as part of a merge.
  • Apr 25, 12:20 PM EDT: @bidetofevil merged this pull request with Graphite.

@bidetofevil bidetofevil force-pushed the hho/app-startup-activity-init-cap branch from e200178 to 953dc60 Compare April 25, 2025 14:31
@bidetofevil bidetofevil force-pushed the hho/app-startup-activity-init-cap branch from 953dc60 to d04bb37 Compare April 25, 2025 16:01
@bidetofevil bidetofevil merged commit 1404ba3 into main Apr 25, 2025
12 checks passed
@bidetofevil bidetofevil deleted the hho/app-startup-activity-init-cap branch April 25, 2025 16:20
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