Firebase-ios-sdk: Xcode 9 - Main Thread Sanitizer

Created on 6 Jun 2017  路  29Comments  路  Source: firebase/firebase-ios-sdk

[READ] Step 1: Are you in the right place?

Yes

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 9.0 beta (9M136h)
  • Firebase SDK version: 4.0.0
  • Library version: 4.0.0
  • Firebase Product: analytics, core

[REQUIRED] Step 3: Describe the problem

Xcode 9 seems to be reporting a lot of Firebase calls to UIApplication properties. Even though the UI is not being updated this is particularly cumbersome due to the extension of logs it produces on a default environment.

=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication delegate]
PID: 740, TID: 51958, Thread name: (none), Queue name: FIRAnalyticsQueue, QoS: 9
Backtrace:
4   UnbabelMobile                       0x0000000101246448 __38+[FIRAnalytics createAppDelegateProxy]_block_invoke + 56
5   libdispatch.dylib                   0x0000000104751614 _dispatch_client_callout + 16
6   libdispatch.dylib                   0x0000000104752368 dispatch_once_f + 120
7   UnbabelMobile                       0x00000001012449d4 __47+[FIRAnalytics startWithConfiguration:options:]_block_invoke_2 + 104
8   libdispatch.dylib                   0x0000000104751654 _dispatch_call_block_and_release + 24
9   libdispatch.dylib                   0x0000000104751614 _dispatch_client_callout + 16
10  libdispatch.dylib                   0x0000000104761008 _dispatch_queue_serial_drain + 716
11  libdispatch.dylib                   0x0000000104754e58 _dispatch_queue_invoke + 340
12  libdispatch.dylib                   0x00000001047621c4 _dispatch_root_queue_drain_deferred_wlh + 412
13  libdispatch.dylib                   0x00000001047697fc _dispatch_workloop_worker_thread + 868
14  libsystem_pthread.dylib             0x00000001aa6e71e8 _pthread_wqthread + 924
15  libsystem_pthread.dylib             0x00000001aa6e6e40 start_wqthread + 4
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 740, TID: 51959, Thread name: (none), Queue name: com.google.fira.worker, QoS: 9
Backtrace:
4   UnbabelMobile                       0x0000000101244384 FIRAIsAppActive + 56
5   UnbabelMobile                       0x0000000101243830 -[FIRASessionReporter shouldStartNewSession] + 24
6   UnbabelMobile                       0x00000001012433d4 -[FIRASessionReporter initWithPersistedConfig:] + 284
7   UnbabelMobile                       0x000000010122f0bc __48-[FIRAMeasurement startMeasurementOnWorkerQueue]_block_invoke + 1828
8   libdispatch.dylib                   0x0000000104751614 _dispatch_client_callout + 16
9   libdispatch.dylib                   0x0000000104752368 dispatch_once_f + 120
10  UnbabelMobile                       0x000000010122e97c -[FIRAMeasurement startMeasurementOnWorkerQueue] + 268
11  UnbabelMobile                       0x000000010122e748 -[FIRAMeasurement setEnabledOnWorkerQueue:] + 124
12  UnbabelMobile                       0x000000010124304c __52-[FIRAScheduler scheduleOnWorkerQueueBlockID:block:]_block_invoke + 44
13  libdispatch.dylib                   0x0000000104751654 _dispatch_call_block_and_release + 24
14  libdispatch.dylib                   0x0000000104751614 _dispatch_client_callout + 16
15  libdispatch.dylib                   0x0000000104761008 _dispatch_queue_serial_drain + 716
16  libdispatch.dylib                   0x0000000104754e58 _dispatch_queue_invoke + 340
17  libdispatch.dylib                   0x00000001047621c4 _dispatch_root_queue_drain_deferred_wlh + 412
18  libdispatch.dylib                   0x00000001047697fc _dispatch_workloop_worker_thread + 868
19  libsystem_pthread.dylib             0x00000001aa6e71e8 _pthread_wqthread + 924
20  libsystem_pthread.dylib             0x00000001aa6e6e40 start_wqthread + 4

Steps to reproduce:

Compile an app which uses the Analytics platform and configure the FirebaseApp.

Relevant Code:

FirebaseApp.configure()
bug

Most helpful comment

Acknowledged. The issue is in a closed source part of Firebase and we're actively working on the fix.

I'll keep this Issue updated with the status.

All 29 comments

Hey there! I couldn't figure out what this issue is about, so I've labeled it for a human to triage. Hang tight.

Same problem here:

=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication delegate]
PID: 92687, TID: 25540441, Thread name: (none), Queue name: FIRAnalyticsQueue, QoS: 9
Backtrace:
4   MindBodyPOS-Develop                 0x0000000104254faf __38+[FIRAnalytics createAppDelegateProxy]_block_invoke + 55
5   libdispatch.dylib                   0x000000010ed9c6c8 _dispatch_client_callout + 8
6   libdispatch.dylib                   0x000000010ed9dc6e dispatch_once_f + 285
7   MindBodyPOS-Develop                 0x000000010425345e __47+[FIRAnalytics startWithConfiguration:options:]_block_invoke_2 + 101
8   libdispatch.dylib                   0x000000010ed9b6dd _dispatch_call_block_and_release + 12
9   libdispatch.dylib                   0x000000010ed9c6c8 _dispatch_client_callout + 8
10  libdispatch.dylib                   0x000000010eda5217 _dispatch_queue_serial_drain + 1272
11  libdispatch.dylib                   0x000000010eda5c6c _dispatch_queue_invoke + 342
12  libdispatch.dylib                   0x000000010eda8ef4 _dispatch_root_queue_drain + 783
13  libdispatch.dylib                   0x000000010eda8b82 _dispatch_worker_thread4 + 54
14  libsystem_pthread.dylib             0x000000010f1835a2 _pthread_wqthread + 1299
15  libsystem_pthread.dylib             0x000000010f18307d start_wqthread + 13

Seems to be an issue related to either the AppDelegate proxy or updating the network activity indicator from a background thread.

Same issue here! Running Xcode 9 on iOS 11.

Acknowledged. The issue is in a closed source part of Firebase and we're actively working on the fix.

I'll keep this Issue updated with the status.

You're awesome. Thank you!

Hi there. Just checking on whether there is an ETA on this one?

My CI / Tests are failing right now.

We're testing a fix that is targeted for the next Firebase patch update. I'll follow up here when it's available.

Thanks @paulb777.

Quick note for those that are finding tests failing, note that iOS 11 is crashing on this error. Switching Tests back to iOS 10.2 or 10.3 stops tests failing unnecessarily.

+1

鈽濓笍

Thanks everyone for the feedback.

We just released Firebase 4.0.3 that fixes the main thread sanitizer issue.

But where? https://firebase.google.com/download/ios goes to 4.0.2

@steipete Sorry about the delay. The CocoaPod was updated when I posted but the zipfile update was delayed. It's now fixed and https://firebase.google.com/download/ios now goes to 4.0.3.

which pod should I use to get this updated version with the fix?

Unless there is a special reason to use an old version, you should update to the current Firebase 4.1.1.

This particular fix released in FirebaseAnalytics 4.0.2, which was included with the Firebase 4.0.3 release.

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'

use_frameworks!

target 'MiddleEast' do
pod 'Firebase/Core'
pod 'Firebase/Messaging'
end
@paulb777 Hello, I am through the above Podfile file update, but CocoaPod inside automatically updated Firebase is 3.17.0 version, which is why?

image

I'm facing same issue,

Using AFNetworking (3.1.0)
Using Branch (0.18.8)
Using CardIO (5.4.1)
Using Crashlytics (3.8.6)
Using Fabric (1.6.13)
Using Firebase (3.17.0)
Using FirebaseAnalytics (3.9.0)
Using FirebaseCore (3.6.0)
Using FirebaseInstanceID (1.0.10)
Using FirebaseMessaging (1.2.3)
Using GTMOAuth2 (1.1.5)
Using GTMSessionFetcher (1.1.11)
Using Google (3.1.0)
Using GoogleSignIn (4.1.0)
Using GoogleToolboxForMac (2.1.1)
Using KontaktSDK (1.4.4)

Here the pods im using

Xcode 9
iOS 11

How to handle this issue like try catch

@ZhengXueNing @Sea-Eagle Make sure you run pod repo update before pod update to get the latest available pods.

If that doesn't work, it's likely that you have a another pod in your Podfile that depends upon Firebase 3.x and doesn't support Firebase 4.x. In particular, @Sea-Eagle, it looks like you're using the Google pod which has been deprecated. See https://stackoverflow.com/questions/44538472/cocoapods-ios-google-has-been-deprecated-how-to-get-rid-of-the-warning

If you're still stuck, create a question on stackoverflow and include the contents of your Podfile.

Sure I will check and update

How can handle this issue I want to just skip this if I got any error how can I do that try catch not working

Here is My new pod update
Last login: Thu Sep 21 20:02:48 on ttys000 User$ pod update Update all pods Updating local specs repositories $ /usr/bin/git -C /Users/.cocoapods/repos/master fetch origin --progress remote: Counting objects: 9, done. remote: Compressing objects: 100% (9/9), done. remote: Total 9 (delta 6), reused 0 (delta 0), pack-reused 0 From https://github.com/CocoaPods/Specs 7cf3745c74a..b418e34e7ae master -> origin/master $ /usr/bin/git -C /Users/.cocoapods/repos/master rev-parse --abbrev-ref HEAD master $ /usr/bin/git -C /Users/.cocoapods/repos/master reset --hard origin/master HEAD is now at b418e34e7ae [Add] QMServices 0.5.2 Analyzing dependencies Removing Google Downloading dependencies Using AFNetworking (3.1.0) Using Branch (0.18.8) Using CardIO (5.4.1) Using Crashlytics (3.8.6) Using Fabric (1.6.13) Installing Firebase 4.2.0 (was 3.17.0) Installing FirebaseAnalytics 4.0.3 (was 3.9.0) Installing FirebaseCore 4.0.7 (was 3.6.0) Installing FirebaseInstanceID 2.0.3 (was 1.0.10) Installing FirebaseMessaging 2.0.3 (was 1.2.3) Using GTMOAuth2 (1.1.5) Using GTMSessionFetcher (1.1.11) Using GoogleSignIn (4.1.0) Using GoogleToolboxForMac (2.1.1) Using KontaktSDK (1.4.4) Using LJAutoScrollView (1.0.1) Using MBProgressHUD (1.0.0) Using Protobuf (3.4.0) Using Reachability (3.2) Using SCNetworkReachability (2.0.5) Using SDWebImage (4.1.0) Using STPopup (1.8.2) Using Stripe (11.3.0) Using YLProgressBar (3.10.1) Using libPhoneNumber-iOS (0.9.10) Using macros_blocks (0.0.1) Installing nanopb (0.3.8) Generating Pods project Integrating client project Sending stats Pod installation complete! There are 18 dependencies from the Podfile and 27 total pods installed.

The issue is changed to

[Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add [FIRApp configure]; (FirebaseApp.configure() in Swift) to your application initialization. Read more: https://goo.gl/ctyzm8.

I'm already doing in a method

if([FIRApp defaultApp] == nil){
    [FIRApp configure];
}

I got it. As someone said before - it's all about dependencies. After few hours I changed
pod 'Google/Analytics' to pod 'GoogleAnalytics'
and Google/SignIn it will be GoogleSignIn
then
pod install
pod update
and finally I'v got:
Installing Firebase 4.2.0 (was 3.17.0)

We only use Firebase Core, and changing the Podfile from pod 'Firebase/Core' to 'pod FirebaseCore' has worked to update it.

@markostt, @lsalvoni thanks for sharing. This what helped me:

- pod 'Google/SignIn'
+ pod 'GoogleSignIn'
- pod 'Firebase/Core'
+ pod 'FirebaseCore'
- pod 'Firebase/Messaging'
+ pod 'FirebaseMessaging'

I'm using

pod 'FirebaseDatabase'
pod 'FirebaseStorage'
pod 'FirebaseCore'
pod 'FirebaseAuth'

And still stuck with the issue. Even after repo update and pod update.

Using FacebookCore (0.2.0)
Using FacebookLogin (0.2.0)
Using FirebaseAnalytics (4.0.3)
Using FirebaseAuth (4.2.0)
Using FirebaseCore (4.0.7)
Using FirebaseDatabase (4.0.3)
Using FirebaseInstanceID (2.0.3)
Using FirebaseStorage (2.0.2)

There was a fix to a similar issue addressed here. It seems there is another related issue on the current release, tracked at #310.

Was this page helpful?
0 / 5 - 0 ratings