Skip to content

[webview_flutter] Hybrid Composition fails to dispose native webview #66764

@Sunbreak

Description

@Sunbreak

After refactoring webview_flutter with Hybrid-Composition as below, native webview fails to dispose when Navigator.pop

branch: https://github.com/Sunbreak/plugins/tree/feature/hybrid-composition
commit: Sunbreak/plugins@a80ac74

Screenshot of chrome://inspect#devices:

Screen Shot 2020-09-27 at 4 41 55 PM

Steps to Reproduce

  1. git clone https://github.com/Sunbreak/plugins -b feature/hybrid-composition
  2. cd packages/webview_flutter/example
  3. flutter run
  4. press the floating action button several times and press back button
  5. open chrome://inspect#devices to check the native webview instance

Expected results:

Webview instances in chrome://inspect#devices are destroyed after Navigator.pop, as the non-Hybrid webview_flutter does.

Actual results:

Webview instances in chrome://inspect#devices are keep-alive

Logs

flutter run

Launching lib/main.dart on Nexus 5 in debug mode...
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                         2.5s
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Waiting for Nexus 5 to report its views...                           9ms
Syncing files to device Nexus 5...                                 510ms

Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h Repeat this help message.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).
An Observatory debugger and profiler on Nexus 5 is available at: http://127.0.0.1:53022/AjNd4rnOuAU=/
I/WebViewFactory( 5405): Loading com.google.android.webview version 85.0.4183.101 (code 418310150)
I/cr_LibraryLoader( 5405): Loaded native library version number "85.0.4183.101"
I/cr_CachingUmaRecorder( 5405): Flushed 5 samples from 5 histograms.
W/chromium( 5405): [WARNING:dns_config_service_posix.cc(342)] Failed to read DnsConfig.
W/cr_media( 5405): Requires BLUETOOTH permission
E/libEGL  ( 5405): validate_display:255 error 3008 (EGL_BAD_DISPLAY)
I/flutter ( 5405): Page started loading: https://flutter.dev/
I/OpenGLRenderer( 5405): Initialized EGL, version 1.4

Application finished.
wangkun@C02CN0H4MD6V example %
wangkun@C02CN0H4MD6V example % ~/flutter/flutter-1.20.x/bin/flutter run
Launching lib/main.dart on Nexus 5 in debug mode...
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                         2.7s
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Waiting for Nexus 5 to report its views...                           8ms
Syncing files to device Nexus 5...                                 525ms

Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h Repeat this help message.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).
An Observatory debugger and profiler on Nexus 5 is available at: http://127.0.0.1:54345/3Y3v2Oh5bKI=/
I/WebViewFactory( 7165): Loading com.google.android.webview version 85.0.4183.101 (code 418310150)
I/cr_LibraryLoader( 7165): Loaded native library version number "85.0.4183.101"
I/cr_CachingUmaRecorder( 7165): Flushed 5 samples from 5 histograms.
W/chromium( 7165): [WARNING:dns_config_service_posix.cc(342)] Failed to read DnsConfig.
E/libEGL  ( 7165): validate_display:255 error 3008 (EGL_BAD_DISPLAY)
W/cr_media( 7165): Requires BLUETOOTH permission
I/flutter ( 7165): Page started loading: https://flutter.dev/
W/VideoCapabilities( 7165): Unrecognized profile 2130706433 for video/avc
I/VideoCapabilities( 7165): Unsupported profile 4 for video/mp4v-es
I/cr_MediaCodecBridge( 7165): create MediaCodec video decoder, mime video/avc
I/OMXClient( 7165): Using client-side OMX mux.
I/MediaCodec( 7165): [OMX.qcom.video.decoder.avc] setting surface generation to 7336961
D/SurfaceUtils( 7165): set up nativeWindow 0x9a0d9808 for 1080x820, color 0x7fa30c04, rotation 0, usage 0x42002900
D/SurfaceUtils( 7165): set up nativeWindow 0x9a0d9808 for 1088x832, color 0x7fa30c04, rotation 0, usage 0x42002900
I/chromium( 7165): [INFO:CONSOLE(263)] "The deviceorientation events are blocked by feature policy. See https://github.com/WICG/feature-policy/blob/master/features.md#sensor-features", source: https://www.youtube.com/s/player/12237e3d/player_ias.vflset/en_US/base.js (263)
I/chromium( 7165): [INFO:CONSOLE(263)] "The deviceorientation events are blocked by feature policy. See https://github.com/WICG/feature-policy/blob/master/features.md#sensor-features", source: https://www.youtube.com/s/player/12237e3d/player_ias.vflset/en_US/base.js (263)
I/flutter ( 7165): Page started loading: https://flutter.dev/
I/cr_MediaCodecBridge( 7165): create MediaCodec video decoder, mime video/avc
I/OMXClient( 7165): Using client-side OMX mux.
I/MediaCodec( 7165): [OMX.qcom.video.decoder.avc] setting surface generation to 7336962
D/SurfaceUtils( 7165): set up nativeWindow 0x90fd5f08 for 1080x820, color 0x7fa30c04, rotation 0, usage 0x42002900
I/cr_MediaCodecBridge( 7165): create MediaCodec video decoder, mime video/avc
I/OMXClient( 7165): Using client-side OMX mux.
I/MediaCodec( 7165): [OMX.qcom.video.decoder.avc] setting surface generation to 7336963
D/SurfaceUtils( 7165): set up nativeWindow 0x90fd5f08 for 1088x832, color 0x7fa30c04, rotation 0, usage 0x42002900
D/SurfaceUtils( 7165): set up nativeWindow 0x97147b08 for 1080x820, color 0x7fa30c04, rotation 0, usage 0x42002900
D/SurfaceUtils( 7165): set up nativeWindow 0x97147b08 for 1088x832, color 0x7fa30c04, rotation 0, usage 0x42002900
I/flutter ( 7165): Page finished loading: https://flutter.dev/
I/cr_MediaCodecBridge( 7165): create MediaCodec video decoder, mime video/avc
I/OMXClient( 7165): Using client-side OMX mux.
I/MediaCodec( 7165): [OMX.qcom.video.decoder.avc] setting surface generation to 7336964
D/SurfaceUtils( 7165): set up nativeWindow 0x9e8b8a08 for 1080x820, color 0x7fa30c04, rotation 0, usage 0x42002900
D/SurfaceUtils( 7165): set up nativeWindow 0x9e8b8a08 for 1088x832, color 0x7fa30c04, rotation 0, usage 0x42002900
I/chromium( 7165): [INFO:CONSOLE(263)] "The deviceorientation events are blocked by feature policy. See https://github.com/WICG/feature-policy/blob/master/features.md#sensor-features", source: https://www.youtube.com/s/player/12237e3d/player_ias.vflset/en_US/base.js (263)
I/chromium( 7165): [INFO:CONSOLE(263)] "The deviceorientation events are blocked by feature policy. See https://github.com/WICG/feature-policy/blob/master/features.md#sensor-features", source: https://www.youtube.com/s/player/12237e3d/player_ias.vflset/en_US/base.js (263)
I/flutter ( 7165): Page finished loading: https://flutter.dev/
I/flutter ( 7165): Page started loading: https://flutter.dev/
I/cr_MediaCodecBridge( 7165): create MediaCodec video decoder, mime video/avc
I/OMXClient( 7165): Using client-side OMX mux.
I/MediaCodec( 7165): [OMX.qcom.video.decoder.avc] setting surface generation to 7336965
D/SurfaceUtils( 7165): set up nativeWindow 0x97c54908 for 1080x820, color 0x7fa30c04, rotation 0, usage 0x42002900
D/SurfaceUtils( 7165): set up nativeWindow 0x97c54908 for 1088x832, color 0x7fa30c04, rotation 0, usage 0x42002900
W/cr_MediaCodecBridge( 7165): Releasing: OMX.qcom.video.decoder.avc
W/cr_MediaCodecBridge( 7165): Codec released
W/cr_MediaCodecBridge( 7165): Releasing: OMX.qcom.video.decoder.avc
W/cr_MediaCodecBridge( 7165): Codec released
W/cr_MediaCodecBridge( 7165): Releasing: OMX.qcom.video.decoder.avc
W/cr_MediaCodecBridge( 7165): Codec released
I/chromium( 7165): [INFO:CONSOLE(263)] "The deviceorientation events are blocked by feature policy. See https://github.com/WICG/feature-policy/blob/master/features.md#sensor-features", source: https://www.youtube.com/s/player/12237e3d/player_ias.vflset/en_US/base.js (263)
I/chromium( 7165): [INFO:CONSOLE(263)] "The deviceorientation events are blocked by feature policy. See https://github.com/WICG/feature-policy/blob/master/features.md#sensor-features", source: https://www.youtube.com/s/player/12237e3d/player_ias.vflset/en_US/base.js (263)
I/flutter ( 7165): Page finished loading: https://flutter.dev/
I/art     ( 7165): Background partial concurrent mark sweep GC freed 54328(2MB) AllocSpace objects, 8(536KB) LOS objects, 28% free, 40MB/56MB, paused 705us total 102.257ms
W/cr_MediaCodecBridge( 7165): Releasing: OMX.qcom.video.decoder.avc
W/cr_MediaCodecBridge( 7165): Codec released
W/cr_MediaCodecBridge( 7165): Releasing: OMX.qcom.video.decoder.avc
W/cr_MediaCodecBridge( 7165): Codec released
I/cr_MediaCodecBridge( 7165): create MediaCodec video decoder, mime video/avc
I/OMXClient( 7165): Using client-side OMX mux.
I/MediaCodec( 7165): [OMX.qcom.video.decoder.avc] setting surface generation to 7336966
D/SurfaceUtils( 7165): set up nativeWindow 0x9e8c3c08 for 1080x820, color 0x7fa30c04, rotation 0, usage 0x42002900
D/SurfaceUtils( 7165): set up nativeWindow 0x9e8c3c08 for 1088x832, color 0x7fa30c04, rotation 0, usage 0x42002900
W/cr_MediaCodecBridge( 7165): Releasing: OMX.qcom.video.decoder.avc
W/cr_MediaCodecBridge( 7165): Codec released
E/chromium( 7165): [ERROR:aw_gl_functor.cc(100)] Received unexpected kModeProcessNoContext
E/libEGL  ( 7165): call to OpenGL ES API with no current context (logged once per thread)

Application finished.

flutter analyze

Analyzing webview_flutter...

   info • `Future` results in `async` function bodies must be `await`ed or marked `unawaited` using `package:pedantic` •
          example/lib/main.dart:98:9 • unawaited_futures
   info • Dead code • example/lib/main.dart:106:5 • dead_code

2 issues found. (ran in 2.6s)

flutter doctor -v

[✓] Flutter (Channel master, 1.22.0-10.0.pre.269, on Mac OS X 10.15.4 19E287 x86_64, locale en)
    • Flutter version 1.22.0-10.0.pre.269 at /Users/wangkun/flutter/flutter-1.20.x
    • Framework revision 51fa704642 (8 days ago), 2020-09-19 11:27:04 -0700
    • Engine revision 4b8477d115
    • Dart version 2.10.0 (build 2.10.0-142.0.dev)
    • Pub download mirror http://dart-pub.byted.org
    • Flutter download mirror https://storage.flutter-io.cn


[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
    • Android SDK at /Users/wangkun/Library/Android/sdk
    • Platform android-30, build-tools 30.0.0
    • ANDROID_HOME = /Users/wangkun/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/wangkun/Library/Android/sdk
    • Java binary at: /Users/wangkun/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.6, Build version 11E708
    • CocoaPods version 1.9.2

[✓] Android Studio (version 4.0)
    • Android Studio at /Users/wangkun/Applications/Android Studio.app/Contents
    • Flutter plugin version 48.1.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] IntelliJ IDEA Community Edition (version 2020.2.1)
    • IntelliJ at /Users/wangkun/Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 49.0.4
    • Dart plugin version 202.7206

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

[✓] Connected device (1 available)
    • Nexus 5 (mobile) • 061f18eff0ec871a • android-arm • Android 6.0.1 (API 23)

• No issues found!

Metadata

Metadata

Assignees

Labels

P0Critical issues such as a build break or regressiona: platform-viewsEmbedding Android/iOS views in Flutter appsengineflutter/engine related. See also e: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: webviewThe WebView pluginpackageflutter/packages repository. See also p: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions