Skip to content

[webview] iOS app crashes with an error "NSInternalInconsistencyException Sending a message before the FlutterEngine has been run." #166677

Closed

Description

@TatsuUkraine

What package does this bug report belong to?

webview_flutter

What target platforms are you seeing this bug on?

iOS

Have you already upgraded your packages?

Yes

Dependency versions

pubspec.lock
...
  webview_flutter:
    dependency: "direct main"
    description:
      name: webview_flutter
      sha256: "889a0a678e7c793c308c68739996227c9661590605e70b1f6cf6b9a6634f7aec"
      url: "https://pub.dev"
    source: hosted
    version: "4.10.0"
  webview_flutter_android:
    dependency: transitive
    description:
      name: webview_flutter_android
      sha256: "631093a7fbd93e9690ac61d8c8f3e857efbc189fc33f712b9ad6c01a623517ef"
      url: "https://pub.dev"
    source: hosted
    version: "4.3.3"
  webview_flutter_platform_interface:
    dependency: transitive
    description:
      name: webview_flutter_platform_interface
      sha256: d937581d6e558908d7ae3dc1989c4f87b786891ab47bb9df7de548a151779d8d
      url: "https://pub.dev"
    source: hosted
    version: "2.10.0"
  webview_flutter_wkwebview:
    dependency: transitive
    description:
      name: webview_flutter_wkwebview
      sha256: c49a98510080378b1525132f407a92c3dcd3b7145bef04fb8137724aadcf1cf0
      url: "https://pub.dev"
    source: hosted
    version: "3.18.4"
....

Steps to reproduce

Hard to say how to reproduce, we see some raising amount of errors after the recent release

Expected results

App doesn't crash

Actual results

App crashes with an exception

Code sample

Code sample
[Paste your code here]

Screenshots or Videos

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
          Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x2d5fc __exceptionPreprocess
1  libobjc.A.dylib                0x31244 objc_exception_throw
2  Foundation                     0x82dec0 _userInfoForFileAndLine
3  Flutter                        0x14a74 (Missing UUID 4c4c44fb55553144a1ac2283bc901480)
4  Flutter                        0x5e12f4 (Missing UUID 4c4c44fb55553144a1ac2283bc901480)
5  Flutter                        0x5e3f0c (Missing UUID 4c4c44fb55553144a1ac2283bc901480)
6  webview_flutter_wkwebview      0x14e40 (Missing UUID 7d0a686ef60339dfbe534f88fd1bc7a5)
7  webview_flutter_wkwebview      0x13bc0 (Missing UUID 7d0a686ef60339dfbe534f88fd1bc7a5)
8  libswiftCore.dylib             0x3d817c _swift_release_dealloc
9  libswiftCore.dylib             0x3d9290 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1>>::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int)
10 libobjc.A.dylib                0x53b0 _object_remove_associations
11 libobjc.A.dylib                0x4f5c objc_destructInstance
12 libobjc.A.dylib                0x4eec _objc_rootDealloc
13 UIKitCore                      0x989ec -[UIResponder dealloc]
14 UIKitCore                      0x9871c -[UIView dealloc]
15 UIKitCore                      0x336c28 -[UIScrollView dealloc]
16 WebKit                         0x594c94 (Missing UUID 82158fd18f2e3f94ac212078b4c4b99a)
17 libobjc.A.dylib                0x5bac object_cxxDestructFromClass(objc_object*, objc_class*)
18 libobjc.A.dylib                0x4f4c objc_destructInstance
19 libobjc.A.dylib                0x4eec _objc_rootDealloc
20 UIKitCore                      0x989ec -[UIResponder dealloc]
21 UIKitCore                      0x9871c -[UIView dealloc]
22 WebKit                         0x58dd18 (Missing UUID 82158fd18f2e3f94ac212078b4c4b99a)
23 Foundation                     0x199054 _NSKVOPerformWithDeallocatingObservable
24 Foundation                     0x198d68 NSKVODeallocate
25 libobjc.A.dylib                0x5bac object_cxxDestructFromClass(objc_object*, objc_class*)
26 libobjc.A.dylib                0x4f4c objc_destructInstance
27 libobjc.A.dylib                0x4eec _objc_rootDealloc
28 Flutter                        0x19fb4 (Missing UUID 4c4c44fb55553144a1ac2283bc901480)
29 Flutter                        0x19cd4 (Missing UUID 4c4c44fb55553144a1ac2283bc901480)
30 Flutter                        0x1a1a8 (Missing UUID 4c4c44fb55553144a1ac2283bc901480)
31 Flutter                        0x1144c (Missing UUID 4c4c44fb55553144a1ac2283bc901480)
32 CoreFoundation                 0x4e488 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
33 CoreFoundation                 0x4e3a4 ___CFXRegistrationPost_block_invoke
34 CoreFoundation                 0x4cf18 _CFXRegistrationPost
35 CoreFoundation                 0x4c01c _CFXNotificationPost
36 Foundation                     0x9fa9c -[NSNotificationCenter postNotificationName:object:userInfo:]
37 UIKitCore                      0x115c528 -[UIApplication _terminateWithStatus:]
38 UIKitCore                      0x1b5644 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
39 UIKitCore                      0x906e8c -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:]
40 UIKitCore                      0x1157c28 -[UIApplication workspaceShouldExit:withTransitionContext:]
41 FrontBoardServices             0x56cd4 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke_2
42 FrontBoardServices             0x1f4c8 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]
43 FrontBoardServices             0x56c74 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke
44 libdispatch.dylib              0x3fa8 _dispatch_client_callout
45 libdispatch.dylib              0x79f0 _dispatch_block_invoke_direct
46 FrontBoardServices             0x18378 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
47 FrontBoardServices             0x182f8 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible]
48 FrontBoardServices             0x181d0 -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource]
49 CoreFoundation                 0x73f4c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
50 CoreFoundation                 0x73ee0 __CFRunLoopDoSource0
51 CoreFoundation                 0x76ba4 __CFRunLoopDoSources0
52 CoreFoundation                 0x75d3c __CFRunLoopRun
53 CoreFoundation                 0xc8284 CFRunLoopRunSpecific
54 GraphicsServices               0x14c0 GSEventRunModal
55 UIKitCore                      0x3ee674 -[UIApplication _run]
56 UIKitCore                      0x14e88 UIApplicationMain
57 UIKitCore                      0x75115c keypath_get_selector_hoverStyle
58 Runner                         0x8a5c main (AppDelegate.swift)
59 ???                            0x1b8e9dde8 (Missing)
        

Flutter Doctor output

Doctor output
[Paste your output here]

Activity

  1. changed the title [-]iOS app crashes with an error "NSInternalInconsistencyException Sending a message before the FlutterEngine has been run."[/-] [+][webview] iOS app crashes with an error "NSInternalInconsistencyException Sending a message before the FlutterEngine has been run."[/+] on Apr 7, 2025
  2. added
    in triage
    on Apr 7, 2025
  3. darshankawar commented on Apr 7, 2025

    @darshankawar
    Member

    Flutter 0x14a74 (Missing UUID 4c4c44fb55553144a1ac2283bc901480)
    4 Flutter 0x5e12f4 (Missing UUID 4c4c44fb55553144a1ac2283bc901480)
    5 Flutter 0x5e3f0c (Missing UUID 4c4c44fb55553144a1ac2283bc901480)

    @TatsuUkraine The flutter frames are missing UUID, can you try to symbolicate those using this document to see if you can get more meaningful logs ?

    Based on "NSInternalInconsistencyException Sending a message before the FlutterEngine has been run.", there are couple of related issues open:

    #125299
    #117523

  4. added
    waiting for response
    on Apr 7, 2025
  5. stuartmorgan-g commented on Apr 7, 2025

    @stuartmorgan-g
    Contributor

    Based on "NSInternalInconsistencyException Sending a message before the FlutterEngine has been run.", there are couple of related issues open

    This will be a distinct issue, since unlike those it's specifically webview_flutter trying to call into the engine at app shutdown (the engine message is misleading) here; any case where a plugin is trying to call the engine after the engine shutdown will log the same message. I suspect in this case it's related to how the webview_flutter object manager, but if we can get the missing frames we'll be able to tell for sure. /cc @bparrishMines.

    (The good news is that while this is crashing, it's crashing specifically while the app is shutting down—generally this is the case where a user swipes an app away in the task manager—so the user won't experience it as a crash.)

  6. sdzfg347 commented on Apr 8, 2025

    @sdzfg347

    Got the same issue on a real iOS device with webview_flutter_wkwebview: 3.18.4 and webview_flutter_wkwebview:3.18.5. I have added a few JavaScript channels into the webview for communication from webView to Flutter.

    As @stuartmorgan-g mentioned, it happens when the webview is opened, the app is in the background, and then it gets killed in the task manager.

  7. github-actions commented on Apr 28, 2025

    @github-actions

    Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
    If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
    Thanks for your contribution.

  8. github-actions commented on May 12, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  9. locked as resolved and limited conversation to collaborators on May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in triagewaiting for response

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions