Fatal Exception: NSInternalInconsistencyException

This thread has been locked by a moderator.

Hi, I have no idea what caused this error "completion handler passed to -[MyApp.MainVC webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:] was not called " can you guys please help me to find it?


Here is the code for JavaScriptAlertPanelWithMessage

func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo,
                 completionHandler: @escaping () -> Void) {
        
        let alertController = UIAlertController(title: nil, message: message, preferredStyle: .actionSheet)
        
        if self.presentingViewController == nil{
            
            alertController.addAction(UIAlertAction(title: "Ok", style: .cancel, handler: { (action) in
                completionHandler()
            }))
            
            if UIDevice.current.userInterfaceIdiom != .phone {
                
                alertController.addAction(UIAlertAction(title: "Ok", style: .default, handler: { (action) in
                    completionHandler()
                }))
                
                if let popoverController = alertController.popoverPresentationController {
                    popoverController.sourceView = self.view
                    popoverController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
                    popoverController.permittedArrowDirections = []
                }
                
            }
            
             self.present(alertController, animated: true, completion: nil)
        }
    }


Here is the crash logs from crashlytics.

Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x1817e2d8c __exceptionPreprocess
1  libobjc.A.dylib                0x18099c5ec objc_exception_throw
2  CoreFoundation                 0x1817e2c6c -[NSException initWithCoder:]
3  WebKit                         0x1911b8688 WebKit::CompletionHandlerCallChecker::~CompletionHandlerCallChecker()
4  WebKit                         0x1911c2ee0 ***::ThreadSafeRefCounted::deref() const
5  WebKit                         0x1912c6f48 ***::BlockPtr ***::BlockPtr::fromCallable<webkit::uidelegate::uiclient::runjavascriptalert(webkit::webpageproxy*, ***::string="" const&,="" webkit::webframeproxy*,="" webcore::securityorigindata="" ***::function<void="" ()="">&&)::$_1>(WebKit::UIDelegate::UIClient::runJavaScriptAlert(WebKit::WebPageProxy*, ***::String const&, WebKit::WebFrameProxy*, WebCore::SecurityOriginData const&, ***::Function&&)::$_1)::'lambda'(void const*)::__invoke(void const*)
6  libsystem_blocks.dylib         0x181174a5c _Block_release
7  MyApp                          0x102a87830 partial apply for MainVC.(webView(WKWebView, didStartProvisionalNavigation : WKNavigation!) -> ()).(closure #3) (MainVC.swift)
8  libswiftCore.dylib             0x10310cf04 (Missing)
9  MyApp                          0x102a87884 ObjCBool (MainVC.swift)
10 libswiftCore.dylib             0x10310cf04 (Missing)
11 libsystem_blocks.dylib         0x181174a5c _Block_release
12 UIKit                          0x18b5ebfb8 -[UIAlertController _clearActionHandlers]
13 UIKit                          0x18b5ebcb8 -[UIAlertController dealloc]
14 UIKit                          0x18b5eb970 -[UIPresentationController .cxx_destruct]
15 libobjc.A.dylib                0x18099aef4 object_cxxDestructFromClass(objc_object*, objc_class*)
16 libobjc.A.dylib                0x1809a8990 objc_destructInstance
17 libobjc.A.dylib                0x1809a89f8 object_dispose
18 UIKit                          0x18b5eb260 -[UIPresentationController dealloc]
19 UIKit                          0x18b5ea694 -[UIViewController _didFinishDismissTransition]
20 UIKit                          0x18b5e9050 -[UIPresentationController transitionDidFinish:]
21 UIKit                          0x18ba14430 -[_UICurrentContextPresentationController transitionDidFinish:]
22 UIKit                          0x18b87ac88 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.436
23 UIKit                          0x18b3ecb88 -[_UIViewControllerTransitionContext completeTransition:]
24 UIKit                          0x18b45a678 -[UITransitionView notifyDidCompleteTransition:]
25 UIKit                          0x18b45a230 -[UITransitionView _didCompleteTransition:]
26 UIKit                          0x18b6f5be4 -[UITransitionView _transitionDidStop:finished:]
27 UIKit                          0x18b3ec0b8 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:]
28 UIKit                          0x18b4d5fcc -[UIViewAnimationState animationDidStop:finished:]
29 UIKit                          0x18b4d606c -[UIViewAnimationState animationDidStop:finished:]
30 QuartzCore                     0x18597b36c CA::Layer::run_animation_callbacks(void*)
31 libdispatch.dylib              0x1810d4a60 _dispatch_client_callout
32 libdispatch.dylib              0x1810e165c _dispatch_main_queue_callback_4CF$VARIANT$mp
33 CoreFoundation                 0x18178b070 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
34 CoreFoundation                 0x181788bc8 __CFRunLoopRun
35 CoreFoundation                 0x1816a8da8 CFRunLoopRunSpecific
36 GraphicsServices               0x18368e020 GSEventRunModal
37 UIKit                          0x18b6c8758 UIApplicationMain
38 MyApp                          0x102a82520 main (MainVC.swift:17)
39 libdyld.dylib                  0x181139fc0 start


#0. Crashed: com.twitter.crashlytics.ios.exception
0  MyApp                          0x102aa85ac CLSProcessRecordAllThreads (CLSProcess.c:376)
1  MyApp                          0x102aa85ac CLSProcessRecordAllThreads (CLSProcess.c:376)
2  MyApp                          0x102aa8a20 CLSProcessRecordAllThreads (CLSProcess.c:407)
3  MyApp                          0x102a98060 CLSHandler (CLSHandler.m:26)
4  MyApp                          0x102aa6b18 __CLSExceptionRecord_block_invoke (CLSException.mm:199)
5  libdispatch.dylib              0x1810d4a60 _dispatch_client_callout + 16
6  libdispatch.dylib              0x1810dd5bc _dispatch_queue_barrier_sync_invoke_and_complete + 56
7  MyApp                          0x102aa6594 CLSExceptionRecord (CLSException.mm:206)
8  MyApp                          0x102aa63c4 CLSExceptionRecordNSException (CLSException.mm:102)
9  MyApp                          0x102aa5fc4 CLSTerminateHandler() (CLSException.mm:259)
10 libc++abi.dylib                0x18098d37c std::__terminate(void (*)()) + 16
11 libc++abi.dylib                0x18098cccc __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 130
12 libobjc.A.dylib                0x18099c720 _objc_exception_destructor(void*) + 362
13 CoreFoundation                 0x1817e2c6c -[NSException initWithCoder:] + 114
14 WebKit                         0x1911b8688 WebKit::CompletionHandlerCallChecker::~CompletionHandlerCallChecker() + 144
15 WebKit                         0x1911c2ee0 ***::ThreadSafeRefCounted::deref() const + 40
16 WebKit                         0x1912c6f48 ***::BlockPtr ***::BlockPtr::fromCallable<webkit::uidelegate::uiclient::runjavascriptalert(webkit::webpageproxy*, ***::string="" const&,="" webkit::webframeproxy*,="" webcore::securityorigindata="" ***::function<void="" ()="">&&)::$_1>(WebKit::UIDelegate::UIClient::runJavaScriptAlert(WebKit::WebPageProxy*, ***::String const&, WebKit::WebFrameProxy*, WebCore::SecurityOriginData const&, ***::Function&&)::$_1)::'lambda'(void const*)::__invoke(void const*) + 32
17 libsystem_blocks.dylib         0x181174a5c _Block_release + 152
18 MyApp                          0x102a87830 partial apply for MainVC.(webView(WKWebView, didStartProvisionalNavigation : WKNavigation!) -> ()).(closure #3) (MainVC.swift)
19 libswiftCore.dylib             0x10310cf04 swift_unownedCheck + 88
20 MyApp                         0x102a87884 ObjCBool (MainVC.swift)
21 libswiftCore.dylib             0x10310cf04 swift_unownedCheck + 88
22 libsystem_blocks.dylib         0x181174a5c _Block_release + 152
23 UIKit                          0x18b5ebfb8 -[UIAlertController _clearActionHandlers] + 204
24 UIKit                          0x18b5ebcb8 -[UIAlertController dealloc] + 352
25 UIKit                          0x18b5eb970 -[UIPresentationController .cxx_destruct] + 372
26 libobjc.A.dylib                0x18099aef4 object_cxxDestructFromClass(objc_object*, objc_class*) + 148
27 libobjc.A.dylib                0x1809a8990 objc_destructInstance + 68
28 libobjc.A.dylib                0x1809a89f8 object_dispose + 16
29 UIKit                          0x18b5eb260 -[UIPresentationController dealloc] + 60
30 UIKit                          0x18b5ea694 -[UIViewController _didFinishDismissTransition] + 564
31 UIKit                          0x18b5e9050 -[UIPresentationController transitionDidFinish:] + 532
32 UIKit                          0x18ba14430 -[_UICurrentContextPresentationController transitionDidFinish:] + 40
33 UIKit                          0x18b87ac88 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.436 + 188
34 UIKit                          0x18b3ecb88 -[_UIViewControllerTransitionContext completeTransition:] + 116
35 UIKit                          0x18b45a678 -[UITransitionView notifyDidCompleteTransition:] + 252
36 UIKit                          0x18b45a230 -[UITransitionView _didCompleteTransition:] + 1132
37 UIKit                          0x18b6f5be4 -[UITransitionView _transitionDidStop:finished:] + 120
38 UIKit                          0x18b3ec0b8 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 312
39 UIKit                          0x18b4d5fcc -[UIViewAnimationState animationDidStop:finished:] + 296
40 UIKit                          0x18b4d606c -[UIViewAnimationState animationDidStop:finished:] + 456
41 QuartzCore                     0x18597b36c CA::Layer::run_animation_callbacks(void*) + 284
42 libdispatch.dylib              0x1810d4a60 _dispatch_client_callout + 16
43 libdispatch.dylib              0x1810e165c _dispatch_main_queue_callback_4CF$VARIANT$mp + 1012
44 CoreFoundation                 0x18178b070 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
45 CoreFoundation                 0x181788bc8 __CFRunLoopRun + 2272
46 CoreFoundation                 0x1816a8da8 CFRunLoopRunSpecific + 552
47 GraphicsServices               0x18368e020 GSEventRunModal + 100
48 UIKit                          0x18b6c8758 UIApplicationMain + 236
49 MyApp                        0x102a82520 main (MainVC.swift:17)
50 libdyld.dylib                  0x181139fc0 start + 4



Thank you very much.

Up vote post of tntsb
7.4k views

Accepted Reply

I have same issue

Which same issue?

NSInternalInconsistencyException
is a very general symptom and there have been two different issues raised on this thread:
  • The initial one, on 30 Aug 2018, which is related to WebKit

  • A second one, on 8 Nov 2019, which related to notifications

Rather than have more folks pile on here, I’m going to lock this thread and recommend that you create a new thread in Xcode > Debugger so that we can discuss your specific case.

ps I noticed you already did this. Thanks! I’ll respond on the specific thread you created for your issue.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

Is this error reproducible in your office? Or do you only see it coming in via crash reports?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi, this is coming from crash reports via Fabric.

this is coming from crash reports via Fabric.

OK.

You can see the immediate cause of this failure in the WebKit open source. Specifically, frame 3 refers to

CompletionHandlerCallChecker
, which you can find here.

If you look at that code you can see it was designed to track whether a specific completion handler was called. The exception being raised in the destructor is

Completion handler passed to *** was not called
. It’s hard to be 100% sure what
***
is in this case, but it’s very likely to be the completion handler passed to your
webView(_:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:)
method. And looking at your code I see a bunch of ways that you might run through that code without calling the completion handler.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

HI eskima,


I am facing similar kind of error. I have no clue how to handle it. Please guide.


Fatal Exception: NSInternalInconsistencyException

0 CoreFoundation 0x1a4a3d80c __exceptionPreprocess

1 libobjc.A.dylib 0x1a4765fa4 objc_exception_throw

2 CoreFoundation 0x1a493fc4c +[_CFXNotificationTokenRegistration keyCallbacks]

3 Foundation 0x1a4d756f4 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]

4 FrontBoardServices 0x1a9b8aafc (Missing)

5 FrontBoardServices 0x1a9b3ff78 (Missing)

6 FrontBoardServices 0x1a9b401e0 (Missing)

7 FrontBoardServices 0x1a9b400e8 (Missing)

8 UIKitCore 0x1a8639e88 (Missing)

9 UIKitCore 0x1a8722d04 (Missing)

10 UIKitCore 0x1a87239f4 (Missing)

11 CameraUI 0x1c601d644 (Missing)

12 CameraUI 0x1c60bae70 (Missing)

13 libobjc.A.dylib 0x1a47650e8 object_cxxDestructFromClass(objc_object*, objc_class*)

14 libobjc.A.dylib 0x1a4777d7c objc_destructInstance

15 libobjc.A.dylib 0x1a477edb0 _objc_rootDealloc

16 CameraUI 0x1c60b06bc (Missing)

17 CoreFoundation 0x1a4987054 __RELEASE_OBJECTS_IN_THE_ARRAY__

18 CoreFoundation 0x1a4914a4c -[__NSArrayM dealloc]

19 CameraUI 0x1c611038c (Missing)

20 libobjc.A.dylib 0x1a47650e8 object_cxxDestructFromClass(objc_object*, objc_class*)

21 libobjc.A.dylib 0x1a4777d7c objc_destructInstance

22 libobjc.A.dylib 0x1a477edb0 _objc_rootDealloc

23 CameraUI 0x1c61021ac (Missing)

24 libsystem_blocks.dylib 0x1a4631a48 (Missing)

25 libsystem_blocks.dylib 0x1a4631a48 (Missing)

26 libdispatch.dylib 0x1a470b184 (Missing)

27 libdispatch.dylib 0x1a46e8710 (Missing)

28 libdispatch.dylib 0x1a46e9128 (Missing)

29 libdispatch.dylib 0x1a46f243c (Missing)

30 libsystem_pthread.dylib 0x1a475af88 (Missing)

31 libsystem_pthread.dylib 0x1a475dad4 (Missing)

NSInternalInconsistencyException
can be raised by a variety of subsystems, and it’s clear that your problem, coming out of FrontBoardServices, is unrelated to the original one reported by tntsb, that was coming out of a web view. Given that, I’d appreciate you starting a new thread for your issue:

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi eskimo!

I have same issue, and I haven't clue how fix it. Please help me!


Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x1ab27ea48 __exceptionPreprocess
1  libobjc.A.dylib                0x1aafa5fa4 objc_exception_throw
2  CoreFoundation                 0x1ab1825a8 -[NSOrderedSet initWithSet:copyItems:]
3  CoreFoundation                 0x1ab282af4 ___forwarding___
4  CoreFoundation                 0x1ab284a7c _CF_forwarding_prep_0
5  UIKitCore                      0x1af55aca8 -[UITextInteraction didMoveToView:]
6  UIKitCore                      0x1af56323c -[UITextPhraseBoundaryInteraction didMoveToView:]
7  UIKitCore                      0x1af7982d0 _setInteractionView
8  UIKitCore                      0x1af7981ac -[UIView(Dragging) addInteraction:]
9  UIKitCore                      0x1af1cf0d0 -[DOMNode(UITextInput_Internal) _setGestureRecognizers]
10 UIKitCore                      0x1af1cf2b4 -[DOMNode(UITextInput_Internal) _setAttributedMarkedText:selectedRange:]
11 CoreFoundation                 0x1ab284c20 __invoking___
12 CoreFoundation                 0x1ab154d30 -[NSInvocation invoke]
13 CoreFoundation                 0x1ab155908 -[NSInvocation invokeWithTarget:]
14 UIKitCore                      0x1af7e2594 -[UIThreadSafeNode forwardInvocation:]
15 CoreFoundation                 0x1ab28286c ___forwarding___
16 CoreFoundation                 0x1ab284a7c _CF_forwarding_prep_0
17 UIKitCore                      0x1af127e78 -[UIKeyboardImpl _setAttributedMarkedText:selectedRange:inputString:searchString:compareAttributes:]
18 UIKitCore                      0x1af13aa18 -[UIKeyboardImpl updateCandidateDisplayAsyncWithCandidateSet:]
19 UIKitCore                      0x1af12ca64 -[UIKeyboardImpl inputManagerDidGenerateCandidatesForRequest:resultSet:]
20 UIKitCore                      0x1af12c4bc __78-[UIKeyboardImpl generateCandidatesAsynchronouslyWithRange:selectedCandidate:]_block_invoke_3
21 UIKitCore                      0x1af1581d0 -[UIKeyboardTaskExecutionContext returnExecutionToParentWithInfo:]
22 UIKitCore                      0x1af12c458 __78-[UIKeyboardImpl generateCandidatesAsynchronouslyWithRange:selectedCandidate:]_block_invoke_2
23 UIKitCore                      0x1af159d88 -[UIKeyboardTaskEntry execute:]
24 UIKitCore                      0x1af1587b8 -[UIKeyboardTaskQueue continueExecutionOnMainThread]
25 UIKitCore                      0x1af158f3c -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished]
26 UIKitCore                      0x1af1166a4 -[UIKeyboardImpl generateAutofillCandidateByAddingTask:]
27 UIKitCore                      0x1af129d18 -[UIKeyboardImpl selectionDidChange:]
28 UIKitCore                      0x1af1cf420 -[DOMNode(UITextInput_Internal) _unmarkText]
29 CoreFoundation                 0x1ab284c20 __invoking___
30 CoreFoundation                 0x1ab154d30 -[NSInvocation invoke]
31 CoreFoundation                 0x1ab155908 -[NSInvocation invokeWithTarget:]
32 UIKitCore                      0x1af7e2594 -[UIThreadSafeNode forwardInvocation:]
33 CoreFoundation                 0x1ab28286c ___forwarding___
34 CoreFoundation                 0x1ab284a7c _CF_forwarding_prep_0
35 UIKitCore                      0x1af128014 -[UIKeyboardImpl unmarkText]
36 UIKitCore                      0x1af11dcac -[UIKeyboardImpl setDelegate:force:]
37 UIKitCore                      0x1aee1f370 -[UIInputResponderController _reloadInputViewsForKeyWindowSceneResponder:]
38 UIKitCore                      0x1aee1ef74 -[UIInputResponderController _reloadInputViewsForResponder:]
39 UIKitCore                      0x1af336268 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews]
40 UIKitCore                      0x1af7e4988 -[UIWebBrowserView _reloadInputViewsAfterPotentialFocusRedirect]
41 UIKitCore                      0x1af7e4824 -[UIWebBrowserView _endAllowingFocusRedirects]
42 libdispatch.dylib              0x1aaf4b184 _dispatch_client_callout
43 libdispatch.dylib              0x1aaf2eea0 _dispatch_async_and_wait_invoke
44 libdispatch.dylib              0x1aaf4b184 _dispatch_client_callout
45 libdispatch.dylib              0x1aaf2e34c _dispatch_main_queue_callback_4CF$VARIANT$armv81
46 CoreFoundation                 0x1ab1fc5e4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
47 CoreFoundation                 0x1ab1f75d8 __CFRunLoopRun
48 CoreFoundation                 0x1ab1f6adc CFRunLoopRunSpecific
49 GraphicsServices               0x1b5197328 GSEventRunModal
50 UIKitCore                      0x1af30463c UIApplicationMain
51 Digitalmembercard              0x100dd7340 main + 38 (AppDelegate.swift:38)
52 libdyld.dylib                  0x1ab080360 start
Crashed: com.twitter.crashlytics.ios.exception
0  Digitalmembercard              0x1010f0464 CLSProcessRecordAllThreads + 4302849124
1  Digitalmembercard              0x1010f084c CLSProcessRecordAllThreads + 4302850124
2  Digitalmembercard              0x1010e00c8 CLSHandler + 4302782664
3  Digitalmembercard              0x1010eea5c __CLSExceptionRecord_block_invoke + 4302842460
4  libdispatch.dylib              0x1aaf4b184 _dispatch_client_callout + 16
5  libdispatch.dylib              0x1aaf2edc8 _dispatch_lane_barrier_sync_invoke_and_complete + 56
6  Digitalmembercard              0x1010ee4c8 CLSExceptionRecord + 4302841032
7  Digitalmembercard              0x1010ee2f4 CLSExceptionRecordNSException + 4302840564
8  Digitalmembercard              0x1010edee8 CLSTerminateHandler() + 4302839528
9  libc++abi.dylib                0x1ab04b304 std::__terminate(void (*)()) + 16
10 libc++abi.dylib                0x1ab04b29c std::terminate() + 44
11 libobjc.A.dylib                0x1aafa61dc _objc_terminate() + 10
12 libdispatch.dylib              0x1aaf4b198 _dispatch_client_callout + 36
13 libdispatch.dylib              0x1aaf2eea0 _dispatch_async_and_wait_invoke + 92
14 libdispatch.dylib              0x1aaf4b184 _dispatch_client_callout + 16
15 libdispatch.dylib              0x1aaf2e34c _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 996
16 CoreFoundation                 0x1ab1fc5e4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
17 CoreFoundation                 0x1ab1f75d8 __CFRunLoopRun + 2004
18 CoreFoundation                 0x1ab1f6adc CFRunLoopRunSpecific + 464
19 GraphicsServices               0x1b5197328 GSEventRunModal + 104
20 UIKitCore                      0x1af30463c UIApplicationMain + 1936
21 Digitalmembercard              0x100dd7340 main + 38 (AppDelegate.swift:38)
22 libdyld.dylib                  0x1ab080360 start + 4

I have same issue

Which same issue?

NSInternalInconsistencyException
is a very general symptom and there have been two different issues raised on this thread:
  • The initial one, on 30 Aug 2018, which is related to WebKit

  • A second one, on 8 Nov 2019, which related to notifications

Rather than have more folks pile on here, I’m going to lock this thread and recommend that you create a new thread in Xcode > Debugger so that we can discuss your specific case.

ps I noticed you already did this. Thanks! I’ll respond on the specific thread you created for your issue.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"