Group Group Group Group Group Group Group Group Group

Chapter 13: UI API called on a background thread

HI, I’m experiencing looks like there is a thread problem with the “GestureIt” app. When I tap “Play”, I see the following in the console. Advice appreciated!

=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 35893, TID: 11094324, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   libobjc.A.dylib                     0x00000001f5bab6f4 <redacted> + 56
5   CoreMotion                          0x00000001fc325d9c CoreMotion + 294300
6   CoreMotion                          0x00000001fc3262cc CoreMotion + 295628
7   CoreMotion                          0x00000001fc3261dc CoreMotion + 295388
8   CoreMotion                          0x00000001fc35401c CoreMotion + 483356
9   CoreMotion                          0x00000001fc354060 CoreMotion + 483424
10  CoreFoundation                      0x00000001f693a27c <redacted> + 28
11  CoreFoundation                      0x00000001f6939b64 <redacted> + 276
12  CoreFoundation                      0x00000001f6934e58 <redacted> + 2276
13  CoreFoundation                      0x00000001f6934254 CFRunLoopRunSpecific + 452
14  CoreFoundation                      0x00000001f6934f88 CFRunLoopRun + 84
15  CoreMotion                          0x00000001fc3539f4 CoreMotion + 481780
16  libsystem_pthread.dylib             0x00000001f65b2908 <redacted> + 132
17  libsystem_pthread.dylib             0x00000001f65b2864 _pthread_start + 48
18  libsystem_pthread.dylib             0x00000001f65badcc thread_start + 4

Hey @karakots, sorry the project’s not working right. A few questions:

  1. Is this with the final version of the app that ships in the resources, or is it at some point during the chapter?
  2. What versions of iOS and Xcode are you running?
  3. Does this happen every time you tap “Play” or only sometimes?

Let me know and then I’ll try to dig in and figure out what’s going on. Thanks!

-Chris

This looks like it’s a known issue inside the Core Motion framework: https://stackoverflow.com/questions/54607856/main-thread-checker-warning-with-coremotion-only-appearing-on-2018-model-iphone

Hi clapollo, thanks for the quick response!

  1. Yes, the final version that ships with the app resources
  2. iOS 12.3.1, xCode Version 10.2.1 (10E1001). iPhone XS
  3. Every time I tap “Play”

Yep, this looks like the bug hollance linked. I just tried it on an XR and I get the same error.

I noticed that the app doesn’t actually crash, and after 10 or so seconds, it continues on and plays the game normally. So for now I’d suggest you ignore it and we can hope things work better in iOS 13. (Although I do not recommend actually trying to compile with Xcode 11 yet. As of beta 2 it’s still a wreck.)

Sorry for the inconvenience, but thanks for spotting this!