-
Notifications
You must be signed in to change notification settings - Fork 27
SwiftUI View Tracing #230
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
Merged
Merged
SwiftUI View Tracing #230
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dependency ReviewThe following issues were found:
License IssuesPackage.resolved
OpenSSF Scorecard
Scanned Files
|
Generated by 🚫 Danger Swift against 63929b6 |
668c304 to
1154c25
Compare
ArielDemarco
reviewed
May 6, 2025
ArielDemarco
reviewed
May 6, 2025
ArielDemarco
reviewed
May 6, 2025
f8f3373 to
3f30d07
Compare
fnewberg
reviewed
May 14, 2025
13e4e81 to
05315c9
Compare
011c9e6 to
7137ba5
Compare
4db1532 to
0ebdc70
Compare
2c9f70d to
f1e8fa9
Compare
9674722 to
8d2f63c
Compare
ArielDemarco
approved these changes
Jun 18, 2025
55c7aa0 to
1c7281f
Compare
1c7281f to
2feaa94
Compare
NachoEmbrace
approved these changes
Jun 24, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
SwiftUI View Instrumentation
This document states the current implementation of SwiftUI View tracing.
PR: #230
The render loop
On iOS, the system for getting anything from the users code to the screen is called the render loop. It consists of a few parts, some we have control over and others we don’t. The important part is that the render loop refresh rate is pre-determined, but can change at runtime based on the state of the device. Usually, it’s 60hz which ends up being 16ms, called the frame deadline. If we miss the frame deadline, we have what is called a hitch since the system needs to wait another frame to put our content on screen.
Embrace View Instrumentation
Render Loop: The duration from the first instrumented body in a render loop to the next tick of the run loop. This is a root trace.
Time To First Render: The duration from the first time the OS initializes this View until the first time it appears on screen. This is a root trace.
Time To First Content Complete: The duration from the first time the OS initializes this View until the first time the user flags the content as complete. This is a root trace.
Example
Only the Photo surface is instrumented.
Session as a Gantt chart:
SwiftUI Performance Gantt Chart.pdf
Session in Embrace Dash:
https://dash.embrace.io/app/wnrhv/grouped_sessions/last_1_hour/54F35B20EF7C41F5ADC0668C1F34DA63/8192029933B74B9896ADD165F48C45A7@/8192029933B74B9896ADD165F48C45A7?first=9C393D0FBD3740E38DC28F60C4496358&last=2D3323E6C2FE479D867903D2C70BF2EB&source=session
API
Parameters:
Equatablevalue that when changed, will cause thetime to first content completespan to end.View Wrapper
View Modifier
Macro. At this time, the macro cannot take any arguments. We may allow this in the future.