PKHUD: Log show HUD not run in main thread

I test PKHUD in viewDidAppear

HUD.show(.labeledProgress(title: nil, subtitle: "loading..."))

still got Thread Error, but I’m sure HUD run in main thread!

opened :Main thread checker Xcode :Version 10.1 (10B61) iOS :12.1.1 Device :iPad 11"

=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 841, TID: 208513, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   libobjc.A.dylib                     0x00000001c487f894 <redacted> + 56
5   CoreMotion                          0x00000001cb105040 CoreMotion + 307264
6   CoreMotion                          0x00000001cb105574 CoreMotion + 308596
7   CoreMotion                          0x00000001cb105484 CoreMotion + 308356
8   CoreMotion                          0x00000001cb136c64 CoreMotion + 511076
9   CoreMotion                          0x00000001cb136cc4 CoreMotion + 511172
10  CoreFoundation                      0x00000001c56164fc <redacted> + 28
11  CoreFoundation                      0x00000001c5615de0 <redacted> + 276
12  CoreFoundation                      0x00000001c56110e4 <redacted> + 2324
13  CoreFoundation                      0x00000001c56104b8 CFRunLoopRunSpecific + 452
14  CoreFoundation                      0x00000001c561121c CFRunLoopRun + 84
15  CoreMotion                          0x00000001cb1365fc CoreMotion + 509436
16  libsystem_pthread.dylib             0x00000001c528b974 <redacted> + 132
17  libsystem_pthread.dylib             0x00000001c528b8d0 _pthread_start + 52
18  libsystem_pthread.dylib             0x00000001c5293ddc thread_start + 4
2019-01-15 00:24:32.721938+0800 MagicController[841:208513] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 841, TID: 208513, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   libobjc.A.dylib                     0x00000001c487f894 <redacted> + 56
5   CoreMotion                          0x00000001cb105040 CoreMotion + 307264
6   CoreMotion                          0x00000001cb105574 CoreMotion + 308596
7   CoreMotion                          0x00000001cb105484 CoreMotion + 308356
8   CoreMotion                          0x00000001cb136c64 CoreMotion + 511076
9   CoreMotion                          0x00000001cb136cc4 CoreMotion + 511172
10  CoreFoundation                      0x00000001c56164fc <redacted> + 28
11  CoreFoundation                      0x00000001c5615de0 <redacted> + 276
12  CoreFoundation                      0x00000001c56110e4 <redacted> + 2324
13  CoreFoundation                      0x00000001c56104b8 CFRunLoopRunSpecific + 452
14  CoreFoundation                      0x00000001c561121c CFRunLoopRun + 84
15  CoreMotion                          0x00000001cb1365fc CoreMotion + 509436
16  libsystem_pthread.dylib             0x00000001c528b974 <redacted> + 132
17  libsystem_pthread.dylib             0x00000001c528b8d0 _pthread_start + 52
18  libsystem_pthread.dylib             0x00000001c5293ddc thread_start + 4
2019-01-15 00:24:32.925872+0800 MagicController[841:208454] [framework] CUIThemeStore: No theme registered with id=0

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 12
  • Comments: 17 (3 by maintainers)

Commits related to this issue

Most upvoted comments

I just found a solution / workaround for this, see my PR https://github.com/pkluz/PKHUD/pull/252

simulator is OK, device show this warning, find someone have same issue on iPhone Xs iPhone X

PKHUD : Version 5.3.0 Xcode :Version 10.2.1 (10E1001) iOS : 12.2 Device : iPhoneXs

It has not been cured yet

Checked: Only happened when debugging. Run without debugger or run release is fine (Not cause freezes main thread)

Same issue, weirdly the freeze happens only after the HUD is being shown for the first time per the app’s instance. Next calls, and calls made after a restart are not blocking.

Running Xcode 10.2 with Swift 5. This warning is now causing main thread freezes.

A temporary fix is to remove/comment-out UIInterpolatingMotionEffect from FrameView.commonInit as:

    private func commonInit() {
        backgroundColor = UIColor(white: 0.8, alpha: 0.36)
        layer.cornerRadius = 9.0
        layer.masksToBounds = true

        contentView.addSubview(content)

//        let offset = 20.0
//
//        let motionEffectsX = UIInterpolatingMotionEffect(keyPath: "center.x", type: .tiltAlongHorizontalAxis)
//        motionEffectsX.maximumRelativeValue = offset
//        motionEffectsX.minimumRelativeValue = -offset
//
//        let motionEffectsY = UIInterpolatingMotionEffect(keyPath: "center.y", type: .tiltAlongVerticalAxis)
//        motionEffectsY.maximumRelativeValue = offset
//        motionEffectsY.minimumRelativeValue = -offset
//
//        let group = UIMotionEffectGroup()
//        group.motionEffects = [motionEffectsX, motionEffectsY]
//
//        addMotionEffect(group)
    }

Does anyone know if there is a temporary workaround for this?

Same issue on iPhone XR