pkluz / PKHUD

A Swift based reimplementation of the Apple HUD (Volume, Ringer, Rotation,…) for iOS 8.
MIT License
3.79k stars 494 forks source link

Log show HUD not run in main thread #245

Open whlsxl opened 5 years ago

whlsxl commented 5 years ago

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
whlsxl commented 5 years ago

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

stefanrenne commented 5 years ago

Seems to be Apple iOS 12 weirdness, see this open radar ticket http://www.openradar.me/45003816

whlsxl commented 5 years ago

Thanks @stefanrenne That's true, but run the code above, the warning must show, maybe some API from apple, trigger this warning.

evandorn commented 5 years ago

Same issue on iPhone XR

jbmaxwell commented 5 years ago

Same issue, iPhone XR, iOS 12.1.4, presenting from main thread, async.

vlainvaldez commented 5 years ago

same issue happening to me, any updates?

iPhone XS: iOS 12.1.4

evandorn commented 5 years ago

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

Malibris commented 5 years ago

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.

jaymathew commented 5 years ago

Same here Xcode 10.2, Swift 5, IPhone XS, only happens on first show. Any workaround or fix ?

tandinhlee commented 5 years ago

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

sushant-here commented 5 years ago

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

stefanrenne commented 5 years ago

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

deepak4u2006 commented 5 years ago

I just found a solution / workaround for this, see my PR #252 Is this merged to master ?

tomokisun commented 5 years ago

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

It has not been cured yet

leshque commented 5 years ago

@tomoki69386 same PKHUD: 5.3.0 Xcode: Version 10.2.1 (10E1001) iOS 12.3.1 Device iPhone XS

Still reproduces and looks like it happens only on first show() call.

jackydhc commented 5 years ago

same issue in iphone xr iphone xs and just occured in first call

NickAger commented 5 years ago

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)
    }