I just added AdMob into my UIViewController
, and when I run the app, it freezes for a few seconds, and then this shows up:
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 8093, TID: 1911410, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4 libobjc.A.dylib 0x0000000198a9b894 <redacted> + 56
5 CoreMotion 0x000000019f321040 CoreMotion + 307264
6 CoreMotion 0x000000019f321574 CoreMotion + 308596
7 CoreMotion 0x000000019f321484 CoreMotion + 308356
8 CoreMotion 0x000000019f352c64 CoreMotion + 511076
9 CoreMotion 0x000000019f352cc4 CoreMotion + 511172
10 CoreFoundation 0x00000001998324fc <redacted> + 28
11 CoreFoundation 0x0000000199831de0 <redacted> + 276
12 CoreFoundation 0x000000019982d0e4 <redacted> + 2324
13 CoreFoundation 0x000000019982c4b8 CFRunLoopRunSpecific + 452
14 CoreFoundation 0x000000019982d21c CFRunLoopRun + 84
15 CoreMotion 0x000000019f3525fc CoreMotion + 509436
16 libsystem_pthread.dylib 0x00000001994a7974 <redacted> + 132
17 libsystem_pthread.dylib 0x00000001994a78d0 _pthread_start + 52
18 libsystem_pthread.dylib 0x00000001994afddc thread_start + 4
Any tips?
Your problem is this process is in the Main Thread . Main Thread for only UI action. Otherwise UI will freeze.
You should do it in background thread.
DispatchQueue.global(qos: .background).async { // Your code }
Enjoy.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.