firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.7k stars 3.97k forks source link

🐛 [firebase_storage] Warning printed when performing operation fails #11667

Closed OutdatedGuy closed 11 months ago

OutdatedGuy commented 1 year ago

Bug report

Describe the bug Following warning is printed in the console when using the firebase_storage function when an operation is failed due to permission denied by storage rules.

The 'plugins.flutter.io/firebase_storage' channel sent a message from native to Flutter on a non-platform thread. Platform channel messages must be sent on the platform thread. Failure to do so may result in data loss or crashes, and must be fixed in the plugin or application code creating that channel.

Steps to reproduce

Steps to reproduce the behavior:

  1. Create a flutter project with firebase storage initialization
  2. Set firebase storage rules to deny all operations
  3. Try to perform an operation on firebase storage that'll get denied
  4. This warning is printed

Additional context

In my case I was using iOS emulator that was connected to a local firebase emulator.

My denied operation was an image upload that printed this message.


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, 3.13.6, on macOS 14.0 23A344 darwin-arm64, locale en-IN) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.0) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.3) [✓] VS Code (version 1.82.2) [✓] VS Code (version 1.83.0-insider) [✓] Connected device (4 available) [✓] Network resources • No issues found! ```

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand ``` Dart SDK 3.1.3 Flutter SDK 3.13.6 client_app_5amclub 5.0.0+16 dependencies: - algolia_helper_flutter 0.4.1 [algolia_insights algoliasearch collection flutter logging meta rxdart] - animated_text_kit 4.2.2 [flutter characters] - awesome_notifications 0.7.5-dev.3 [flutter flutter_web_plugins plugin_platform_interface intl] - badges 3.1.2 [flutter] - cached_network_image 3.2.3 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web] - cached_video_player 2.0.4 [meta video_player_platform_interface video_player_web flutter flutter_test] - carousel_slider 4.2.1 [flutter] - cloud_firestore 4.9.2 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - cloud_functions 4.4.1 [cloud_functions_platform_interface cloud_functions_web firebase_core firebase_core_platform_interface flutter] - dotted_border 2.0.0+3 [flutter path_drawing] - email_validator 2.1.17 - ensure_visible_when_focused 1.1.1 [flutter] - firebase_analytics 10.5.0 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_app_check 0.2.0+1 [firebase_app_check_platform_interface firebase_app_check_web firebase_core firebase_core_platform_interface flutter] - firebase_auth 4.10.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.17.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 3.3.6 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_messaging 14.6.8 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - firebase_performance 0.9.2+6 [firebase_core firebase_core_platform_interface firebase_performance_platform_interface firebase_performance_web flutter] - firebase_storage 11.2.7 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - flutter 0.0.0 [characters collection material_color_utilities meta vector_math web sky_engine] - flutter_dotenv 5.1.0 [flutter] - flutter_easyloading 3.0.5 [flutter flutter_spinkit] - flutter_svg 2.0.7 [flutter vector_graphics vector_graphics_codec vector_graphics_compiler] - font_awesome_flutter 10.5.0 [flutter] - google_fonts 6.1.0 [flutter http path_provider crypto] - image_cropper 5.0.0 [flutter image_cropper_platform_interface image_cropper_for_web] - image_picker 1.0.4 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_linux image_picker_macos image_picker_platform_interface image_picker_windows] - infinite_scroll_pagination 4.0.0 [flutter flutter_staggered_grid_view sliver_tools] - intl 0.18.1 [clock meta path] - intl_phone_field 3.2.0 [flutter] - just_the_tooltip 0.0.12 [flutter] - lottie 2.6.0 [archive flutter path vector_math] - pin_code_fields 8.0.1 [flutter] - progress_border 0.1.2 [flutter] - provider 6.0.5 [collection flutter nested] - razorpay_flutter 1.3.5 [flutter eventify fluttertoast package_info_plus] - readmore 2.2.0 [flutter] - receive_sharing_intent 1.4.5 [flutter] - rounded_loading_button 2.1.0 [flutter rxdart] - timeline_tile 2.0.0 [flutter] - upgrader 8.1.0 [flutter device_info_plus html http os_detect package_info_plus shared_preferences url_launcher version xml] - url_launcher 6.1.14 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - uuid 3.0.7 [crypto] dev dependencies: - flutter_lints 2.0.3 [lints] - flutter_native_splash 2.3.2 [args flutter flutter_web_plugins js html image meta path universal_io xml yaml] - flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math async boolean_selector characters collection material_color_utilities meta source_span stream_channel string_scanner term_glyph web] - icons_launcher 2.1.3 [args image path universal_io yaml] - package_rename 1.5.0 [args html logger yaml] transitive dependencies: - _flutterfire_internals 1.3.7 [collection firebase_core firebase_core_platform_interface flutter meta] - algolia_client_core 0.2.3 [dio] - algolia_client_insights 0.2.3 [algolia_client_core json_annotation collection] - algolia_client_search 0.2.3 [algolia_client_core json_annotation collection] - algolia_insights 0.2.1 [algolia_client_insights collection flutter hive logging meta path_provider rxdart uuid] - algoliasearch 0.2.3 [algolia_client_core algolia_client_search algolia_client_insights json_annotation collection] - archive 3.4.0 [crypto path pointycastle] - args 2.4.2 - async 2.11.0 [collection meta] - boolean_selector 2.1.1 [source_span string_scanner] - cached_network_image_platform_interface 2.0.0 [flutter flutter_cache_manager] - cached_network_image_web 1.0.2 [flutter flutter_cache_manager cached_network_image_platform_interface] - characters 1.3.0 - clock 1.1.1 - cloud_firestore_platform_interface 5.16.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 3.7.1 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - cloud_functions_platform_interface 5.5.1 [firebase_core flutter meta plugin_platform_interface] - cloud_functions_web 4.6.1 [cloud_functions_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - collection 1.17.2 - convert 3.1.1 [typed_data] - cross_file 0.3.3+5 [js meta] - crypto 3.0.3 [typed_data] - csslib 1.0.0 [source_span] - device_info_plus 9.0.3 [device_info_plus_platform_interface ffi file flutter flutter_web_plugins meta win32 win32_registry] - device_info_plus_platform_interface 7.0.0 [flutter meta plugin_platform_interface] - dio 5.3.3 [async http_parser meta path] - eventify 1.0.1 - fake_async 1.3.1 [clock collection] - ffi 2.1.0 - file 6.1.4 [meta path] - file_selector_linux 0.9.2+1 [cross_file file_selector_platform_interface flutter] - file_selector_macos 0.9.3+3 [cross_file file_selector_platform_interface flutter] - file_selector_platform_interface 2.6.1 [cross_file flutter http plugin_platform_interface] - file_selector_windows 0.9.3+1 [cross_file file_selector_platform_interface flutter] - firebase_analytics_platform_interface 3.7.0 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.5.5 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_app_check_platform_interface 0.1.0+1 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_app_check_web 0.1.0+1 [_flutterfire_internals firebase_app_check_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_auth_platform_interface 6.19.0 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.8.1 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser js meta] - firebase_core_platform_interface 4.8.0 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.8.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.6.6 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 4.5.7 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 3.5.7 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - firebase_performance_platform_interface 0.1.4+6 [_flutterfire_internals firebase_core flutter plugin_platform_interface] - firebase_performance_web 0.1.4+6 [_flutterfire_internals firebase_core firebase_core_web firebase_performance_platform_interface flutter flutter_web_plugins js] - firebase_storage_platform_interface 4.4.6 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.6.7 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - flutter_blurhash 0.7.0 [flutter] - flutter_cache_manager 3.3.1 [clock collection file flutter http path path_provider rxdart sqflite uuid] - flutter_plugin_android_lifecycle 2.0.16 [flutter] - flutter_spinkit 5.2.0 [flutter] - flutter_staggered_grid_view 0.7.0 [flutter] - flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math web] - fluttertoast 8.2.2 [flutter flutter_web_plugins] - hive 2.2.3 [meta crypto] - html 0.15.4 [csslib source_span] - http 1.1.0 [async http_parser meta] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - image 4.1.0 [archive meta xml] - image_cropper_for_web 3.0.0 [flutter flutter_web_plugins image_cropper_platform_interface js] - image_cropper_platform_interface 5.0.0 [flutter plugin_platform_interface http] - image_picker_android 0.8.8 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - image_picker_for_web 3.0.1 [flutter flutter_web_plugins image_picker_platform_interface mime] - image_picker_ios 0.8.8+2 [flutter image_picker_platform_interface] - image_picker_linux 0.2.1+1 [file_selector_linux file_selector_platform_interface flutter image_picker_platform_interface] - image_picker_macos 0.2.1+1 [file_selector_macos file_selector_platform_interface flutter image_picker_platform_interface] - image_picker_platform_interface 2.9.1 [cross_file flutter http plugin_platform_interface] - image_picker_windows 0.2.1+1 [file_selector_platform_interface file_selector_windows flutter image_picker_platform_interface] - js 0.6.7 [meta] - json_annotation 4.8.1 [meta] - lints 2.1.1 - logger 2.0.2 - logging 1.2.0 - matcher 0.12.16 [async meta stack_trace term_glyph test_api] - material_color_utilities 0.5.0 [collection] - meta 1.9.1 - mime 1.0.4 - nested 1.0.0 [flutter] - octo_image 1.0.2 [flutter flutter_blurhash] - os_detect 2.0.1 - package_info_plus 4.1.0 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface win32] - package_info_plus_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - path 1.8.3 - path_drawing 1.0.1 [vector_math meta path_parsing flutter] - path_parsing 1.0.1 [vector_math meta] - path_provider 2.1.1 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows] - path_provider_android 2.2.0 [flutter path_provider_platform_interface] - path_provider_foundation 2.3.1 [flutter path_provider_platform_interface] - path_provider_linux 2.2.1 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_platform_interface 2.1.1 [flutter platform plugin_platform_interface] - path_provider_windows 2.2.1 [ffi flutter path path_provider_platform_interface win32] - petitparser 5.4.0 [meta] - platform 3.1.2 - plugin_platform_interface 2.1.6 [meta] - pointycastle 3.7.3 [collection convert js] - rxdart 0.27.7 - shared_preferences 2.2.1 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] - shared_preferences_android 2.2.1 [flutter shared_preferences_platform_interface] - shared_preferences_foundation 2.3.4 [flutter shared_preferences_platform_interface] - shared_preferences_linux 2.3.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface] - shared_preferences_platform_interface 2.3.1 [flutter plugin_platform_interface] - shared_preferences_web 2.2.1 [flutter flutter_web_plugins shared_preferences_platform_interface] - shared_preferences_windows 2.3.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - sky_engine 0.0.99 - sliver_tools 0.2.12 [flutter] - source_span 1.10.0 [collection path term_glyph] - sqflite 2.3.0 [flutter sqflite_common path] - sqflite_common 2.5.0 [synchronized path meta] - stack_trace 1.11.0 [path] - stream_channel 2.1.1 [async] - string_scanner 1.2.0 [source_span] - synchronized 3.1.0 - term_glyph 1.2.1 - test_api 0.6.0 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph] - typed_data 1.3.2 [collection] - universal_io 2.2.2 [collection meta typed_data] - url_launcher_android 6.1.0 [flutter url_launcher_platform_interface] - url_launcher_ios 6.1.5 [flutter url_launcher_platform_interface] - url_launcher_linux 3.0.6 [flutter url_launcher_platform_interface] - url_launcher_macos 3.0.7 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.1.5 [flutter plugin_platform_interface] - url_launcher_web 2.0.20 [flutter flutter_web_plugins url_launcher_platform_interface] - url_launcher_windows 3.0.8 [flutter url_launcher_platform_interface] - vector_graphics 1.1.7 [flutter vector_graphics_codec] - vector_graphics_codec 1.1.7 - vector_graphics_compiler 1.1.7 [args meta path_parsing xml vector_graphics_codec] - vector_math 2.1.4 - version 3.0.2 - video_player_platform_interface 5.1.4 [flutter plugin_platform_interface] - video_player_web 2.0.15 [flutter flutter_web_plugins video_player_platform_interface] - web 0.1.4-beta - win32 5.0.8 [ffi] - win32_registry 1.1.2 [ffi win32] - xdg_directories 1.0.3 [meta path] - xml 6.3.0 [collection meta petitparser] - yaml 3.1.2 [collection source_span string_scanner] ```

darshankawar commented 1 year ago

Thanks for the report @OutdatedGuy

A similar fix was made for firebase_database recently. Same will be done for storage as well.

Allansekyewa commented 1 year ago

@OutdatedGuy did you fix this

russellwheatley commented 1 year ago

@OutdatedGuy - please provide a repro code sample for this warning, please.

OutdatedGuy commented 1 year ago

Hi @russellwheatley, this error popped in my project which is too big, and I don't have time to create a separate code sample for this.

Can't you just use the plugin example instead?

OutdatedGuy commented 1 year ago

@OutdatedGuy did you fix this

No, I won't be fixing this

russellwheatley commented 1 year ago

@OutdatedGuy - could you point me to the specific API that causes the warning and I'll take a look? Thanks.

OutdatedGuy commented 1 year ago

Yo @russellwheatley, it occurred during upload file to firebase_storage using putData method. Below is my code for that:

Upload Code ```dart // Dart Packages import 'dart:async'; // Firebase Packages import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_storage/firebase_storage.dart'; // Third Party Packages import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:image_picker/image_picker.dart'; /// Uploading user profile image to Firebase Storage Future uploadProfileImage(XFile image) async { StreamSubscription? uploadStreamSub; try { final uid = FirebaseAuth.instance.currentUser!.uid; // getting reference for this user's profile image in storage Reference imageRef = FirebaseStorage.instance.ref('pfps').child('$uid profile.jpg'); var uploadTask = imageRef.putData( await image.readAsBytes(), SettableMetadata(contentType: 'image/jpg'), ); uploadStreamSub = uploadTask.snapshotEvents.listen((event) { if (event.state == TaskState.running) { double progress = event.bytesTransferred / event.totalBytes; EasyLoading.showProgress( progress, status: 'Uploading Profile Image...\n' '${(progress * 100).toStringAsFixed(0)}% Completed', maskType: EasyLoadingMaskType.black, ); } }); await uploadTask.whenComplete(() => null); imageRef = uploadTask.snapshot.ref; return imageRef.getDownloadURL(); } catch (e) { rethrow; } finally { uploadStreamSub?.cancel(); } } ```
wjmetcalfiiii commented 1 year ago

I have the same problem with details described in https://github.com/fluttercommunity/plus_plugins/discussions/2280

russellwheatley commented 11 months ago

This has been fixed with the migration to pigeon for Firebase Storage.