flutter_workmanager icon indicating copy to clipboard operation
flutter_workmanager copied to clipboard

🐞[Android] execution of the `callBackDispatcher` destroys another library's platform channel

Open clangenb opened this issue 3 years ago • 3 comments

  • [x] I have read the README
  • [x] I have done the setup for Android
  • [ ] I have done the setup for iOS
  • [ ] I have ran the sample app and it does not work there

Version

Technology Version
Workmanager version 5.0.0

Describe the error Executing a periodic task destroys the platform channel of another library in_app_webview.

E/flutter (17528): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method evaluateJavascript on channel com.pichillilorenzo/flutter_inappwebview_1214122967374174233124163190134233129107185174)
E/flutter (17528): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:294:7)
E/flutter (17528): <asynchronous suspension>
E/flutter (17528): #1      InAppWebViewController.evaluateJavascript (package:flutter_inappwebview/src/in_app_webview/in_app_webview_controller.dart:1420:16)
E/flutter (17528): <asynchronous suspension>
E/flutter (17528): 

I am quite positive that this is the issue because the flutter_inappwebView is launched correctly and has been working stable for months before introducing the workmanager. I will investigate some more...

Output of flutter doctor -v [√] Flutter (Channel stable, 3.3.2, on Microsoft Windows [Version 10.0.22000.978], locale en-CH) • Flutter version 3.3.2 on channel stable at C:\tools\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision e3c29ec00c (2 weeks ago), 2022-09-14 08:46:55 -0500 • Engine revision a4ff2c53d8 • Dart version 2.18.1 • DevTools version 2.15.0

[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0) • Android SDK at C:\Users\clang\AppData\Local\Android\sdk • Platform android-33, build-tools 32.0.0 • Java binary at: C:\Users\clang\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-1\213.7172.25.2211.8571212\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted.

[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop for Windows X Visual Studio not installed; this is necessary for Windows development. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2021.3) • Android Studio at C:\Users\clang\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-1\213.6777.52.2113.8172706 • Flutter plugin version 64.1.4 • Dart plugin version 213.5744.122 • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[√] Android Studio (version 2022.1) • Android Studio at C:\Users\clang\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-1\213.7172.25.2211.8571212 • Flutter plugin version 70.0.3 • Dart plugin version 213.7371 • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[√] Connected device (6 available) • Mi 9T (mobile) • 3d64a078 • android-arm64 • Android 10 (API 29) • SM G800F (mobile) • 52009a2368692331 • android-arm • Android 6.0.1 (API 23) • Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22000.978] • Chrome (web) • chrome • web-javascript • Google Chrome 105.0.5195.127 • Edge (web) • edge • web-javascript • Microsoft Edge 105.0.1343.50

[√] HTTP Host Availability • All required HTTP hosts are available

clangenb avatar Sep 28 '22 15:09 clangenb

The cause seems to be different. It is the actual execution of the callBackDispatcher, which destroys the channel. I updated the issue accordingly.

clangenb avatar Sep 30 '22 15:09 clangenb

We faced a similar issue. Just instead of in_app_webview, it kills the BLE connection of flutter_reactive_ble in our case. Apparently, the engine?.destroy() in BackgroundWorker.kt is responsible for this. Removing this line fixes this issue. @clangenb, if you're still facing this issue with in_app_webview, can you confirm?

What's the purpose of destroying the engine? Since other platform channels seem to reuse it, is it possible it should be created differently?

dominicmh avatar Feb 02 '24 09:02 dominicmh

We have stopped using the workmanager and the webview since a long time now, so I can't make a statement unfortunately.

clangenb avatar Feb 02 '24 10:02 clangenb