Skip to content

Occasional Crash When Opening URL in WebView Implemented via PlatformView On Android (Hard to reproduce) #170509

Open
@AWarmHug

Description

@AWarmHug

Steps to reproduce

In our Flutter project, we have implemented a custom WebView using PlatformView. Occasionally, when opening a specific URL, the app crashes unexpectedly. The issue occurs randomly and is currently not reproducible in a stable way.

Expected results

no Crash

Actual results

Crash

Code sample

Code sample
I used automated testing to repeatedly open the page hundreds of times, and the crash only occurred after many attempts.

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
Platform view cannot be composed without a valid RenderTarget surface.
Platform view cannot be composed without a valid RenderTarget surface.
[ERROR:flutter/fml/platform/android/jni_util.cc(206)] java.lang.IllegalStateException: Image is already closed
	at android.media.Image.throwISEIfImageIsInvalid(Image.java:72)
	at android.media.ImageReader$SurfaceImage.getHardwareBuffer(ImageReader.java:883)
[FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1597)] Check failed: fml::jni::CheckException(env).
      #01 pc 000000000046ced4  /data/app/com.bertadata.qxb-x2EeBA3kxMzWPCvKGcmk5A==/lib/arm64/libflutter.so!libflutter.so (offset 0x461000) (BuildId: 2c0bd20296bfcbf70a9b1f8a745bd75c64897220)

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.29.3, on macOS 15.4.1 24E263 darwin-arm64, locale
    zh-Hans-CN) [2.1s]
    • Flutter version 3.29.3 on channel stable at
      /Users/bin_ren/.fvm/versions/3.29.3
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ea121f8859 (9 weeks ago), 2025-04-11 19:10:07 +0000
    • Engine revision cf56914b32
    • Dart version 3.7.2
    • DevTools version 2.42.3
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
    [2.5s]
    • Android SDK at /Users/bin_ren/Library/Android/sdk
    • Platform android-36, build-tools 35.0.1
    • ANDROID_HOME = /Users/bin_ren/Library/Android/sdk
    • Java binary at:
      /Users/bin_ren/Library/Java/JavaVirtualMachines/corretto-17.0.14/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 Corretto-17.0.14.7.1 (build
      17.0.14+7-LTS)
    • All Android licenses accepted.

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

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

[✓] Android Studio (version 2022.3) [83ms]
    • Android Studio at /Applications/Android Studio
      AI-223.8836.35.2231.10671973.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
      17.0.6+0-17.0.6b829.9-10027231)

[✓] Android Studio (version 2024.3) [82ms]
    • 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.6+-13368085-b895.109)

[✓] IntelliJ IDEA Community Edition (version 2024.1.4) [82ms]
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • 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

[✓] IntelliJ IDEA Ultimate Edition (version 2024.1) [38ms]
    • IntelliJ at /Users/bin_ren/Applications/IntelliJ IDEA Ultimate.app
    • 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

[✓] VS Code (version 1.100.1) [13ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.112.0

[!] Proxy Configuration [13ms]
    • HTTP_PROXY is set
    ! NO_PROXY is not set

[✓] Connected device (5 available) [7.8s]
    • JSN AL00a (mobile)              • 7XBRX19125001247      • android-arm64  •
      Android 10 (API 29)
    • YAL AL00 (mobile)               • CUY0219522000831      • android-arm64  •
      Android 10 (API 29)
    • macOS (desktop)                 • macos                 • darwin-arm64   •
      macOS 15.4.1 24E263 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         •
      macOS 15.4.1 24E263 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript •
      Google Chrome 137.0.7151.69
    ! Error: Browsing on the local area network for 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)
    ! Error: Browsing on the local area network for Aria的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)
    ! Error: Browsing on the local area network for 任斌的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 [5.8s]
    • All expected network resources are available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in triagePresently being triaged by the triage teamwaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions