Skip to content

[webview] Crash during app termination: Fatal Exception: NSInternalInconsistencyException: Sending a message before the FlutterEngine has been run. #167650

Closed as duplicate

Description

@DieGlueckswurst

Steps to reproduce

Unfortunately I am not able to reproduce it. I can only see it happening in my Crashlytics Console.

After upgrading my Flutter version from 3.24.4 to 3.29.2, I start getting this error in my Crashlytics:

Fatal Exception: NSInternalInconsistencyException

Sending a message before the FlutterEngine has been run.

It seems to be happening on random views / actions inside my app. There is no pattern that I can see. The only thing is that it never happened before the upgrade.

I am happy for every help. It's causing our app to lose downloads.

Here is the full stacktrace:

          Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x2d5fc __exceptionPreprocess
1  libobjc.A.dylib                0x31244 objc_exception_throw
2  Foundation                     0x82dec0 _userInfoForFileAndLine
3  Flutter                        0x1fcc4 (Missing UUID 4c4c444355553144a1942736321a049f)
4  Flutter                        0x5e3de0 (Missing UUID 4c4c444355553144a1942736321a049f)
5  Flutter                        0x5e69f8 (Missing UUID 4c4c444355553144a1942736321a049f)
6  webview_flutter_wkwebview      0x10fd0 (Missing UUID 77fb8f2ca38a37d4a730288634b0a912)
7  webview_flutter_wkwebview      0xfd1c (Missing UUID 77fb8f2ca38a37d4a730288634b0a912)
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 WebKit                         0x58dd18 (Missing UUID 82158fd18f2e3f94ac212078b4c4b99a)
16 Foundation                     0x199054 _NSKVOPerformWithDeallocatingObservable
17 Foundation                     0x198d68 NSKVODeallocate
18 libobjc.A.dylib                0x5bac object_cxxDestructFromClass(objc_object*, objc_class*)
19 libobjc.A.dylib                0x4f4c objc_destructInstance
20 libobjc.A.dylib                0x4eec _objc_rootDealloc
21 Flutter                        0x3639c (Missing UUID 4c4c444355553144a1942736321a049f)
22 Flutter                        0x36024 (Missing UUID 4c4c444355553144a1942736321a049f)
23 libobjc.A.dylib                0x5bac object_cxxDestructFromClass(objc_object*, objc_class*)
24 libobjc.A.dylib                0x4f4c objc_destructInstance
25 libobjc.A.dylib                0x4eec _objc_rootDealloc
26 Flutter                        0x52ea4 (Missing UUID 4c4c444355553144a1942736321a049f)
27 CoreFoundation                 0x4e488 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
28 CoreFoundation                 0x4e3a4 ___CFXRegistrationPost_block_invoke
29 CoreFoundation                 0x4cf18 _CFXRegistrationPost
30 CoreFoundation                 0x4c01c _CFXNotificationPost
31 Foundation                     0x9fa9c -[NSNotificationCenter postNotificationName:object:userInfo:]
32 UIKitCore                      0x115c528 -[UIApplication _terminateWithStatus:]
33 UIKitCore                      0x1b5644 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
34 UIKitCore                      0x906e8c -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:]
35 UIKitCore                      0x1157c28 -[UIApplication workspaceShouldExit:withTransitionContext:]
36 FrontBoardServices             0x56cd4 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke_2
37 FrontBoardServices             0x1f4c8 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]
38 FrontBoardServices             0x56c74 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke
39 libdispatch.dylib              0x3fa8 _dispatch_client_callout
40 libdispatch.dylib              0x79f0 _dispatch_block_invoke_direct
41 FrontBoardServices             0x18378 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
42 FrontBoardServices             0x182f8 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible]
43 FrontBoardServices             0x181d0 -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource]
44 CoreFoundation                 0x73f4c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
45 CoreFoundation                 0x73ee0 __CFRunLoopDoSource0
46 CoreFoundation                 0x76b40 __CFRunLoopDoSources0
47 CoreFoundation                 0x75d3c __CFRunLoopRun
48 CoreFoundation                 0xc8284 CFRunLoopRunSpecific
49 GraphicsServices               0x14c0 GSEventRunModal
50 UIKitCore                      0x3ee674 -[UIApplication _run]
51 UIKitCore                      0x14e88 UIApplicationMain
52 UIKitCore                      0x75115c keypath_get_selector_hoverStyle
53 Runner                         0x8a38 main (AppDelegate.swift)
54 ???                            0x1c7c1dde8 (Missing)

Expected results

The app should not crash, or give me a better error description to fix it.

Actual results

App is crashing.

Code sample

Code sample

Could not reproduce it.

Screenshot from the console:

Image

Screenshots or Video

Logs

Logs
          Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x2d5fc __exceptionPreprocess
1  libobjc.A.dylib                0x31244 objc_exception_throw
2  Foundation                     0x82dec0 _userInfoForFileAndLine
3  Flutter                        0x1fcc4 (Missing UUID 4c4c444355553144a1942736321a049f)
4  Flutter                        0x5e3de0 (Missing UUID 4c4c444355553144a1942736321a049f)
5  Flutter                        0x5e69f8 (Missing UUID 4c4c444355553144a1942736321a049f)
6  webview_flutter_wkwebview      0x10fd0 (Missing UUID 77fb8f2ca38a37d4a730288634b0a912)
7  webview_flutter_wkwebview      0xfd1c (Missing UUID 77fb8f2ca38a37d4a730288634b0a912)
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 WebKit                         0x58dd18 (Missing UUID 82158fd18f2e3f94ac212078b4c4b99a)
16 Foundation                     0x199054 _NSKVOPerformWithDeallocatingObservable
17 Foundation                     0x198d68 NSKVODeallocate
18 libobjc.A.dylib                0x5bac object_cxxDestructFromClass(objc_object*, objc_class*)
19 libobjc.A.dylib                0x4f4c objc_destructInstance
20 libobjc.A.dylib                0x4eec _objc_rootDealloc
21 Flutter                        0x3639c (Missing UUID 4c4c444355553144a1942736321a049f)
22 Flutter                        0x36024 (Missing UUID 4c4c444355553144a1942736321a049f)
23 libobjc.A.dylib                0x5bac object_cxxDestructFromClass(objc_object*, objc_class*)
24 libobjc.A.dylib                0x4f4c objc_destructInstance
25 libobjc.A.dylib                0x4eec _objc_rootDealloc
26 Flutter                        0x52ea4 (Missing UUID 4c4c444355553144a1942736321a049f)
27 CoreFoundation                 0x4e488 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
28 CoreFoundation                 0x4e3a4 ___CFXRegistrationPost_block_invoke
29 CoreFoundation                 0x4cf18 _CFXRegistrationPost
30 CoreFoundation                 0x4c01c _CFXNotificationPost
31 Foundation                     0x9fa9c -[NSNotificationCenter postNotificationName:object:userInfo:]
32 UIKitCore                      0x115c528 -[UIApplication _terminateWithStatus:]
33 UIKitCore                      0x1b5644 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
34 UIKitCore                      0x906e8c -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:]
35 UIKitCore                      0x1157c28 -[UIApplication workspaceShouldExit:withTransitionContext:]
36 FrontBoardServices             0x56cd4 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke_2
37 FrontBoardServices             0x1f4c8 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]
38 FrontBoardServices             0x56c74 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke
39 libdispatch.dylib              0x3fa8 _dispatch_client_callout
40 libdispatch.dylib              0x79f0 _dispatch_block_invoke_direct
41 FrontBoardServices             0x18378 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
42 FrontBoardServices             0x182f8 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible]
43 FrontBoardServices             0x181d0 -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource]
44 CoreFoundation                 0x73f4c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
45 CoreFoundation                 0x73ee0 __CFRunLoopDoSource0
46 CoreFoundation                 0x76b40 __CFRunLoopDoSources0
47 CoreFoundation                 0x75d3c __CFRunLoopRun
48 CoreFoundation                 0xc8284 CFRunLoopRunSpecific
49 GraphicsServices               0x14c0 GSEventRunModal
50 UIKitCore                      0x3ee674 -[UIApplication _run]
51 UIKitCore                      0x14e88 UIApplicationMain
52 UIKitCore                      0x75115c keypath_get_selector_hoverStyle
53 Runner                         0x8a38 main (AppDelegate.swift)
54 ???                            0x1c7c1dde8 (Missing)
        

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.29.2, on macOS 15.3.2 24D81 darwin-arm64, locale de-DE) [823ms]
    • Flutter version 3.29.2 on channel stable at /Users/christiankonnerth/fvm/versions/3.29.2
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c236373904 (6 weeks ago), 2025-03-13 16:17:06 -0400
    • Engine revision 18b71d647a
    • Dart version 3.7.2
    • DevTools version 2.42.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1) [1.284ms]
    • Android SDK at /Users/christiankonnerth/Library/Android/sdk
    • Platform android-35, build-tools 35.0.1
    • Java binary at: /opt/homebrew/Cellar/openjdk@17/17.0.14/libexec/openjdk.jdk/Contents/Home/bin/java
      This JDK is specified in your Flutter configuration.
      To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment Homebrew (build 17.0.14+0)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1) [910ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [9ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [9ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.5+-13047016-b750.29)

[✓] Connected device (5 available) [8,9s]
    • iPhone von Chris (mobile)       • 00008120-000E20E43E44C01E            • ios            • iOS 18.1.1 22B91
    • iPhone 16 Pro (mobile)          • A70C6685-6F1B-478E-942C-512E33DB11CD • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-1 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 15.3.2 24D81 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 15.3.2 24D81 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 135.0.7049.96

[✓] Network resources [887ms]
    • All expected network resources are available.

• No issues found!

Activity

  1. added
    in triage
    on Apr 24, 2025
  2. danagbemava-nc commented on Apr 24, 2025

    @danagbemava-nc
    Member

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

  3. added
    waiting for response
    on Apr 24, 2025
  4. DieGlueckswurst commented on Apr 24, 2025

    @DieGlueckswurst
    Author

    @danagbemava-nc don't uite know how I can get the dsym from an older app version 🤔 I've already published an update where I downgraded to 3.29.2, hopefully that fixes things.

    Is it maybe related to: #166677 ?

  5. removed
    waiting for response
    on Apr 24, 2025
  6. DieGlueckswurst commented on Apr 24, 2025

    @DieGlueckswurst
    Author

    Update:

    The issue seems indeed to be happening when the webview is open and the user kills the app. I tested it and got this error in my XCode Console:

    *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Sending a message before the FlutterEngine has been run.'
    *** First throw call stack:
    (0x19d22c7cc 0x19a4ff2e4 0x19c5fc8d8 0x10c228ba0 0x10c7f8838 0x10c7fb450 0x105b5252c 0x105b53310 0x105b533c8 0x105b4efe8 0x105b4f07c 0x19bbac83c 0x19bbad950 0x19a4ed3a0 0x19a4ecf4c 0x19a4ecedc 0x19fa58ca0 0x19fa58b98 0x1b2a39ec4 0x19bed5420 0x19bed5134 0x105b31858 0x19a4edafc 0x19a4ecf3c 0x19a4ecedc 0x10c23f608 0x10c23f290 0x19a4edafc 0x19a4ecf3c 0x19a4ecedc 0x10c25c6d8 0x19d1fb2f4 0x19d1fb210 0x19d1fb158 0x19d1f970c 0x19be1cea4 0x1a0acfdf0 0x19fb0ef88 0x1a02ef8f4 0x1a0acb54c 0x1b6809f68 0x1b67c9c44 0x1b6809f08 0x105a2a71c 0x105a2e13c 0x1b67cb300 0x1b67cb280 0x1b67cb158 0x19d200328 0x19d2002bc 0x19d1fde24 0x19d1fcfbc 0x19d1fc830 0x1e91dc1c4 0x19fd62eb0 0x19fe115b4 0x1a014bfa8 0x106068ed8 0x106068e50 0x106068f54 0x1c2beaec8)
    libc++abi: terminating due to uncaught exception of type NSException
    

    webview_flutter: ^4.11.0

    flutter: 3.29.2

    Even though its apparently not actually crashing the app because the app was closed anyway, Apple seems to recognize it as "fatal crash" and considers it in its analysis.

    Quite critical for our app, as downloads are still going down, depending on the ranking.

    Update 2.0

    apparently this also happens when the WebView is already closed again. Is there something wrong with the disposel of it?

    Couldn't find anything about it, but getting more and more erros shown.

  7. danagbemava-nc commented on Apr 28, 2025

    @danagbemava-nc
    Member

    Hi @DieGlueckswurst, have you found a way to reproduce this issue locally? That would help us to be able to come up with a fix for it

  8. added
    waiting for response
    on Apr 28, 2025
  9. DieGlueckswurst commented on Apr 28, 2025

    @DieGlueckswurst
    Author

    yes! @danagbemava-nc . quite simple: Open the WebView on iOS (latest Flutter Version) and shut the app down manually by swiping up on iOS and removing the app. You will see the error in the logs on XCode

  10. removed
    waiting for response
    on Apr 28, 2025
  11. csandovalgd commented on Apr 28, 2025

    @csandovalgd

    This is also happening for me, this is what I see on my log service:

    NSInternalInconsistencyException 0x14a70 (0x14788 + 744)
    Sending a message before the FlutterEngine has been run.
    
  12. danagbemava-nc commented on Apr 29, 2025

    @danagbemava-nc
    Member

    Hi @DieGlueckswurst, does this also happen with the webview sample app? Also, what version of webview_flutter and webview_flutter_wkwebview are resolved in your project? This can be found in your pubspec.lock

  13. added
    waiting for response
    on Apr 29, 2025
  14. DieGlueckswurst commented on Apr 29, 2025

    @DieGlueckswurst
    Author

    @danagbemava-nc using the latest version, webview_flutter: ^4.11.0. Could you not reproduce it? I always tested it with a real device, iOS 18.

  15. removed
    waiting for response
    on Apr 29, 2025
  16. 19 remaining items

  17. added
    c: crash
    p: webview
    package
    fyi-ecosystem
    team-ios
    platform-ios
    c: fatal crash
    on Jun 3, 2025
  18. changed the title [-]Fatal Exception: NSInternalInconsistencyException: Sending a message before the FlutterEngine has been run.[/-] [+][webview] Crash during app termination: Fatal Exception: NSInternalInconsistencyException: Sending a message before the FlutterEngine has been run.[/+] on Jun 3, 2025
  19. stuartmorgan-g commented on Jun 3, 2025

    @stuartmorgan-g
    Contributor

    This is a duplicate of #168535

    It seems to be happening on random views / actions inside my app.

    The stack here cannot possibly be happening on random actions; it can only be triggered by manually terminating the app while it is frontmost.

    If you have crashes that happen at other times, please file a new issue.

    I am happy for every help. It's causing our app to lose downloads.

    It's not clear to me what this is referring to. This won't be user-visible because it's crashing while terminating, so the behavior from a user standpoint—the app is no longer running—is the expected behavior.

  20. stuartmorgan-g commented on Jun 3, 2025

    @stuartmorgan-g
    Contributor

    because of the native popup that shows when they reopen the app afterwards

    Thanks for clarifying; that's new behavior since the last time I dealt with a termination-specific crash on iOS.

  21. github-actions commented on Jun 17, 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.

  22. locked as resolved and limited conversation to collaborators on Jun 17, 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

    c: crashc: fatal crashfyi-ecosystemp: webviewpackageplatform-iosteam-ios

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions