Skip to content

[webview_flutter] Crash when opening webview on iOS after updating transitive webview_flutter_wkwebview to 3.18.0 #162437

Closed
flutter/packages
#8707

Description

@biklas7

Steps to reproduce

Some users reported that just opening a webview causes a crash almost every time.
We also got several crash reports on Firebase Crashlytics.

Expected results

I expect the app to not crash when opening a webview.

Actual results

App crashes.

Code sample

Can't really reproduce on my side if I create a minimal sample project, but please check the crash report.
Also, I noted that pinning webview_flutter_wkwebview to 3.17.0 solves the issue, so the bug must got introduced since then.

Screenshots or Video

No response

Logs

crash-report.txt

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.27.3, on macOS 15.2 24C101 darwin-arm64, locale en-PT)
    • Flutter version 3.27.3 on channel stable at /opt/homebrew/Caskroom/flutter/3.13.7/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c519ee916e (9 days ago), 2025-01-21 10:32:23 -0800
    • Engine revision e672b006cb
    • Dart version 3.6.1
    • DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/antonio/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 21.0.4+-12422083-b607.1)
    • All Android licenses accepted.

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

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

[✓] Android Studio (version 2024.2)
    • 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.4+-12422083-b607.1)

[✓] VS Code (version 1.96.4)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.102.0

[✓] Connected device (4 available)
    • iPhone 16 Pro (mobile)          • 01C8DB8E-568F-43FA-A971-626A012767BD • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-18-2 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 15.2 24C101 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 15.2 24C101 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 132.0.6834.112
    ! Error: Browsing on the local area network for António’s iPhone. Ensure the device is unlocked and attached with a cable or
      associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

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

• No issues found!

Activity

  1. stuartmorgan-g commented on Jan 30, 2025

    @stuartmorgan-g
    Contributor

    @bparrishMines Looks like a regression from the Swift proxy API conversion. This is the relevant part of the crash log:

    Exception Type:  EXC_CRASH (SIGABRT)
    Exception Codes: 0x0000000000000000, 0x0000000000000000
    Termination Reason: SIGNAL 6 Abort trap: 6
    Terminating Process: Runner [1557]
    
    Triggered by Thread:  0
    
    
    Thread 0 name:
    Thread 0 Crashed:
    0   libsystem_kernel.dylib        	0x00000001fff07198 __pthread_kill + 8 (:-1)
    1   libsystem_pthread.dylib       	0x000000020f4965f8 pthread_kill + 208 (pthread.c:1670)
    2   libsystem_c.dylib             	0x00000001cb5a580c __abort + 124 (abort.c:155)
    3   libsystem_c.dylib             	0x00000001cb5504c4 abort + 136 (abort.c:126)
    4   libswiftCore.dylib            	0x00000001be8a4998 swift::fatalErrorv(unsigned int, char const*, char*) + 132 (Errors.cpp:378)
    5   libswiftCore.dylib            	0x00000001be8a49b4 swift::fatalError(unsigned int, char const*, ...) + 28 (Errors.cpp:386)
    6   libswiftCore.dylib            	0x00000001be89c6ec swift::swift_dynamicCastFailure(void const*, char const*, void const*, char const*, char const*) + 76 (Casting.cpp:388)
    7   libswiftCore.dylib            	0x00000001be89c764 swift::swift_dynamicCastFailure(swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, char const*) + 120 (Casting.cpp:402)
    8   libswiftCore.dylib            	0x00000001be8a06ac swift_dynamicCast + 280 (CompatibilityOverrideRuntime.def:109)
    9   webview_flutter_wkwebview     	0x0000000105b6e380 closure #1 in PigeonApiWKNavigationDelegate.didReceiveAuthenticationChallenge(pigeonInstance:webView:challenge:completion:) + 536 (WebKitLibrary.g.swift:4354)
    10  webview_flutter_wkwebview     	0x0000000105b5c104 thunk for @escaping @callee_guaranteed (@in_guaranteed Any?) -> () + 84 (/<compiler-generated>:0)
    

    It looks like the cast in question is let result = listResponse[0] as! AuthenticationChallengeResponse (here).

  2. added
    platform-iosiOS applications specifically
    packageflutter/packages repository. See also p: labels.
    P1High-priority issues at the top of the work list
    on Jan 30, 2025
  3. JediPixels commented on Jan 30, 2025

    @JediPixels

    Not sure if this is related but when I updated my share_plus: to ^10.1.4 it caused a crash with this error:

    Could not cast value of type 'NSNull' (0x205d18b30) to 'webview_flutter_wkwebview.AuthenticationChallengeResponse' (0x1014f3ba8)
    

    I opened an issue with the share_plus plugin at
    fluttercommunity/plus_plugins#3450

    With the previous share_plus: ^10.1.3 no crashes and it works fine.

  4. JediPixels commented on Jan 31, 2025

    @JediPixels
  5. JediPixels commented on Jan 31, 2025

    @JediPixels

    I believe that something could have also happened with the compatibility of webview_flutter and the WordPress Akismet Anti-spam: Spam Protection plugin.

  6. stuartmorgan-g commented on Jan 31, 2025

    @stuartmorgan-g
    Contributor

    @JediPixels Unless you are using other plugins with severe bugs that cause arbitrary memory to be stomped, they should not be able to cause this crash.

  7. JediPixels commented on Jan 31, 2025

    @JediPixels
  8. JediPixels commented on Jan 31, 2025

    @JediPixels

    after more testing, if the WordPress site uses reCaptcha for the contact forms, but the pages that webview_flutter is loading is not the contact form, could the reCaptcha be causing the error? AuthenticationChallengeResponse

    Could not cast value of type 'NSNull' (0x1f5fed040) to 'webview_flutter_wkwebview.AuthenticationChallengeResponse'
    
  9. JediPixels commented on Jan 31, 2025

    @JediPixels
  10. 52 remaining items

  11. mateenshiekh commented on Mar 6, 2025

    @mateenshiekh
  12. stuartmorgan-g commented on Mar 6, 2025

    @stuartmorgan-g
    Contributor

    This is fixed in 3.18.3, so anyone seeing this should flutter pub upgrade --unlock-transitive webview_flutter to get the latest version of webview_flutter_wkwebview.

  13. Michael199311 commented on Mar 8, 2025

    @Michael199311

    Thanks @stuartmorgan , this issue bothered me for weeks, but after I ran flutter pub upgrade --unlock-transitive webview_flutter, the webview_flutter_wkwebview didn't upgrade to the latest version, it's still in 3.18.1(which is related to the latest version of wevbiew_flutter).
    I manually add webview_flutter_wkwebview: ^3.18.4 anyway

  14. ferdinandfrank commented on Mar 11, 2025

    @ferdinandfrank

    Are you guys sure that this is fully fixed in 3.18.4?

    Even though we do not receive the original error (Could not cast value of type 'NSNull' (0x11c6a0dc8) to 'webview_flutter_wkwebview.AuthenticationChallengeResponse') anymore, we now receive the following two errors on our latest release using this version:

    SIGABRT
    Could not cast value of type '%s' (%p) to '%s' (%p)%s%s
     > Could not cast value of type 'NSNull' (0x1f62c1a00) to 'webview_flutter_wkwebview.URLRequestWrapper' (0x1020b8a50).
     > NSNull
    
    NSInternalInconsistencyException
    Completion handler passed to -[webview_flutter_wkwebview.NavigationDelegateImpl webView:didReceiveAuthenticationChallenge:completionHandler:] was not called
    

    These two errors still cause several crashes on our app.

    Looking at our pubspec.lock, we are definitely on the latest version:

      webview_flutter_wkwebview:
        dependency: "direct main"
        description:
          name: webview_flutter_wkwebview
          sha256: c49a98510080378b1525132f407a92c3dcd3b7145bef04fb8137724aadcf1cf0
          url: "https://pub.dev"
        source: hosted
        version: "3.18.4"
    
  15. ferdinandfrank commented on Mar 18, 2025

    @ferdinandfrank

    I downgraded back to version 3.17.0 and can confirm that the issues and crashes are now gone.

    @bparrishMines I'm pretty sure that there are still related issues with the 3.18.x versions, see my comment above.

  16. bparrishMines commented on Mar 21, 2025

    @bparrishMines
    Contributor

    @ferdinandfrank

    SIGABRT
    Could not cast value of type '%s' (%p) to '%s' (%p)%s%s
     > Could not cast value of type 'NSNull' (0x1f62c1a00) to 'webview_flutter_wkwebview.URLRequestWrapper' (0x1020b8a50).
     > NSNull
    

    The WKNavigationDelegate.didReceiveAuthenticationChallenge doesn't contain a URL, so this is most likely unrelated to this issue. Can you open a separate issue providing more info and an example of how to reproduce?

    NSInternalInconsistencyException
    Completion handler passed to -[webview_flutter_wkwebview.NavigationDelegateImpl webView:didReceiveAuthenticationChallenge:completionHandler:] was not called
    

    This error could have a different cause to this issue. Can you open a separate issue for this as well? This could be related to #102476.

  17. github-actions commented on Apr 4, 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.

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

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listp: webviewThe WebView pluginpackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions