After upgrading to XCode 9 I suddently get the following warning when I run my app:
Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 15473, TID: 773864, Thread name: com.google.Maps.LabelingBehavior, Queue name: com.apple.root.default-qos.overcommit, QoS: 21
Backtrace:
4 App 0x000000010b8ee524 GMSIsApplicationInBackground + 53
5 App 0x000000010b8dc77a -[GMSForegroundDispatchQueue initWithName:targetQueue:] + 269
6 App 0x000000010b9bc5ee _ZN7gmscore6vector4text8GlyphSetC2ERKNS_4base10reffed_ptrINS0_16TextureAtlasPoolEEEPU28objcproto17OS_dispatch_queue8NSObjectPK8__CTFontff + 344
7 App 0x000000010b9bba58 _ZN7gmscore6vector4text10GlyphCache11GetGlyphSetEPK8__CTFontf + 214
8 App 0x000000010b9b950e _ZN7gmscore6vector4text6GLText14PrefetchGlyphsERKNS_4base10reffed_ptrINS1_10GlyphCacheEEERKNSt3__16vectorItNS9_9allocatorItEEEEPK8__CTFontf + 22
9 App 0x000000010b9b9611 _ZN7gmscore6vector4text6GLText14PrefetchGlyphsERKNS_4base10reffed_ptrINS1_10GlyphCacheEEEPK8__CTLinebf + 207
10 App 0x000000010b9112df _ZN7gmscore6vector12GLPointLabel22PrefetchGlyphsForGroupEPNS0_12GLLabelGroupE + 181
11 App 0x000000010b911207 _ZN7gmscore6vector12GLPointLabel14PrefetchGlyphsEv + 33
12 App 0x000000010b98022a _ZN7gmscore6vector16LabelingBehavior23CreatePendingOperationsERKNSt3__13setINS_4base10reffed_ptrINS0_7GLLabelEEENS2_4lessIS7_EENS2_9allocatorIS7_EEEESE_SE_NS0_13LabelDrawModeE + 1096
13 App 0x000000010b97fb9d _ZN7gmscore6vector16LabelingBehavior14RunLabelingJobERKNS_4base10reffed_ptrINS1_11LabelingJobEEE + 357
14 App 0x000000010b97fa2a ___ZN7gmscore6vector16LabelingBehavior14CommitInternalEPNS_8renderer14EntityRendererE_block_invoke + 22
15 Foundation 0x0000000110bb0948 __NSThreadPerformPerform + 334
16 CoreFoundation 0x00000001117af2b1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
17 CoreFoundation 0x000000011184ed31 __CFRunLoopDoSource0 + 81
18 CoreFoundation 0x0000000111793c19 __CFRunLoopDoSources0 + 185
19 CoreFoundation 0x00000001117931ff __CFRunLoopRun + 1279
20 CoreFoundation 0x0000000111792a89 CFRunLoopRunSpecific + 409
21 Foundation 0x0000000110b6ae5e -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 274
22 App 0x000000010b9bace5 -[GMSx_GTMSimpleWorkerThread main] + 337
23 Foundation 0x0000000110b788ac __NSThread__start__ + 1197
24 libsystem_pthread.dylib 0x000000011323393b _pthread_body + 180
25 libsystem_pthread.dylib 0x0000000113233887 _pthread_body + 0
26 libsystem_pthread.dylib 0x000000011323308d thread_start + 13
Error Domain=kCLErrorDomain Code=0 "(null)"
I can narrow it down to the problem happens when I assign the map to my view.
override func viewDidLoad() {
super.viewDidLoad()
UIApplication.shared.isIdleTimerDisabled = true
GPSManager.instance.startGPS()
setupLayout()
map = GMSMapView.map(withFrame: CGRect.zero, camera: getCamera(location: initialLocation, zoom: 10))
map.mapType = .hybrid
map.delegate = self
map.settings.consumesGesturesInView = false
self.view.addSubview(map) <-- This is where is goes wrong
self.view.sendSubview(toBack: map)
configureMenus()
}
Is this something I can fix or is it inside Google Maps? Cheers
The problem is inside the Google library.
If you don't want this kind of warning you can disable Main Thread Checker inside the Scheme options.
Go Product > Scheme > Manage Schemes
search the Scheme you use for your tests and press Edit...
in the left sidebar press Run
and then go to Diagnostics
and uncheck Main Thread Checker
checkbox.
This is only a temporal solution if you don't want these warnings. I do not recommend it because you could introduce bugs if call UI inside a background thread
If you have test you should disable the checkbox in Test
option as I explained in Xcode 9, iOS 11, XCUITest failure: Main Thread Checker Flurry Analytics if you do not want the tests crash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With