googlevr / gvr-ios-sdk

Google VR SDK for iOS
http://developers.google.com/vr/ios/
Other
647 stars 191 forks source link

Accessing UIKit on background thread #306

Open benasher44 opened 6 years ago

benasher44 commented 6 years ago

Hi there! When using the SDK, we found that using the panorama view causes accesses to UIKit from a background thread, which is unsupported and also triggers the main thread sanitizer in Xcode 9. Here is the output from the sanitizer:

UI API called from background thread: -[UIView setHidden:] must be used from main thread only

Thread 90
#0  0x00000001081f1d8d in __ABTSwizzleDynamicSelectorProperty_block_invoke_5 ()
#1  0x00000001059e3de5 in -[GVRWidgetView setContentLoaded:] ()
#2  0x00000001059d7b13 in __36-[GVRPanoramaView loadImage:ofType:]_block_invoke ()
#3  0x000000011409d05c in __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ ()
#4  0x000000011408183b in __CFRunLoopDoBlocks ()
#5  0x0000000114081014 in __CFRunLoopRun ()
#6  0x0000000114080889 in CFRunLoopRunSpecific ()
#7  0x00000001140bce03 in CFRunLoopRun ()
#8  0x000000010a71e12c in __NSThread__start__ ()
#9  0x0000000115efe6c1 in _pthread_body ()
#10 0x0000000115efe56d in _pthread_start ()
#11 0x0000000115efdc5d in thread_start ()

UI API called from background thread: -[UIView setNeedsLayout] must be used from main thread only

Thread 90
#0  0x000000010820ea0f in _logos_method$_ungrouped$UIView$setNeedsLayout ()
#1  0x00000001059d7b13 in __36-[GVRPanoramaView loadImage:ofType:]_block_invoke ()
#2  0x000000011409d05c in __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ ()
#3  0x000000011408183b in __CFRunLoopDoBlocks ()
#4  0x0000000114081014 in __CFRunLoopRun ()
#5  0x0000000114080889 in CFRunLoopRunSpecific ()
#6  0x00000001140bce03 in CFRunLoopRun ()
#7  0x000000010a71e12c in __NSThread__start__ ()
#8  0x0000000115efe6c1 in _pthread_body ()
#9  0x0000000115efe56d in _pthread_start ()
#10 0x0000000115efdc5d in thread_start ()

UI API called from background thread: -[UIView frame] must be used from main thread only

Thread 90
#0  0x00000001059e5624 in -[GVRWidgetView render:] ()
#1  0x00000001059dbc32 in -[GVRWeakRenderTarget render:] ()
#2  0x00000001059dccfb in -[GVRRenderLoop updateWithDisplayLink:] ()
#3  0x000000010cbe12b8 in CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) ()
#4  0x000000010cd21894 in display_timer_callback(__CFMachPort*, void*, long, void*) ()
#5  0x0000000114089899 in __CFMachPortPerform ()
#6  0x00000001140897d9 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#7  0x0000000114089741 in __CFRunLoopDoSource1 ()
#8  0x0000000114081524 in __CFRunLoopRun ()
#9  0x0000000114080889 in CFRunLoopRunSpecific ()
#10 0x00000001140bce03 in CFRunLoopRun ()
#11 0x000000010a71e12c in __NSThread__start__ ()
#12 0x0000000115efe6c1 in _pthread_body ()
#13 0x0000000115efe56d in _pthread_start ()
#14 0x0000000115efdc5d in thread_start ()

UI API called from background thread: -[UIApplication statusBarOrientation] must be used from main thread only

Thread 90
#0  0x00000001059dce32 in +[GVRRenderUtils screenOrientationInDegrees] ()
#1  0x00000001059e56c6 in -[GVRWidgetView render:] ()
#2  0x00000001059dbc32 in -[GVRWeakRenderTarget render:] ()
#3  0x00000001059dccfb in -[GVRRenderLoop updateWithDisplayLink:] ()
#4  0x000000010cbe12b8 in CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) ()
#5  0x000000010cd21894 in display_timer_callback(__CFMachPort*, void*, long, void*) ()
#6  0x0000000114089899 in __CFMachPortPerform ()
#7  0x00000001140897d9 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#8  0x0000000114089741 in __CFRunLoopDoSource1 ()
#9  0x0000000114081524 in __CFRunLoopRun ()
#10 0x0000000114080889 in CFRunLoopRunSpecific ()
#11 0x00000001140bce03 in CFRunLoopRun ()
#12 0x000000010a71e12c in __NSThread__start__ ()
#13 0x0000000115efe6c1 in _pthread_body ()
#14 0x0000000115efe56d in _pthread_start ()
#15 0x0000000115efdc5d in thread_start ()

It'd be great to see this fixed in an upcoming release! Let me know if there's any additional info I can provide, and thanks for your consideration!