sparrowcode / PermissionsKit

Universal API for request permission and get its statuses.
https://x.com/sparrowcode_ios
MIT License
5.64k stars 462 forks source link

Crash - Fatal Exception: NSInternalInconsistencyException Invalid size {0, 0} #261

Closed luis-colorcast closed 2 years ago

luis-colorcast commented 3 years ago

Describe the bug The app is crashing on startup when attempting to present the user with an initial permissions request for Notifications and ATT:

Fatal Exception: NSInternalInconsistencyException
Invalid size {0, 0} for item <SPPermissions.SPPermissionsDialogView: 0x1037bc540; frame = (187.5 400.2; 0 0); gestureRecognizers = <NSArray: 0x2813df660>; layer = <CALayer: 0x281d26160>> in Dynamics

To Reproduce Startup app for the first time (fresh install). This happens in a small percentage of these cases, so is unfortunately difficult to reproduce.

Expected behavior The user is able to see the permissions being requested and make a decision.

Screenshots N/A

Smartphone (please complete the following information):

Additional context The crash sounds similar to #213, which also, unfortunately, doesn't have a lot of detail to help solve.

Additionally, we have hit this crash 3 times with our production build and Firebase reports 100% background which could be related.

Full stack:

Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation 0x1a29df25c __exceptionPreprocess 1 libobjc.A.dylib 0x1b6774480 objc_exception_throw 2 CoreFoundation 0x1a28ecc98 -[CFPrefsSearchListSource addManagedSourceForIdentifier:user:] 3 Foundation 0x1a3c24ef8 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] 4 UIKitCore 0x1a4cb91f0 -[UIDynamicAnimator _registerBodyForItem:] 5 UIKitCore 0x1a4ccbbfc -[UISnapBehavior _associate] 6 UIKitCore 0x1a4cb67cc -[UIDynamicAnimator registerBehavior:] 7 UIKitCore 0x1a4cb65b8 -[UIDynamicAnimator addBehavior:] 8 Colorcast 0x100c942ac closure #3 in closure #1 in SPPermissionsDialogController.present(on:) 9 Colorcast 0x100ca4638 partial apply for closure #1 in static Delay.wait(:closure:) 10 Colorcast 0x100c94214 thunk for @escaping @callee_guaranteed () -> () 11 libdispatch.dylib 0x1a2617298 _dispatch_client_callout 12 libdispatch.dylib 0x1a25bc028 _dispatch_continuation_pop$VARIANT$mp 13 libdispatch.dylib 0x1a25ccd64 _dispatch_source_invoke$VARIANT$mp 14 libdispatch.dylib 0x1a25c5bc4 _dispatch_main_queue_callback_4CF$VARIANT$mp 15 CoreFoundation 0x1a295e298 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE 16 CoreFoundation 0x1a29586f8 __CFRunLoopRun 17 CoreFoundation 0x1a29577d0 CFRunLoopRunSpecific 18 GraphicsServices 0x1b9099570 GSEventRunModal 19 UIKitCore 0x1a52842d0 -[UIApplication _run] 20 UIKitCore 0x1a528984c UIApplicationMain 21 Colorcast 0x100a1c26c main + 19 (AppDelegate.swift:19) 22 libdyld.dylib 0x1a2636140 start

ivanvorobei commented 2 years ago

Hello! I have info about it, I think you try present it right after starting the application?

luis-colorcast commented 2 years ago

Yes, this is from our first screen after our splash screen on startup. A few more notes:

Hopefully, those additional notes help! Sorry, again we don't have a more detailed recreation on this.

ivanvorobei commented 2 years ago

I have idea, maybe its not bug. If you try present when app state not active, so layout not called in this case. Dialog preset using dynamic animator, its required correct sizes for start process it and no way manage it without sizes (zero size). So really, in this case should happen this error.

I see you did guard condition, now it work? I think it should help.

luis-colorcast commented 2 years ago

The app itself is active, but I think that the native prompt “to find and connect to devices on your local network” prompt is what is putting it in "inactive" state. The guard prevents the crash, but of course no SPPermissions prompt is ever shown.

ivanvorobei commented 2 years ago

@luis-colorcast fixed it maybe? Can I close issue?

luis-colorcast commented 2 years ago

The guard is preventing the crash, and we refactored some of our startup code to really avoid the situation. You can go ahead and close, thanks.

denandreychuk commented 2 years ago

We have the same problem. Is there the workaround to fix the crash and always present popup?