Firebase-ios-sdk: UI API called from background thread

Created on 16 Jul 2019  路  12Comments  路  Source: firebase/firebase-ios-sdk

  • Xcode version: 10.2.1
  • Firebase SDK version: 6.4.0
  • Firebase Component: Analytics (?)
  • Component version: Firebase/Core (6.4.0), FirebaseAnalytics (= 6.0.3)
  • iOS: 13 beta 2 (not sure if it matters though)

[REQUIRED] Describe the problem

FPRScreenTraceTracker calls -[UIViewController isViewLoaded] on background thread. Setting FirebaseScreenReportingEnabled to NO in Info.plist doesn't help.

Steps to reproduce:

Integrate Firebase and run the app with main thread checker enabled

Main Thread Checker: UI API called on a background thread: -[UIViewController isViewLoaded]
PID: 11103, TID: 1213752, Thread name: (none), Queue name: com.google.FPRScreenTraceTracker, QoS: 0
Backtrace:
4   R                             0x0000000106e1227c -[FPRScreenTraceTracker shouldCreateScreenTraceForViewController:] + 300
5   R                             0x0000000106e11d40 -[FPRScreenTraceTracker startScreenTraceForViewController:currentTotalFrames:currentFrozenFrames:currentSlowFrames:] + 80
6   R                             0x0000000106e11848 __56-[FPRScreenTraceTracker appDidBecomeActiveNotification:]_block_invoke + 200
7   libdispatch.dylib                   0x000000011265986c _dispatch_call_block_and_release + 24
8   libdispatch.dylib                   0x000000011265ac48 _dispatch_client_callout + 16
9   libdispatch.dylib                   0x0000000112661db8 _dispatch_lane_serial_drain + 1248
10  libdispatch.dylib                   0x0000000112662760 _dispatch_lane_invoke + 452
11  libdispatch.dylib                   0x000000011266db6c _dispatch_workloop_worker_thread + 1364
12  libsystem_pthread.dylib             0x00000001aa174f5c _pthread_wqthread + 304
13  libsystem_pthread.dylib             0x00000001aa177aa0 start_wqthread + 8
2019-07-16 14:50:44.703832+0300 R[11103:1213752] [reports] Main Thread Checker: UI API called on a background thread: -[UIViewController isViewLoaded]
PID: 11103, TID: 1213752, Thread name: (none), Queue name: com.google.FPRScreenTraceTracker, QoS: 0
performance

Most helpful comment

@novkostya Thank you for the issue report.

As far as I can see from the code, the method -[UIViewController isViewLoaded] is called dispatch_sync on a background queue, so despite that technically it is called from a background thread, it is synchronized with the UI thread, so should be safe to use as is.

Anyway, we will consider a fix to avoid the main thread checker complaining.

All 12 comments

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@novkostya Thank you for the issue report.

As far as I can see from the code, the method -[UIViewController isViewLoaded] is called dispatch_sync on a background queue, so despite that technically it is called from a background thread, it is synchronized with the UI thread, so should be safe to use as is.

Anyway, we will consider a fix to avoid the main thread checker complaining.

Internally tracked at b/137637765.

My UI is freezing on iOS 13 when [UIViewController isViewLoaded] happens in a thread that isn't the main thread so I think they modified the behaviour and does not just require running in sync with the main thread but completely running on the main thread.

I have the same problem as @Valpertui has.

@exceptioncatcher91 me too.

@Valpertui Is this freezing on the development builds or even on release builds?

Freezes only occur in dev builds from Xcode 10.2.1 sdk 12 targeting iOS 13 devices (device support import trick) and Xcode 11 sdk 13 targeting iOS 13 devices.
When TestFlight builds from Xcode 10.2.1 targeting the SDK 12 are run on an iOS 13 device, the freezes do not occur.

This is fixed and available in the upcoming release.

any update for the upcoming release? @visumickey, we are affected by this quite a bit as it causes a great amount of crashes in our production apps

The upcoming release is planned to happen on August 8th. We are in the final phases of testing.

Thanks for this. I was using 6.5 and was happening quite often. Now on 6.8 haven't encountered it once.

Was this page helpful?
0 / 5 - 0 ratings