-
Notifications
You must be signed in to change notification settings - Fork 134
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
RUMM-1615 Allow launch time earlier than UIApplicationDidBecomeActiveNotification
#642
RUMM-1615 Allow launch time earlier than UIApplicationDidBecomeActiveNotification
#642
Conversation
In terms of testing, I could apply a change in |
43411cc
to
30b4afc
Compare
@@ -311,7 +311,7 @@ internal class RUMViewScope: RUMScope, RUMContextProvider { | |||
crash: nil, | |||
error: nil, | |||
id: dependencies.rumUUIDGenerator.generateUnique().toRUMDataFormat, | |||
loadingTime: dependencies.launchTimeProvider.launchTime?.toInt64Nanoseconds, | |||
loadingTime: dependencies.launchTimeProvider.launchTime.toInt64Nanoseconds, |
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.
There are two things I'm concerned about:
- The new "lazy" aspect of
.launchTime
API makes it slightly dangerous. It's easy to imagine introducing a bug by calling it somewhere earlier in the stack which will skew the measurement. Seems hard to cover this in tests. - Using
launchTimeProvider.launchTime
to stop measurement inRUMViewScope
skews the real measurement by the time ofqueue.async {}
used to run RUM "start view" command.
What's our take on the above? Is there any alternative we can consider 🤔 💭?
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.
The new "lazy" aspect of
.launchTime
API makes it slightly dangerous.
The launchTime
property is not lazy but computed, calling it earlier in the stack won't stop measuring the UIApplicationDidBecomeActiveNotification
. It's applying a fallback in case the UIApplicationDidBecomeActiveNotification
has not yet been reached.
Though, It is true that UIApplicationDidBecomeActiveNotification
could be triggered by the time it reaches queue.async { }
, even if queue
has a .userInteractive
qos, it's part of another scope.
Another approach would be to respond to the following notifications:
UIWindowDidBecomeVisibleNotification
UIApplicationDidFinishLaunchingNotification
UIApplicationDidBecomeActiveNotification
And then report the last notification received 🤔
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.
Another approach would be to respond to the following notifications (...)
Or we could add our own notification, sent from RUMMonitor.startView()
, but this sounds like adding cruft...
The
launchTime
property is not lazy but computed (...). It's applying a fallback
I totally missed that .launchTime
is computed now. This mitigates the first point on my list 👍.
Maybe the queue.async {}
impact is not that significant as it will be uniformly added to all measurements for the same scenario. @maxep @buranmert ?
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.
Yes, I don't think the async
process will have an impact on the reported time. IMO, this is the minimal change we can apply and it preserve from regressions.
What and why?
This PR is a proposal on allowing sending the
application_start
action with aloading_time
value before the application has become active.The SDK measures the Application launch time from the time the application process starts until when it is responsive and accepts touch events. This is performed by responding to
UIApplicationDidBecomeActiveNotification
.In case the RUM monitor receives the first
startView
command before the application has become active, theapplication_start
action event is recorded without aloading_time
. This will be the case when invokingstartView
manually from theUIViewController.viewWillAppear
or fromSwiftUI.View.onAppear
for instance.In this proposal, we make sure to always return a Launch Time when requested, by either returning the time to become active (as before) or the time to receive the first
startView
command.How?
The
__dd_private_AppLaunchTime
function now returns the time from start until 'now' if theUIApplicationDidBecomeActiveNotification
has not yet been received.To reflect this change, the
LaunchTimeProviderType
now expect a non-optionallaunchTime
.Review checklist