-
Notifications
You must be signed in to change notification settings - Fork 135
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-1218 App going background stops active RUM view #479
RUMM-1218 App going background stops active RUM view #479
Conversation
if lastActiveAppVC != nil { | ||
return | ||
} |
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.
What if the lastActiveAppVC
is not nil
but doesn't match the lastStartedViewController
? When the app comes back in background, won't you be starting the wrong RUM View ?
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.
Also, I'm wondering if we need the lastActiveAppVC
property at all. As far as I can see, we either set it to lastStartedViewController
or to nil
, so can't we simply do:
- if the app goes to background: stop
lastStartedViewController
, - when it goes to foreground: start
lastStartedViewController
?
If there's sth special about lastActiveAppVC
that I miss, I think it's worth adding it in the property comment.
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.
NotificationCenter.default.post(name: UIApplication.willResignActiveNotification, object: nil) | ||
} | ||
dateProvider.advance(bySeconds: 1) | ||
for _ in 0..<3 { |
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.
It's quite unclear why we call it 3 times - I guess it's just for sanity, no? Maybe it's worth expressing somehow (either with an inline comment or by labelling 3
with a named variable).
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.
removed ✅
if lastActiveAppVC != nil { | ||
return | ||
} |
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.
Also, I'm wondering if we need the lastActiveAppVC
property at all. As far as I can see, we either set it to lastStartedViewController
or to nil
, so can't we simply do:
- if the app goes to background: stop
lastStartedViewController
, - when it goes to foreground: start
lastStartedViewController
?
If there's sth special about lastActiveAppVC
that I miss, I think it's worth adding it in the property comment.
Implementation simplified
UIApplication notifications are listened in two places Unit tests of both can be running at the same time That leads to flaky or crashing tests Now those places listen to different NotificationCenters in unit tests
cbd0491
to
e2ddf1d
Compare
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.
LG 👌
What and why?
When the app goes to background, technically there is no active view. Previous behavior didn't match that.
How?
When the app goes to background (by resigning active)
UIKitRUMViewsHandler
stops the last started RUM view and keeps a weak reference to it.When the app comes back to foreground (IOW when it does become active)
UIKitRUMViewsHandler
re-starts that view.Review checklist