Open alexanderthoren opened 1 year ago
Hey @alexanderthoren 👋
Indeed, there is no tracking of view loading time on iOS. The reason being that there is no strict definition of when it starts and when it stops. We are not sure what a view loading time would mean for View Controller, or for SwiftUI.View.
Maybe you could share your use case and we could think of a solution? How do you leverage this value on Android?
Hello @maxep,
In the graph above we can see that when the system function viewDidAppear
is called, the view is actually loaded, or at least presented to the user. We could start a timer on the init
function and stop it in viewDidAppear
to collect that LoadingTime
. What do you think about this approach? 🤔
In Android, in onCreate
function the timer is started and it stops in the onPause
function. Then fun updateViewLoadingTime(key: Any, loadingTimeInNs: Long, type: ViewEvent.LoadingType)
is called.
Hello @alexanderthoren 👋, thank you for more insights. To give you more background, the idea of view.loading_time
originated in our Browser SDK and Monitoring Web Page Performance:
view.loading_time
- Time until the page is ready and no network request or DOM mutation is currently happening.
In web world, this is very valuable metric indicating How long the user has to wait until all content is ready (on a web page)?. It clearly defines its purpose as different teams can work on optimising website resources, scripts, DOM and othear means to make this initial experience arrive earlier (hence they measure and aim at reducing the view.loading_time
).
Measuring UIViewController.init()
to .viewDidAppear()
won't serve similar purpose because such measurement is detached from content being "ready" for the end user. Think for example of a screen that loads gallery of remote images - it might take several seconds until all images are shown to the user, but init()
to .viewDidAppear()
will most likely report 0.2s
which is default duration in VCs transition. Even if images are not remote, but loaded from local bundle, the measurement won't tell anything about their overall loading performance as viewDidAppear()
doesn't await for anything app-specific.
With lack of clear definition for "view loading time" on iOS, we rather promote the API for adding your own performance timing. It can be used to mark the end of app-specific routines, e.g. "all images loaded" or "UI is ready for interaction".
We are currently using Datadog v1.12.0 in iOS with SPM.
In
Android
we can access the parameterLoadingTime
as it is sent to Datadog automatically. IniOS
we are not able to track this automatically, and we found out that the classRUMViewScope
in the functionsendViewUpdateEvent
always sends this parameter asnil
.I am attaching two screenshots, the first one from
Android
and the second one foriOS
.When this will be added to iOS? Is it scheduled for one of the next updates? Thanks! 😄