Skip to content
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

[PLAT-7208] Fix missing sessions when started in background state #1180

Merged
merged 1 commit into from
Sep 8, 2021

Conversation

nickdowell
Copy link
Contributor

@nickdowell nickdowell commented Sep 7, 2021

Goal

Fix a regression (introduced in release v6.9.5 by #1108) where the session was not captured at launch if Bugsnag was started before willFinishLaunchingWithOptions in iOS apps that do not adopt the UIScene life-cycle.

Overview

If Bugsnag is started early in the app life-cycle, before the app delegate's willFinishLaunchingWithOptions method is called, then applicationState is reported as .background and Bugsnag does not start a session.

In iOS apps that do not adopt the UIScene life-cycle, no willEnterForegroundNotification is posted during launch and consequently no session was being started until the app was resumed from the background state. A didBecomeActiveNotification is posted during launch.

Changeset

The session tracker now starts a session in response to didBecomeActiveNotification as well as willEnterForegroundNotification.

Notification registration logic has been moved to BugsnagSessionTracker to make it more testable.

Testing

Reproduced the issue and verified the fix using a test app.

Added unit test cases to verify that

  • A session is started upon receiving UIApplicationDidBecomeActiveNotification alone
  • Multiple calls to handleAppForegroundEvent do not result in multiple sessions

E2E tests cannot test this because the fixture app cannot start Bugsnag early enough in the app's life-cycle.

@github-actions
Copy link

github-actions bot commented Sep 7, 2021

Infer: No issues found 🎉

OCLint: No issues found 🎉

Bugsnag.framework binary size decreased by 280 bytes from 1,156,400 to 1,156,120 🎉

Generated by 🚫 Danger

@nickdowell nickdowell marked this pull request as ready for review September 7, 2021 13:54
@nickdowell nickdowell merged commit 578811d into next Sep 8, 2021
@nickdowell nickdowell deleted the nickdowell/fix-session-tracking branch September 8, 2021 07:13
@nickdowell nickdowell mentioned this pull request Sep 15, 2021
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