5 Replies
      Latest reply on Nov 11, 2019 1:36 AM by eskimo
      tntsb Level 1 Level 1 (0 points)

        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.

        • Re: Fatal Exception: NSInternalInconsistencyException
          eskimo Apple Staff Apple Staff (12,265 points)

          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"

            • Re: Fatal Exception: NSInternalInconsistencyException
              tntsb Level 1 Level 1 (0 points)

              Hi, this is coming from crash reports via Fabric.

                • Re: Fatal Exception: NSInternalInconsistencyException
                  eskimo Apple Staff Apple Staff (12,265 points)

                  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 xxx was not called.  It’s hard to be 100% sure what xxx 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"

                    • Re: Fatal Exception: NSInternalInconsistencyException
                      Avishek_ARC Level 1 Level 1 (0 points)

                      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)

                        • Re: Fatal Exception: NSInternalInconsistencyException
                          eskimo Apple Staff Apple Staff (12,265 points)

                          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"