Closed awaik closed 10 months ago
Yes, I've checked them.
Here https://github.com/FirebaseExtended/flutterfire/issues/3671 was the workaround for firestore. Here was suggested to initiate the plugin within isolate.
But it is impossible for [firebase_storage] plugin because it demands to use WidgetsFlutterBinding.ensureInitialized()
before start.
And it is impossible to use WidgetsFlutterBinding.ensureInitialized()
into isolate.
Hi @awaik
Could you please provide a minimal complete reproducible code sample and your flutter pub deps -- --style=compact
(instead of the verbose tree).
Thank you
Can you try isolate_handler?
Hey @markusaksli-nc I made a repository https://github.com/awaik/test_firebase_storage_isolate It works on the iPhone simulator (already connected with firebase storage)
There are 2 cases:
runApp()
has been called (for example, during plugin initialization), then you need to explicitly call the WidgetsFlutterBinding.ensureInitialized()
first.
If you're running a test, you can call the TestWidgetsFlutterBinding.ensureInitialized()
as the first line in your test's main()
method to initialize the binding.Results of flutter pub deps -- --style=compact (instead of the verbose tree)
That is quite an old version of firebase storage but I was able to reproduce this on the latest master 1.26.0-18.0.pre.90
with
firebase_core: ^0.7.0
firebase_storage: ^7.0.0
The issue is caused by the fact that we cannot initialize Firebase in a non-main isolate due to the reliance on platform channel methods.
There have been a few issues about this before https://github.com/FirebaseExtended/flutterfire/issues/3124
@awaik For now you will just have to find a different solution.
Hello, has a solution to this problem been found?
Hey @awaik, it is possible to use isolates for FlutterFire but it depends on whether the underlying API communicates witht he native platform via method channel or event channel. If the API uses an event channel, it won't work. If the API uses a platform channel, it will work.
Here is an open issue to allow communication from native -> dart which would allow event channel communication: https://github.com/flutter/flutter/issues/119207
This article illustrates how to use isolates for a Firestore API that is using the method channel under the hood: https://invertase.io/blog/improve-flutter-performance-with-background-isolates-in-flutter-3-7
I'm going to close this issue out in favour of this issue which is the same problem: https://github.com/firebase/flutterfire/issues/10514
Bug report
Hi! When we upload a lot of files it is good to make it in a separate isolate. But when we try to create a reference to the storage
StorageReference reference = FirebaseStorage.instance.ref().child('file_name');
in the isolate we got the errorServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized. If you're running an application and need to access the binary messenger before
runApp()
has been called (for example, during plugin initialization), then you need to explicitly call theWidgetsFlutterBinding.ensureInitialized()
first. If you're running a test, you can call theTestWidgetsFlutterBinding.ensureInitialized()
as the first line in your test'smain()
method to initialize the binding.Steps to reproduce
Steps to reproduce the behavior:
StorageReference reference = FirebaseStorage.instance.ref().child('file_name');
Expected behavior
We should have the possibility to upload files to firebase storage in isolates.
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
``` Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 1.22.6, on macOS 11.1 20C69 darwin-x64, locale en-RU) [!] Android toolchain - develop for Android devices (Android SDK version 30.0.2) ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [✓] Xcode - develop for iOS and macOS (Xcode 12.1) ```Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
``` Dart SDK 2.10.5 Flutter SDK 1.22.6 popcrn 1.0.50 |-- auto_size_text 2.1.0 | '-- flutter... |-- better_player 0.0.48 | |-- cupertino_icons... | |-- flutter... | |-- flutter_hls_parser 1.0.0 | | |-- collection... | | |-- flutter... | | |-- meta... | | '-- quiver... | |-- flutter_widget_from_html_core 0.5.1+4 | | |-- flutter... | | '-- html 0.14.0+4 | | |-- csslib 0.16.2 | | | '-- source_span... | | '-- source_span... | |-- meta... | |-- path_provider... | |-- pedantic... | |-- visibility_detector... | '-- wakelock 0.2.1+1 | |-- flutter... | |-- meta... | |-- wakelock_platform_interface 0.1.0+1 | | |-- flutter... | | '-- meta... | '-- wakelock_web 0.1.0+3 | |-- flutter... | |-- flutter_web_plugins... | |-- import_js_library 1.0.2 | | |-- flutter... | | |-- flutter_web_plugins... | | |-- html... | | '-- js... | |-- js... | '-- wakelock_platform_interface... |-- build_runner 1.10.3 | |-- args 1.6.0 | |-- async 2.5.0-nullsafety.1 | | '-- collection... | |-- build 1.5.0 | | |-- analyzer... | | |-- async... | | |-- convert... | | |-- crypto... | | |-- glob... | | |-- logging... | | |-- meta... | | '-- path... | |-- build_config 0.4.2 | | |-- checked_yaml 1.0.2 | | | |-- json_annotation... | | | |-- source_span... | | | '-- yaml... | | |-- json_annotation... | | |-- meta... | | |-- path... | | |-- pubspec_parse... | | '-- yaml... | |-- build_daemon 2.1.4 | | |-- built_collection 4.3.2 | | | |-- collection... | | | '-- quiver... | | |-- built_value 7.1.0 | | | |-- built_collection... | | | |-- collection... | | | |-- fixnum 0.10.11 | | | '-- quiver... | | |-- http_multi_server... | | |-- logging... | | |-- path... | | |-- pedantic... | | |-- pool... | | |-- shelf... | | |-- shelf_web_socket... | | |-- stream_transform... | | |-- watcher... | | '-- web_socket_channel... | |-- build_resolvers 1.4.2 | | |-- analyzer... | | |-- build... | | |-- crypto... | | |-- graphs... | | |-- logging... | | |-- meta... | | |-- package_config 1.9.3 | | | |-- charcode... | | | '-- path... | | |-- path... | | |-- pool... | | '-- pub_semver... | |-- build_runner_core 6.0.3 | | |-- async... | | |-- build... | | |-- build_config... | | |-- build_resolvers... | | |-- collection... | | |-- convert... | | |-- crypto... | | |-- glob... | | |-- graphs... | | |-- json_annotation... | | |-- logging... | | |-- meta... | | |-- package_config... | | |-- path... | | |-- pedantic... | | |-- pool... | | |-- timing... | | |-- watcher... | | '-- yaml... | |-- code_builder 3.5.0 | | |-- built_collection... | | |-- built_value... | | |-- collection... | | |-- matcher... | | '-- meta... | |-- collection... | |-- crypto... | |-- dart_style 1.3.8 | | |-- analyzer... | | |-- args... | | |-- path... | | '-- source_span... | |-- glob 1.2.0 | | |-- async... | | |-- collection... | | |-- node_io 1.1.1 | | | |-- node_interop 1.1.1 | | | | '-- js... | | | '-- path... | | |-- path... | | |-- pedantic... | | '-- string_scanner... | |-- graphs 0.2.0 | |-- http_multi_server 2.2.0 | | '-- async... | |-- io 0.3.4 | | |-- charcode... | | |-- meta... | | |-- path... | | '-- string_scanner... | |-- js 0.6.2 | |-- logging 0.11.4 | |-- meta... | |-- mime 0.9.7 | |-- path... | |-- pedantic... | |-- pool 1.4.0 | | |-- async... | | '-- stack_trace... | |-- pub_semver 1.4.4 | | '-- collection... | |-- pubspec_parse 0.1.5 | | |-- checked_yaml... | | |-- json_annotation... | | |-- pub_semver... | | '-- yaml... | |-- shelf 0.7.9 | | |-- async... | | |-- collection... | | |-- http_parser... | | |-- path... | | |-- stack_trace... | | '-- stream_channel... | |-- shelf_web_socket 0.2.3 | | |-- shelf... | | |-- stream_channel... | | '-- web_socket_channel... | |-- stack_trace 1.10.0-nullsafety.1 | | '-- path... | |-- stream_transform 1.2.0 | |-- timing 0.1.1+2 | | '-- json_annotation... | |-- watcher 0.9.7+15 | | |-- async... | | |-- path... | | '-- pedantic... | |-- web_socket_channel 1.1.0 | | |-- async... | | |-- crypto... | | '-- stream_channel... | '-- yaml 2.2.1 | |-- charcode... | |-- collection... | |-- source_span... | '-- string_scanner... |-- cached_network_image 2.3.3 | |-- flutter... | |-- flutter_cache_manager 2.0.0 | | |-- clock... | | |-- file 5.2.1 | | | |-- intl... | | | |-- meta... | | | '-- path... | | |-- flutter... | | |-- http... | | |-- path... | | |-- path_provider... | | |-- pedantic... | | |-- rxdart... | | |-- sqflite... | | '-- uuid 2.2.2 | | |-- convert... | | '-- crypto... | '-- octo_image 0.3.0 | |-- flutter... | '-- flutter_blurhash 0.5.0 | |-- flutter... | '-- meta... |-- cloud_firestore 0.14.4 | |-- cloud_firestore_platform_interface 2.2.1 | | |-- collection... | | |-- firebase_core... | | |-- flutter... | | |-- meta... | | '-- plugin_platform_interface... | |-- cloud_firestore_web 0.2.1+2 | | |-- cloud_firestore_platform_interface... | | |-- firebase_core... | | |-- firebase_core_web... | | |-- flutter... | | |-- flutter_web_plugins... | | |-- http_parser... | | |-- js... | | '-- meta... | |-- firebase_core... | |-- firebase_core_platform_interface... | |-- flutter... | |-- meta... | '-- quiver... |-- crypto 2.1.5 | |-- collection... | |-- convert 2.1.1 | | |-- charcode... | | '-- typed_data... | '-- typed_data... |-- cupertino_icons 1.0.0 |-- dots_indicator 1.2.0 | '-- flutter... |-- file_picker 2.1.5+1 | |-- flutter... | |-- flutter_plugin_android_lifecycle 1.0.11 | | '-- flutter... | |-- flutter_web_plugins 0.0.0 | | |-- characters... | | |-- collection... | | |-- flutter... | | |-- meta... | | |-- typed_data... | | '-- vector_math... | '-- plugin_platform_interface 1.0.3 | '-- meta... |-- firebase_auth 0.18.4+1 | |-- firebase_auth_platform_interface 2.1.4 | | |-- firebase_core... | | |-- flutter... | | |-- meta... | | '-- plugin_platform_interface... | |-- firebase_auth_web 0.3.2+3 | | |-- firebase_auth_platform_interface... | | |-- firebase_core... | | |-- firebase_core_web... | | |-- flutter... | | |-- flutter_web_plugins... | | |-- http_parser... | | |-- intl... | | |-- js... | | '-- meta... | |-- firebase_core... | |-- firebase_core_platform_interface... | |-- flutter... | '-- meta... |-- firebase_core 0.5.3 | |-- firebase_core_platform_interface 2.1.0 | | |-- flutter... | | |-- meta... | | |-- plugin_platform_interface... | | '-- quiver... | |-- firebase_core_web 0.2.1+1 | | |-- firebase_core_platform_interface... | | |-- flutter... | | |-- flutter_web_plugins... | | |-- js... | | '-- meta... | |-- flutter... | |-- meta... | '-- quiver 2.1.3 | |-- matcher... | '-- meta... |-- firebase_dynamic_links 0.6.3 | |-- firebase_core... | '-- flutter... |-- firebase_messaging 7.0.3 | |-- firebase_core... | |-- flutter... | '-- meta... |-- firebase_storage 4.0.1 | |-- firebase_core... | '-- flutter... |-- flushbar 1.10.4 | '-- flutter... |-- flutter 0.0.0 | |-- characters 1.1.0-nullsafety.3 | |-- collection 1.15.0-nullsafety.3 | |-- meta 1.3.0-nullsafety.3 | |-- sky_engine 0.0.99 | |-- typed_data 1.3.0-nullsafety.3 | | '-- collection... | '-- vector_math 2.1.0-nullsafety.3 |-- flutter_app_badger 1.1.2 | '-- flutter... |-- flutter_google_places 0.2.6 | |-- flutter... | |-- google_maps_webservice... | |-- http... | '-- rxdart 0.24.1 |-- flutter_keyboard_size 0.1.2+2 | |-- flutter... | '-- provider... |-- flutter_staggered_grid_view 0.3.3 | '-- flutter... |-- flutter_svg 0.19.1 | |-- flutter... | |-- meta... | |-- path_drawing 0.4.1+1 | | |-- flutter... | | |-- meta... | | |-- path_parsing 0.1.4 | | | |-- meta... | | | '-- vector_math... | | '-- vector_math... | |-- vector_math... | '-- xml 4.5.1 | |-- collection... | |-- convert... | |-- meta... | '-- petitparser 3.1.0 | '-- meta... |-- flutter_swipe_action_cell 1.2.2 | '-- flutter... |-- flutter_test 0.0.0 | |-- async... | |-- boolean_selector 2.1.0-nullsafety.1 | | |-- source_span... | | '-- string_scanner... | |-- characters... | |-- charcode 1.2.0-nullsafety.1 | |-- clock 1.1.0-nullsafety.1 | |-- collection... | |-- fake_async 1.2.0-nullsafety.1 | | |-- clock... | | '-- collection... | |-- flutter... | |-- matcher 0.12.10-nullsafety.1 | | '-- stack_trace... | |-- meta... | |-- path... | |-- source_span 1.8.0-nullsafety.2 | | |-- charcode... | | |-- collection... | | |-- path... | | '-- term_glyph... | |-- stack_trace... | |-- stream_channel 2.1.0-nullsafety.1 | | '-- async... | |-- string_scanner 1.1.0-nullsafety.1 | | |-- charcode... | | '-- source_span... | |-- term_glyph 1.2.0-nullsafety.1 | |-- test_api 0.2.19-nullsafety.2 | | |-- async... | | |-- boolean_selector... | | |-- collection... | | |-- matcher... | | |-- meta... | | |-- path... | | |-- source_span... | | |-- stack_trace... | | |-- stream_channel... | | |-- string_scanner... | | '-- term_glyph... | |-- typed_data... | '-- vector_math... |-- geoflutterfire 2.2.1 | |-- cloud_firestore... | |-- flutter... | '-- rxdart... |-- get 3.16.0 | '-- flutter... |-- google_maps_webservice 0.0.18 | |-- http... | '-- meta... |-- google_sign_in 4.5.5 | |-- flutter... | |-- google_sign_in_platform_interface 1.1.2 | | |-- flutter... | | |-- meta... | | '-- quiver... | |-- google_sign_in_web 0.9.2 | | |-- flutter... | | |-- flutter_web_plugins... | | |-- google_sign_in_platform_interface... | | |-- js... | | '-- meta... | '-- meta... |-- hive 1.4.4+1 | |-- crypto... | '-- meta... |-- hive_flutter 0.3.1 | |-- flutter... | |-- hive... | |-- path 1.8.0-nullsafety.1 | '-- path_provider 1.6.27 | |-- flutter... | |-- path_provider_linux 0.0.1+2 | | |-- flutter... | | |-- path... | | |-- path_provider_platform_interface... | | '-- xdg_directories 0.1.2 | | |-- meta... | | |-- path... | | '-- process 3.0.13 | | |-- file... | | |-- intl... | | |-- meta... | | |-- path... | | '-- platform... | |-- path_provider_macos 0.0.4+4 | | '-- flutter... | |-- path_provider_platform_interface 1.0.3 | | |-- flutter... | | |-- meta... | | |-- platform 2.2.1 | | '-- plugin_platform_interface... | '-- path_provider_windows 0.0.4+1 | |-- ffi 0.1.3 | |-- flutter... | |-- meta... | |-- path... | |-- path_provider_platform_interface... | '-- win32 1.7.3 | '-- ffi... |-- hive_generator 0.8.1 | |-- analyzer 0.40.4 | | |-- _fe_analyzer_shared 11.0.0 | | | '-- meta... | | |-- args... | | |-- charcode... | | |-- cli_util 0.2.0 | | | '-- path... | | |-- collection... | | |-- convert... | | |-- crypto... | | |-- glob... | | |-- meta... | | |-- package_config... | | |-- path... | | |-- pub_semver... | | |-- source_span... | | |-- watcher... | | '-- yaml... | |-- build... | |-- dartx 0.5.0 | | |-- characters... | | |-- collection... | | |-- crypto... | | |-- meta... | | |-- path... | | '-- time 1.3.0 | |-- hive... | '-- source_gen 0.9.7+1 | |-- analyzer... | |-- async... | |-- build... | |-- dart_style... | |-- glob... | |-- meta... | |-- path... | |-- pedantic... | '-- source_span... |-- http 0.12.2 | |-- http_parser 3.1.4 | | |-- charcode... | | |-- collection... | | |-- source_span... | | |-- string_scanner... | | '-- typed_data... | |-- path... | '-- pedantic 1.9.2 | '-- meta... |-- image 2.1.19 | |-- archive 2.0.13 | | |-- args... | | |-- crypto... | | '-- path... | |-- meta... | '-- xml... |-- json_annotation 3.1.0 |-- json_serializable 3.5.0 | |-- analyzer... | |-- build... | |-- build_config... | |-- json_annotation... | |-- meta... | |-- path... | '-- source_gen... |-- like_button 1.0.4 | '-- flutter... |-- liquid_swipe 1.5.0 | |-- flutter... | '-- provider 4.3.2+2 | |-- collection... | |-- flutter... | '-- nested 0.0.4 | '-- flutter... |-- modal_progress_hud 0.1.3 | '-- flutter... |-- package_info 0.4.3+2 | '-- flutter... |-- percent_indicator 2.1.9 | '-- flutter... |-- photo_view 0.10.3 | '-- flutter... |-- sign_in_with_apple 2.5.4 | |-- flutter... | '-- meta... |-- skeleton_text 1.0.0 | '-- flutter... |-- snapping_sheet 2.0.2 | '-- flutter... |-- sqflite 1.3.2+2 | |-- flutter... | |-- path... | '-- sqflite_common 1.0.3 | |-- meta... | |-- path... | '-- synchronized 2.2.0+2 |-- supercharged 1.11.1 | |-- flutter... | '-- supercharged_dart 1.3.1 |-- syncfusion_flutter_sliders 18.3.53-beta | |-- flutter... | |-- intl 0.16.1 | | '-- path... | '-- syncfusion_flutter_core 18.3.53 | |-- flutter... | '-- pedantic... |-- video_compress 2.1.1 | '-- flutter... '-- visibility_detector 0.1.5 '-- flutter... ```