ios-360-videos
ios-360-videos copied to clipboard
updateCameraAngleForCurrentDeviceMotion calls UI API on a background thread
When running the example project on iOS 11.3 with Xcode 9.3, the Main Thread Checker detects that the UI API is called on a background thread instead of the main thread in updateCameraAngleForCurrentDeviceMotion()
and Xcode reports -[UIApplication statusBarOrientation] must be used from main thread only
on https://github.com/NYTimes/ios-360-videos/blob/develop/Sources/NYT360CameraController.m#L109.
After surrounding the code block by dispatch_async(dispatch_get_main_queue(), ^{ ... });
the warning no longer appears.
Main Thread Checker: UI API called on a background thread: -[UIApplication statusBarOrientation]
PID: 6294, TID: 2952262, Thread name: (none), Queue name: com.apple.scenekit.renderingQueue.SCNView0x10bd0c930, QoS: 33
Backtrace:
4 NYT360Video 0x00000001047c9a48 -[NYT360CameraController updateCameraAngleForCurrentDeviceMotion] + 384
5 NYT360Video 0x00000001047c8ea8 -[NYT360ViewController renderer:updateAtTime:] + 116
6 SceneKit 0x0000000196c5af80 <redacted> + 444
7 SceneKit 0x0000000196c5d018 <redacted> + 252
8 SceneKit 0x0000000196c5d69c <redacted> + 84
9 SceneKit 0x0000000196c5daa0 <redacted> + 728
10 SceneKit 0x0000000196d0446c <redacted> + 512
11 SceneKit 0x0000000196bc07dc <redacted> + 56
12 SceneKit 0x0000000196ccd388 <redacted> + 80
13 libdispatch.dylib 0x00000001047e9260 _dispatch_call_block_and_release + 24
14 libdispatch.dylib 0x00000001047e9220 _dispatch_client_callout + 16
15 libdispatch.dylib 0x00000001047f7e80 _dispatch_queue_serial_drain + 768
16 libdispatch.dylib 0x00000001047ec730 _dispatch_queue_invoke + 328
17 libdispatch.dylib 0x00000001047f8dd8 _dispatch_root_queue_drain_deferred_wlh + 352
18 libdispatch.dylib 0x00000001047ffebc _dispatch_workloop_worker_thread + 676
19 libsystem_pthread.dylib 0x0000000182643e70 _pthread_wqthread + 860
20 libsystem_pthread.dylib 0x0000000182643b08 start_wqthread + 4
2018-04-24 16:27:12.053023+0800 NYT360VideoExample[6294:2952262] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication statusBarOrientation]
PID: 6294, TID: 2952262, Thread name: (none), Queue name: com.apple.scenekit.renderingQueue.SCNView0x10bd0c930, QoS: 33
Backtrace:
4 NYT360Video 0x00000001047c9a48 -[NYT360CameraController updateCameraAngleForCurrentDeviceMotion] + 384
5 NYT360Video 0x00000001047c8ea8 -[NYT360ViewController renderer:updateAtTime:] + 116
6 SceneKit 0x0000000196c5af80 <redacted> + 444
7 SceneKit 0x0000000196c5d018 <redacted> + 252
8 SceneKit 0x0000000196c5d69c <redacted> + 84
9 SceneKit 0x0000000196c5daa0 <redacted> + 728
10 SceneKit 0x0000000196d0446c <redacted> + 512
11 SceneKit 0x0000000196bc07dc <redacted> + 56
12 SceneKit 0x0000000196ccd388 <redacted> + 80
13 libdispatch.dylib 0x00000001047e9260 _dispatch_call_block_and_release + 24
14 libdispatch.dylib 0x00000001047e9220 _dispatch_client_callout + 16
15 libdispatch.dylib 0x00000001047f7e80 _dispatch_queue_serial_drain + 768
16 libdispatch.dylib 0x00000001047ec730 _dispatch_queue_invoke + 328
17 libdispatch.dylib 0x00000001047f8dd8 _dispatch_root_queue_drain_deferred_wlh + 352
18 libdispatch.dylib 0x00000001047ffebc _dispatch_workloop_worker_thread + 676
19 libsystem_pthread.dylib 0x0000000182643e70 _pthread_wqthread + 860
20 libsystem_pthread.dylib 0x0000000182643b08 start_wqthread + 4