PKHUD.show(onView:) is crashing with iOS 15
arsalangolestanekh opened this issue · 22 comments
Did anybody observed crash with PKHUD.show(onView:) on iOS 15?
Can someone recommend something to resolve this crash
Crashlogs:
`Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000010264298c
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: SIGNAL; [5]
Terminating Process: exc handler [815]
Terminating Process: exc handler [815]
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 PKHUD 0x10264298c PKHUD.show(onView:) + 956
1 PKHUD 0x102642678 PKHUD.show(onView:) + 168
2 PKHUD 0x102640b54 static HUD.show(_:onView:) + 144
3 my_App 0x1016cb304 0x100dd8000 + 9384708
4 my_App 0x101528d48 0x100dd8000 + 7671112
5 my_App 0x101526658 0x100dd8000 + 7661144
6 my_App 0x101525d28 0x100dd8000 + 7658792
7 my_App 0x1013d7c40 0x100dd8000 + 6290496
8 my_App 0x101581b30 0x100dd8000 + 8035120
9 my_App 0x101581c7c 0x100dd8000 + 8035452
10 IntuneMAMSwift 0x108eb1664 0x108c90000 + 2233956
11 IntuneMAMSwift 0x108ca4c10 0x108c90000 + 85008
12 IntuneMAMSwift 0x108e390f0 0x108c90000 + 1741040
13 IntuneMAMSwift 0x108e38de4 0x108c90000 + 1740260
14 IntuneMAMSwift 0x108e39a24 0x108c90000 + 1743396
15 IntuneMAMSwift 0x108eae9d8 0x108c90000 + 2222552
16 IntuneMAMSwift 0x108eb0ab0 0x108c90000 + 2230960
17 ADAL 0x101dade24 __swizzle_ApplicationOpenURLiOS9 + 300
18 UIKitCore 0x18370881c __58-[UIApplication _applicationOpenURLAction:payload:origin:]_block_invoke + 804
19 UIKitCore 0x1835ea1d0 -[UIApplication _applicationOpenURLAction:payload:origin:] + 892
20 UIKitCore 0x1835c58c4 -[UIApplication _handleNonLaunchSpecificActions:forScene:withTransitionContext:completion:] + 5040
21 UIKitCore 0x183566d50 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 496
22 UIKitCore 0x1835aa524 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 288
23 UIKitCore 0x183534370 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 492
24 FrontBoardServices 0x192a54100 -[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:] + 528
25 FrontBoardServices 0x192a6cd4c __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke_2 + 152
26 FrontBoardServices 0x192a516b4 -[FBSWorkspace calloutQueue_executeCalloutFromSource:withBlock:] + 240
27 FrontBoardServices 0x192a57b10 __94-[FBSWorkspaceScenesClient queue_updateScene:withSettings:diff:transitionContext:completion:]block_invoke + 396
28 libdispatch.dylib 0x180beb660 dispatch_client_callout + 20
29 libdispatch.dylib 0x180bef118 dispatch_block_invoke_direct + 264
30 FrontBoardServices 0x192a52f94 FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 48
31 FrontBoardServices 0x192a523d4 -[FBSSerialQueue targetQueue_performNextIfPossible] + 220
32 FrontBoardServices 0x192a569e4 -[FBSSerialQueue performNextFromRunLoopSource] + 28
33 CoreFoundation 0x180f9b020 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 28
34 CoreFoundation 0x180fabce0 __CFRunLoopDoSource0 + 208
35 CoreFoundation 0x180ee5fe8 __CFRunLoopDoSources0 + 268
36 CoreFoundation 0x180eeb7f4 __CFRunLoopRun + 820
37 CoreFoundation 0x180eff3b8 CFRunLoopRunSpecific + 600
38 GraphicsServices 0x19c88f38c GSEventRunModal + 164
39 UIKitCore 0x18389f6a8 -[UIApplication run] + 1100
40 UIKitCore 0x18361e7f4 UIApplicationMain + 2092
41 IntuneMAMSwiftStub 0x108c7a1a8 cmarRealUIApplicationMain(::::) + 96
42 IntuneMAMSwift 0x108f17294 cmarHookedUIApplicationMain(::::) + 216
43 securelinegen2_intune 0x100eac808 0x100dd8000 + 870408
44 dyld 0x101d05a24 start + 520
`
Me too
Do you know the way how to fix those crashes?
No :( I can't reproduce in debug. I have only reports from users. You pass onView parameter?
I think it is an answer, I think we should pass view
Ok, I thing it'a issue, when you don't pass view. HUD use keyWindow. Changes for iOS 15: https://developer.apple.com/documentation/uikit/uiwindow/1621612-keywindow
It's a fork with commit for this issue: kevin-zqw@597e660
Wow, @MarkerwApk when was it fix?
do we have this change in the latest version?
I thing no. I will try pass UIView and I will be observe Crashlytics.
@MarkerwApk did you make a pull request to the main repo? Sounds like it's a easy fix
I am also getting crash on this method when I change the scheme and run the project without running a clean build.
If I clean and build again then it does not crash anymore.
yes i know how to fix it, however I dont know how to contribute to the improvemnet
this should will fix it
var window = UIApplication.shared.keyWindow //--> nil = crash if #available(iOS 13.0, *) { window = UIApplication.shared.connectedScenes .filter({$0.activationState == .foregroundActive}) .compactMap({$0 as? UIWindowScene}) .first?.windows .filter({$0.isKeyWindow}).first }
Has anyone managed to fix the problem? I’m experiencing the same issue from iOS 15.4 and 15.5
Has anyone managed to fix the problem? I’m experiencing the same issue from iOS 15.4 and 15.5
I've been experienced this problem since a couple of months ago when the user opens a deep link (the HUD is shown) and the app is not ready yet.
After trying several things I finally tried this, thinking it would be the ultimate solution:
if UIApplication.shared.keyWindow != nil {
HUD.show(.progress)
}
But I'm still receiving crashes in this line (HUD.show(.progress))! Why?? It has no sense to me.
Anyway I'm going to test @MarkerwApk and add onView: view to the call and see what it happens.
I've been experienced this problem since a couple of months ago when the user opens a deep link (the HUD is shown) and the app is not ready yet. After trying several things I finally tried this, thinking it would be the ultimate solution:
if UIApplication.shared.keyWindow != nil { HUD.show(.progress) }
But I'm still receiving crashes in this line (HUD.show(.progress))! Why?? It has no sense to me. Anyway I'm going to test @MarkerwApk and add onView: view to the call and see what it happens.
Look at documentation: https://developer.apple.com/documentation/uikit/uiwindow/1621612-keywindow
It's very bad from Apple side(change behavior and implementation). "onView" should resolve issue.
Thanks!! I'm gonna try your solution.
In my case I'm still having issues with the deep linking, I'm pretty sure this is because the view is not ready yet, so I'm trying:
let isViewVisible = self.viewIfLoaded?.window != nil
if isViewVisible {
HUD.show(.progress, onView: self.view)
}
Well, I'm still having crashes with this last code...I'll find another option.
@rferbesa try this
let keyWindow = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
pass the variable to onView and let me know
Thanks! I'll try that and let you know.
It didn't work. I think is a problem of how my app detects if it's in background or not (or if the view is being shown or not). I won't show the spinner in the deep linking flow to "fix" this.