AR Template results in 2 "not on main thread" warnings

I created a new project using the Augmented Reality App template in Xcode 10.1. Running this app with no changes results in 2 warnings when running through Xcode on an iPhone XS Max. Same error occurs whether tethered or connecting via network. Running the same code through Xcode on an iPhone 7 Plus results in no errors.


Any ideas why? (Log shown below.)


Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]

PID: 1035, TID: 164930, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0

Backtrace:

4 libobjc.A.dylib 0x0000000226f63534 <redacted> + 56

5 CoreMotion 0x000000022d7ec040 CoreMotion + 307264

6 CoreMotion 0x000000022d7ec574 CoreMotion + 308596

7 CoreMotion 0x000000022d7ec484 CoreMotion + 308356

8 CoreMotion 0x000000022d81dc64 CoreMotion + 511076

9 CoreMotion 0x000000022d81dcc4 CoreMotion + 511172

10 CoreFoundation 0x0000000227cfc354 <redacted> + 28

11 CoreFoundation 0x0000000227cfbc38 <redacted> + 276

12 CoreFoundation 0x0000000227cf6f14 <redacted> + 2324

13 CoreFoundation 0x0000000227cf62e8 CFRunLoopRunSpecific + 452

14 CoreFoundation 0x0000000227cf704c CFRunLoopRun + 84

15 CoreMotion 0x000000022d81d5fc CoreMotion + 509436

16 libsystem_pthread.dylib 0x0000000227970974 <redacted> + 132

17 libsystem_pthread.dylib 0x00000002279708d0 _pthread_start + 52

18 libsystem_pthread.dylib 0x0000000227978ddc thread_start + 4

2019-02-15 17:28:03.511545-0800 AR Ruler[1035:164930] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]

PID: 1035, TID: 164930, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0

Backtrace:

4 libobjc.A.dylib 0x0000000226f63534 <redacted> + 56

5 CoreMotion 0x000000022d7ec040 CoreMotion + 307264

6 CoreMotion 0x000000022d7ec574 CoreMotion + 308596

7 CoreMotion 0x000000022d7ec484 CoreMotion + 308356

8 CoreMotion 0x000000022d81dc64 CoreMotion + 511076

9 CoreMotion 0x000000022d81dcc4 CoreMotion + 511172

10 CoreFoundation 0x0000000227cfc354 <redacted> + 28

11 CoreFoundation 0x0000000227cfbc38 <redacted> + 276

12 CoreFoundation 0x0000000227cf6f14 <redacted> + 2324

13 CoreFoundation 0x0000000227cf62e8 CFRunLoopRunSpecific + 452

14 CoreFoundation 0x0000000227cf704c CFRunLoopRun + 84

15 CoreMotion 0x000000022d81d5fc CoreMotion + 509436

16 libsystem_pthread.dylib 0x0000000227970974 <redacted> + 132

17 libsystem_pthread.dylib 0x00000002279708d0 _pthread_start + 52

18 libsystem_pthread.dylib 0x0000000227978ddc thread_start + 4

Replies

Bumping this up. Hopefully this is on Apple's bug list. Anyone know a work-around?



I get the same problem with my iPad Pro (12.9-inch) (3rd generation) (Model MTFl2LL/A), Software Version 12.2.


Searching around, this seems like a problem with the latest generation of hardware.


Here is a reference for duplicating the problem (using Core Motion) and associated sample code:

https://stackoverflow.com/questions/52979259/cmotionmanager-crash-on-instantiation


import UIKit

import CoreMotion



class ViewController: UIViewController {

var motion: CMMotionManager?

override func viewDidLoad() {

super.viewDidLoad()



// This causes a crash on iPhone Xs, iOS 12.0.1

self.motion = CMMotionManager()

}

}

Please file a bug report.

Bug report filed.


Here is an additional note to anyone who runs across this discussion in case it helps them: for me the problem ("Main Thread Checker: UI API called on a background thread") did *not* cause my program to crash when using ARKit


conf = AROrientationTrackingConfiguration()

sess = ARSession()

sess.run(conf)


However, the program did crash with the following warning:


"This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data."


Because this console message was right at the end of the previous warning, I thought the "Main Thread Checker" issue caused the crash. It did not.


The crash (for me) was a separate issue. After I added the "Privacy - Camera Usage Description" entry to my info.plist, the program runs without crashing. I still got the "Main Thread Checker" alert, but after about 10 seconds, the program runs fine.