2017-09-25 47 views
8

升級到了XCode 9後,我suddently收到以下警告,當我跑我的應用程序:呼籲背景UI API線程com.google.Maps.LabelingBehavior

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)" 

我可以縮小它的問題發生當我將地圖分配給我的視圖時。

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

這是我可以解決的問題還是它在Google地圖中?歡呼聲

+0

莫非你添加你的代碼? –

+0

@IvanSmetanin完成 – Recusiwe

+1

問題出在Google Maps SDK。你必須等到他們更新他們的sdk :( – Siyavash

回答

2

問題出在Google庫中。

如果你不想要這種警告,你可以禁用Scheme選項中的Main Thread Checker。

轉到Product > Scheme > Manage Schemes搜索您用於測試的計劃,並按Edit...左側邊欄中按Run,然後去Diagnostics,並取消Main Thread Checker複選框。

這只是一個暫時的解決方案,如果你不想要這些警告。我不建議這樣做,因爲你可能會引入錯誤,如果後臺線程中調用UI

如果你有測試你應該在Test選項來禁用該複選框,因爲我在Xcode 9, iOS 11, XCUITest failure: Main Thread Checker Flurry Analytics解釋的。如果你不想測試碰撞

+0

因此,當Google進行更新時,基本上我可以關閉警告並重新啓用它們嗎? – Recusiwe

+0

是的,但是如果您玩過很多線程和UIKit,最好打開警告以避免奇怪的行爲,我建議您讓主動在'Run'中禁用,並在'Test'中禁用,直到Google更新它。 –

+0

我可以將這個問題的應用程序推送到App Store嗎?它似乎沒有破壞應用程序中的任何內容 – Recusiwe