Skip to content

FlutterNativeView does not receive incoming BinaryMessages when running in CoroutineWorker #30957

@nrkramer

Description

@nrkramer

Steps to Reproduce

  1. Write boilerplate code to run a CoroutineWorker from WorkManager
  2. Write boilerplate code to run a callback routine in Flutter from kotlin. This callback opens a MethodChannel and sends 'initialized' to kotlin.
  3. Write boilerplate code to run isolate in CoroutineWorker, wait for initialized message in kotlin from flutter, then call whatever function you want in flutter from kotlin (through the same MethodChannel)
  4. Write boilerplate code to have flutter start this worker on a button press
  5. PRESS THE BUTTON!!!!

Here's my worker and flutter callback: https://gist.github.com/nrkramer/71f202302a177a454244c09188334b2b

Logs

[        ] Updating files
[ +644 ms] DevFS: Sync finished
[   +1 ms] Syncing files to device Android SDK built for x86... (completed in 2,555ms, longer than expected)
[        ] Synced 12.7MB.
[   +1 ms] Sending to VM service: _flutter.listViews({})
[   +3 ms] Result: {type: FlutterViewList, views: [{type: FlutterView, id: _flutterView/0xde4e270c, isolate: {type: @Isolate, fixedId: true, id: isolates/474932352, name: main.dart$main-474932352, number: 474932352}}]}
[        ] <- accept
[        ] Connected to _flutterView/0xde4e270c.
[   +2 ms] �  To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
[   +1 ms] An Observatory debugger and profiler on Android SDK built for x86 is available at: http://127.0.0.1:55664/
[        ] For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".
[+22655 ms] D/MainActivity( 9500): Notify run check requested
[  +23 ms] D/MainActivity( 9500): Notify is running: false
[+2755 ms] D/MainActivity( 9500): Immediate update requested
[ +294 ms] D/ShowtapNotifyJob( 9500): SetMethodCallHandler was set
[ +276 ms] I/flutter ( 9500): Callback dispatcher called
[  +16 ms] I/flutter ( 9500): Called initialized
[+4715 ms] D/ShowtapNotifyJob( 9500): Calling invokeMethod
[   +7 ms] I/flutter ( 9500): Method was called
[  +15 ms] I/WM-WorkerWrapper( 9500): Worker result SUCCESS for Work [ id=2ad8aaf4-5eb2-4abe-9d4e-8dfad326a428, tags={ apps.blanket.showtap.NotificationWorker } ]
[+36873 ms] D/EGL_emulation( 9500): eglMakeCurrent: 0xdff05960: ver 3 1 (tinfo 0xdff03850)
[+1810 ms] Service protocol connection closed.
[   +1 ms] Lost connection to device.
[   +3 ms] DevFS: Deleting filesystem on the device (file:///data/user/0/apps.blanket.showtap/code_cache/showtapEXYPXM/showtap/)
[   +1 ms] Sending to VM service: _deleteDevFS({fsName: showtap})
[ +256 ms] Ignored error while cleaning up DevFS: TimeoutException after 0:00:00.250000: Future not completed
[   +5 ms] "flutter run" took 93,638ms.
[        ] "flutter run" took 93,638ms.

   info - The value of the field '_imagesBaseURL' isn't used - lib\database\TMDbDatabase.dart:15:10 - unused_field
   info - Await only futures - lib\main.dart:14:3 - await_only_futures
   info - Unused import: 'package:showtap/custom_routes.dart' - lib\ui\pages\discover_page.dart:3:8 - unused_import
   info - Unused import: 'package:showtap/ui/pages/movie_details_page.dart' - lib\ui\pages\discover_page.dart:4:8 - unused_import
   info - Unused import: 'package:showtap/ui/widgets/movie_smallitem.dart' - lib\ui\pages\discover_page.dart:5:8 - unused_import
   info - Unused import: 'package:showtap/metadata/movie_metadata.dart' - lib\ui\pages\discover_page.dart:7:8 - unused_import
   info - Unused import: 'package:showtap/metadata/local_movie_db.dart' - lib\ui\pages\discover_page.dart:8:8 - unused_import

    • Flutter version 1.4.19-pre.3 at D:\Development\flutter
    • Framework revision 404f66d968 (2 hours ago), 2019-04-12 03:01:18 -0400
    • Engine revision f804c293f3
    • Dart version 2.2.1 (build 2.2.1-dev.4.2 None)


[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at D:\Android Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-Q, build-tools 28.0.3
    • Java binary at: D:\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    • All Android licenses accepted.

[√] Android Studio (version 3.3)
    • Android Studio at D:\Android Studio
    • Flutter plugin version 34.0.1
    • Dart plugin version 182.5215
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[√] VS Code, 64-bit edition (version 1.28.2)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 2.21.1

[√] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

• No issues found!

I've followed the guide here: https://medium.com/flutter-io/executing-dart-in-the-background-with-flutter-plugins-and-geofencing-2b3e40a1a124
And looked at the code here: https://github.com/talkdirty/android_job_scheduler

Minus the plugin registration since I don't need to use any plugins with the background job.

Any advice would be welcome :)

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