firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

Xcode 9 - Main Thread Sanitizer

Open ivanbruel opened this issue 9 years ago • 29 comments

[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()

ivanbruel avatar Jun 06 '17 13:06 ivanbruel

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

google-oss-bot avatar Jun 06 '17 13:06 google-oss-bot

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.

eneko avatar Jun 06 '17 18:06 eneko

Same issue here! Running Xcode 9 on iOS 11.

blackhattristar avatar Jun 09 '17 00:06 blackhattristar

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.

paulb777 avatar Jun 09 '17 00:06 paulb777

You're awesome. Thank you!

blackhattristar avatar Jun 09 '17 00:06 blackhattristar

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

My CI / Tests are failing right now.

stevejcox avatar Jun 23 '17 17:06 stevejcox

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

paulb777 avatar Jun 23 '17 18:06 paulb777

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.

stevejcox avatar Jun 23 '17 18:06 stevejcox

+1

liufsd avatar Jun 28 '17 06:06 liufsd

☝️

jimmymlu avatar Jun 29 '17 16:06 jimmymlu

Thanks everyone for the feedback.

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

paulb777 avatar Jun 29 '17 17:06 paulb777

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

steipete avatar Jul 04 '17 17:07 steipete

@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.

paulb777 avatar Jul 04 '17 19:07 paulb777

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

groovz avatar Sep 12 '17 09:09 groovz

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.

paulb777 avatar Sep 12 '17 14:09 paulb777

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

ZhengXueNing avatar Sep 21 '17 09:09 ZhengXueNing

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

Sea-Eagle avatar Sep 21 '17 13:09 Sea-Eagle

How to handle this issue like try catch

Sea-Eagle avatar Sep 21 '17 13:09 Sea-Eagle

@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.

paulb777 avatar Sep 21 '17 13:09 paulb777

Sure I will check and update

Sea-Eagle avatar Sep 21 '17 14:09 Sea-Eagle