RxSwiftCommunity / RxCoreMotion

Provides an easy and straight-forward way to use Apple iOS CoreMotion responses as Rx Observables.
MIT License
60 stars 26 forks source link

Main Thread Checker error #20

Open richy486 opened 5 years ago

richy486 commented 5 years ago

Getting a thread checker issue in Device motion in the example. Running on: iOS 12, Xcode 10, iPhone Xs

coreMotionManager
    .flatMapLatest { manager in
        manager.deviceMotion ?? Observable.empty()
    }
    .observeOn(MainScheduler.instance)
    .subscribe(onNext: { deviceMotion in
        print(deviceMotion)
    })
    .disposed(by: disposeBag)
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 12527, TID: 1586580, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   libobjc.A.dylib                     0x0000000217343894 <redacted> + 56
5   CoreMotion                          0x000000021dba37a4 CoreMotion + 305060
6   CoreMotion                          0x000000021dba3cd8 CoreMotion + 306392
7   CoreMotion                          0x000000021dba3be8 CoreMotion + 306152
8   CoreMotion                          0x000000021dbd53cc CoreMotion + 508876
9   CoreMotion                          0x000000021dbd542c CoreMotion + 508972
10  CoreFoundation                      0x00000002180dc888 <redacted> + 28
11  CoreFoundation                      0x00000002180dc16c <redacted> + 276
12  CoreFoundation                      0x00000002180d7470 <redacted> + 2324
13  CoreFoundation                      0x00000002180d6844 CFRunLoopRunSpecific + 452
14  CoreFoundation                      0x00000002180d75a8 CFRunLoopRun + 84
15  CoreMotion                          0x000000021dbd4d64 CoreMotion + 507236
16  libsystem_pthread.dylib             0x0000000217d51a04 <redacted> + 132
17  libsystem_pthread.dylib             0x0000000217d51960 _pthread_start + 52
18  libsystem_pthread.dylib             0x0000000217d59df4 thread_start + 4
2018-11-16 11:24:09.981490-0800 RxCoreMotionExample[12527:1586580] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 12527, TID: 1586580, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   libobjc.A.dylib                     0x0000000217343894 <redacted> + 56
5   CoreMotion                          0x000000021dba37a4 CoreMotion + 305060
6   CoreMotion                          0x000000021dba3cd8 CoreMotion + 306392
7   CoreMotion                          0x000000021dba3be8 CoreMotion + 306152
8   CoreMotion                          0x000000021dbd53cc CoreMotion + 508876
9   CoreMotion                          0x000000021dbd542c CoreMotion + 508972
10  CoreFoundation                      0x00000002180dc888 <redacted> + 28
11  CoreFoundation                      0x00000002180dc16c <redacted> + 276
12  CoreFoundation                      0x00000002180d7470 <redacted> + 2324
13  CoreFoundation                      0x00000002180d6844 CFRunLoopRunSpecific + 452
14  CoreFoundation                      0x00000002180d75a8 CFRunLoopRun + 84
15  CoreMotion                          0x000000021dbd4d64 CoreMotion + 507236
16  libsystem_pthread.dylib             0x0000000217d51a04 <redacted> + 132
17  libsystem_pthread.dylib             0x0000000217d51960 _pthread_start + 52
18  libsystem_pthread.dylib             0x0000000217d59df4 thread_start + 4
freak4pc commented 5 years ago

Did you try moving the observeOn into the flatMap ?