Skip to content

Fix main thread crashing issue, reenable tests. #3974

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 5 commits into from
Oct 2, 2019

Conversation

ryanwilson
Copy link
Member

Checking applicationState while not on the main thread results in a crash. Revert to using notifications and a flag to track this, but with a single source of truth.

Fixes #3973.

@ryanwilson ryanwilson requested review from mikehaney24, paulb777 and maksymmalyhin and removed request for mikehaney24 October 2, 2019 16:15
Copy link
Contributor

@maksymmalyhin maksymmalyhin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -37,6 +37,13 @@ BOOL GDTCORReachabilityFlagsContainWWAN(SCNetworkReachabilityFlags flags) {
#endif // TARGET_OS_IOS
}

@interface GDTCORApplication () {
/** Private flag to match the existing `readonly` public flag. */
BOOL _isRunningInBackground;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't write it from different threads (only read), but it may make sense to add volatile just in case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or declare it as an atomic property (which is a bit more common way to declare thread-safe variables)

Comment on lines -111 to +112
[notifCenter postNotificationName:kGDTCORApplicationDidEnterBackgroundNotification object:nil];
[notifCenter postNotificationName:UIApplicationDidEnterBackgroundNotification object:nil];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change from the abstracted notification to an iOS-specific one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We previously used the abstract one because it triggered each classes' foreground/background flags, but now since the flag moved it's set before the abstracted notification is fired. Meaning: the abstract notification no longer triggers the flag to change, only the iOS specific one does.

@ryanwilson ryanwilson merged commit 4c4ba12 into master Oct 2, 2019
@ryanwilson ryanwilson deleted the rw-gdt-background-mainthread branch October 2, 2019 19:10
schmidt-sebastian pushed a commit that referenced this pull request Oct 2, 2019
* Fix main thread crashing issue, reenable tests.

* Added log, extra check for event generation to prevent early exit.

* Temporarily run cron tests for travis.

* Revert travis.yml update

* Change property to atomic based on review comments.
@firebase firebase locked and limited conversation to collaborators Nov 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Re-enable GDT Background Tests
5 participants