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.72k stars 3.97k forks source link

πŸ› [firebase_storage] [firebase_storage/unknown] An unknown error occurred, please check the server response.. Error thrown null. #7706

Closed Tom3652 closed 1 year ago

Tom3652 commented 2 years ago

Bug report

Describe the bug

I have an app in beta test and my users complained about a file upload that sometimes fails. I have logged my upload methods to firebase_storage and i saw sometimes this error :

Capture d’écran 2021-12-26 aΜ€ 15 29 38

I have also noticed this kind of error but i have no clue where this comes from :

[firebase_storage/unknown] File at URL: file:///var/mobile/Containers/Data/Application/DABF3DC5-1ABC-4824-B072-DEAC0F37144D/Documents/myappdir/b42e210-62ed-11ec-9430-f940facba-temp_file.mp4 is not reachable. Ensure file URL is not a directory, symbolic link, or invalid url..

Is it linked ? I don't know, as i don't know when this error is raised (ie: before upload, after upload, before download...).

Steps to reproduce

It works fine 90% of the time i would say but all of my users are experiencing it.
If this is a "normal" error, how can I debug this please to know the underlying cause ?

Expected behavior

The error should not be unknown so we (developer) can know the real problem and fix it.
The fact that we should check the server response, you will agree with me, is unfortunately useless for a solution such as firebase_storage that is serverless for developers.
But i would actually like to see this server response or anything that has a real explanation.


Additional context

For the upload logic, i am simply uploading local files (a thumbnail of a file saved in a new file and the main file).
Before upload i am compressing files and check if the Files exist locally and do not start by http. Then, i use the getDownloadUrl() method to get the URL and save it in my database.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` [βœ“] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-x64, locale fr-FR) β€’ Flutter version 2.8.1 at /Users/foxtom/Desktop/flutter β€’ Upstream repository https://github.com/flutter/flutter.git β€’ Framework revision 77d935af4d (10 days ago), 2021-12-16 08:37:33 -0800 β€’ Engine revision 890a5fca2e β€’ Dart version 2.15.1 [βœ“] Android toolchain - develop for Android devices (Android SDK version 31.0.0) β€’ Android SDK at /Users/foxtom/Library/Android/sdk β€’ Platform android-31, build-tools 31.0.0 β€’ Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java β€’ Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165) β€’ All Android licenses accepted. [βœ“] Xcode - develop for iOS and macOS (Xcode 13.2.1) β€’ Xcode at /Applications/Xcode.app/Contents/Developer β€’ CocoaPods version 1.11.2 [βœ“] Chrome - develop for the web β€’ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [βœ“] Android Studio (version 2020.3) β€’ Android Studio at /Applications/Android Studio.app/Contents β€’ Flutter plugin can be installed from: πŸ”¨ https://plugins.jetbrains.com/plugin/9212-flutter β€’ Dart plugin can be installed from: πŸ”¨ https://plugins.jetbrains.com/plugin/6351-dart β€’ Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165) [βœ“] VS Code (version 1.63.2) β€’ VS Code at /Users/foxtom/Desktop/Visual Studio Code.app/Contents β€’ Flutter extension version 3.29.0 [βœ“] Connected device (3 available) β€’ CPH1931 (mobile) β€’ ee9b32b5 β€’ android-arm64 β€’ Android 10 (API 29) β€’ macOS (desktop) β€’ macos β€’ darwin-x64 β€’ macOS 12.1 21C52 darwin-x64 β€’ Chrome (web) β€’ chrome β€’ web-javascript β€’ Google Chrome 96.0.4664.110 β€’ No issues found! ```

Flutter dependencies

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

Click To Expand ``` Dart SDK 2.15.1 Flutter SDK 2.8.1 myappname 1.0.0+1 dependencies: - app_settings 4.1.1 [flutter] - app_tracking_transparency 2.0.2+1 [flutter] - apple_maps_flutter 1.0.1 [flutter] - auto_size_text 3.0.0 [flutter] - badges 2.0.2 [flutter] - cached_network_image 3.2.0 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web] - camera 0.9.4+5 [camera_platform_interface camera_web flutter pedantic quiver flutter_plugin_android_lifecycle] - clipboard 0.1.3 [flutter] - cloud_functions 3.2.4 [cloud_functions_platform_interface cloud_functions_web firebase_core firebase_core_platform_interface flutter] - connectivity_plus 2.1.0 [flutter connectivity_plus_platform_interface connectivity_plus_linux connectivity_plus_macos connectivity_plus_web connectivity_plus_windows] - country_code_picker 2.0.2 [flutter modal_bottom_sheet collection universal_platform] - crypto 3.0.1 [collection typed_data] - cupertino_back_gesture 0.1.0 [flutter] - cupertino_icons 1.0.4 - disk_space 0.2.1 [flutter] - emoji_picker_flutter 1.0.8 [flutter shared_preferences] - extended_image 6.0.1 [extended_image_library flutter meta] - extended_tabs 2.3.0 [flutter] - firebase_analytics 9.0.4 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_auth 3.3.4 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 1.10.6 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 2.4.4 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_database 9.0.4 [firebase_core firebase_core_platform_interface firebase_database_platform_interface firebase_database_web flutter] - firebase_dynamic_links 4.0.3 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface] - firebase_messaging 11.2.4 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - firebase_performance 0.8.0+3 [firebase_core firebase_core_platform_interface firebase_performance_platform_interface firebase_performance_web flutter] - firebase_storage 10.2.4 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_app_badger 1.3.0 [flutter] - flutter_arc_text 0.5.0 [characters flutter] - flutter_contacts 1.1.1+2 [flutter] - flutter_facebook_auth 3.5.7 [flutter flutter_facebook_auth_platform_interface flutter_facebook_auth_web] - flutter_ffmpeg 0.4.2 [flutter] - flutter_image_compress 1.1.0 [flutter] - flutter_interactive_keyboard 0.2.0 [flutter] - flutter_localizations 0.0.0 [flutter intl characters clock collection meta path typed_data vector_math] - flutter_native_text_input 1.2.2 [flutter] - flutter_sound_lite 8.4.2 [path_provider recase uuid provider path synchronized logger flutter flutter_sound_platform_interface flutter_sound_web] - flutter_staggered_grid_view 0.5.0-dev.4 [flutter] - flutter_svg 1.0.0 [flutter meta path_drawing vector_math xml] - geocoding 2.0.1 [flutter geocoding_platform_interface] - geolocator 8.0.1 [flutter geolocator_platform_interface geolocator_android geolocator_apple geolocator_web] - google_fonts 2.1.1 [flutter http path_provider crypto] - google_maps_flutter 2.1.1 [flutter flutter_plugin_android_lifecycle google_maps_flutter_platform_interface] - google_mobile_ads 1.0.1 [meta flutter] - google_sign_in 5.2.1 [flutter google_sign_in_platform_interface google_sign_in_web meta] - hive 2.0.5 [meta crypto] - hive_flutter 1.1.0 [flutter hive path_provider path] - http 0.13.4 [async http_parser meta path] - image_editor 1.0.2 [flutter] - in_app_purchase 2.0.1 [flutter in_app_purchase_platform_interface in_app_purchase_android in_app_purchase_storekit] - in_app_review 2.0.3 [flutter in_app_review_platform_interface] - intl 0.17.0 [clock path] - logger 1.1.0 - native_admob_flutter 1.5.0 [flutter] - package_info_plus 1.3.0 [flutter package_info_plus_platform_interface package_info_plus_linux package_info_plus_macos package_info_plus_windows package_info_plus_web] - path 1.8.0 - path_provider 2.0.8 [flutter path_provider_android path_provider_ios path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows] - percent_indicator 3.4.0 [flutter] - perfect_volume_control 1.0.5 [flutter] - permission_handler 8.3.0 [flutter meta permission_handler_platform_interface] - photo_manager 1.3.10 [flutter] - provider 6.0.1 [collection flutter nested] - pull_to_refresh 2.0.0 [flutter] - rive 0.8.1 [collection flutter graphs http meta] - screen_capture_event 1.0.0+1 [flutter permission_handler] - scrollable_positioned_list 0.2.3 [flutter collection] - share_plus 3.0.4 [meta mime flutter share_plus_platform_interface share_plus_linux share_plus_macos share_plus_windows share_plus_web] - shared_preferences 2.0.11 [flutter meta shared_preferences_android shared_preferences_ios shared_preferences_linux shared_preferences_macos shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] - sign_in_with_apple 3.3.0 [flutter meta sign_in_with_apple_platform_interface sign_in_with_apple_web] - sliver_tools 0.2.5 [flutter] - sqflite 2.0.1 [flutter sqflite_common path] - translator 0.1.7 [http] - url_launcher 6.0.17 [flutter meta 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.5 [crypto] - video_compress 3.1.1 [flutter] - video_player 2.2.10 [flutter meta video_player_platform_interface video_player_web html] - video_thumbnail 0.4.3 [flutter] - visibility_detector 0.2.2 [flutter] dev dependencies: - build_runner 2.1.7 [args async analyzer build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http_multi_server io js logging meta mime package_config path pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml] - flutter_lints 1.0.4 [lints] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data] - hive_generator 1.1.1 [build source_gen hive analyzer source_helper] transitive dependencies: - _fe_analyzer_shared 31.0.0 [meta] - analyzer 2.8.0 [_fe_analyzer_shared cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - args 2.3.0 - async 2.8.2 [collection meta] - boolean_selector 2.1.0 [source_span string_scanner] - build 2.2.1 [analyzer async convert crypto glob logging meta path] - build_config 1.0.0 [checked_yaml json_annotation path pubspec_parse yaml] - build_daemon 3.0.1 [built_collection built_value http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 2.0.6 [analyzer async build crypto graphs logging path package_config pool pub_semver stream_transform yaml] - build_runner_core 7.2.3 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pool timing watcher yaml] - built_collection 5.1.1 - built_value 8.1.3 [built_collection collection fixnum meta] - cached_network_image_platform_interface 1.0.0 [flutter flutter_cache_manager] - cached_network_image_web 1.0.1 [flutter flutter_cache_manager cached_network_image_platform_interface] - camera_platform_interface 2.1.1 [cross_file flutter meta plugin_platform_interface stream_transform] - camera_web 0.2.1+1 [camera_platform_interface flutter flutter_web_plugins stream_transform] - characters 1.2.0 - charcode 1.3.1 - checked_yaml 2.0.1 [json_annotation source_span yaml] - cli_util 0.3.5 [meta path] - clock 1.1.0 - cloud_functions_platform_interface 5.0.19 [firebase_core flutter meta plugin_platform_interface] - cloud_functions_web 4.2.5 [cloud_functions_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - code_builder 4.1.0 [built_collection built_value collection matcher meta] - collection 1.15.0 - connectivity_plus_linux 1.1.1 [flutter connectivity_plus_platform_interface meta nm] - connectivity_plus_macos 1.2.1 [connectivity_plus_platform_interface flutter] - connectivity_plus_platform_interface 1.1.1 [flutter meta plugin_platform_interface] - connectivity_plus_web 1.1.0+1 [connectivity_plus_platform_interface flutter_web_plugins flutter] - connectivity_plus_windows 1.2.0 [connectivity_plus_platform_interface flutter] - convert 3.0.1 [typed_data] - cross_file 0.3.2 [flutter js meta] - csslib 0.17.1 [source_span] - dart_style 2.2.1 [analyzer args path pub_semver source_span] - dbus 0.6.6 [args ffi meta xml] - extended_image_library 3.1.0 [crypto flutter http_client_helper path path_provider] - fake_async 1.2.0 [clock collection] - ffi 1.1.2 - file 6.1.2 [meta path] - firebase 9.0.2 [http http_parser js] - firebase_analytics_platform_interface 3.0.3 [firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.4.0+4 [firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_auth_platform_interface 6.1.9 [firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 3.3.5 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.2.3 [collection flutter meta plugin_platform_interface] - firebase_core_web 1.5.3 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.1.11 [collection firebase_core flutter meta plugin_platform_interface] - firebase_database_platform_interface 0.2.0+3 [collection firebase_core flutter meta plugin_platform_interface] - firebase_database_web 0.2.0+3 [firebase_core firebase_core_web firebase_database_platform_interface flutter flutter_web_plugins js] - firebase_dynamic_links_platform_interface 0.2.0+3 [firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 3.1.4 [firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 2.2.5 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - firebase_performance_platform_interface 0.1.0+3 [firebase_core flutter plugin_platform_interface] - firebase_performance_web 0.1.0+3 [firebase firebase_core firebase_core_web firebase_performance_platform_interface flutter flutter_web_plugins js] - firebase_storage_platform_interface 4.0.11 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.2.5 [async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - fixnum 1.0.0 - flutter_blurhash 0.6.0 [flutter meta pedantic] - flutter_cache_manager 3.3.0 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid] - flutter_facebook_auth_platform_interface 2.7.1 [flutter plugin_platform_interface] - flutter_facebook_auth_web 2.6.0+2 [flutter flutter_web_plugins js flutter_facebook_auth_platform_interface] - flutter_plugin_android_lifecycle 2.0.5 [flutter] - flutter_sound_platform_interface 8.4.2 [flutter meta plugin_platform_interface logger] - flutter_sound_web 8.4.2 [flutter_sound_platform_interface flutter logger flutter_web_plugins meta js] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - frontend_server_client 2.1.2 [async path] - geocoding_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - geolocator_android 3.0.1 [flutter geolocator_platform_interface] - geolocator_apple 2.0.0+2 [flutter geolocator_platform_interface] - geolocator_platform_interface 3.0.1 [flutter plugin_platform_interface vector_math meta] - geolocator_web 2.1.1 [flutter flutter_web_plugins geolocator_platform_interface] - glob 2.0.2 [async collection file path string_scanner] - google_maps_flutter_platform_interface 2.1.3 [collection flutter meta plugin_platform_interface stream_transform] - google_sign_in_platform_interface 2.1.0 [flutter meta quiver] - google_sign_in_web 0.10.0+3 [flutter flutter_web_plugins google_sign_in_platform_interface js meta] - graphs 2.1.0 [collection] - html 0.15.0 [csslib source_span] - http_client_helper 2.0.2 [http] - http_multi_server 3.0.1 [async] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - in_app_purchase_android 0.2.2 [collection flutter in_app_purchase_platform_interface json_annotation meta] - in_app_purchase_platform_interface 1.3.0 [flutter plugin_platform_interface] - in_app_purchase_storekit 0.2.1 [collection flutter in_app_purchase_platform_interface json_annotation meta] - in_app_review_platform_interface 2.0.2 [flutter url_launcher plugin_platform_interface platform] - io 1.0.3 [meta path string_scanner] - js 0.6.3 - json_annotation 4.4.0 [meta] - lints 1.0.1 - logging 1.0.2 - matcher 0.12.11 [stack_trace] - meta 1.7.0 - mime 1.0.1 - modal_bottom_sheet 2.0.0 [flutter] - nested 1.0.0 [flutter] - nm 0.4.2 [dbus] - octo_image 1.0.1 [flutter flutter_blurhash] - package_config 2.0.2 [path] - package_info_plus_linux 1.0.3 [package_info_plus_platform_interface flutter path] - package_info_plus_macos 1.3.0 [flutter] - package_info_plus_platform_interface 1.0.2 [flutter meta plugin_platform_interface] - package_info_plus_web 1.0.4 [flutter flutter_web_plugins http meta package_info_plus_platform_interface] - package_info_plus_windows 1.0.4 [package_info_plus_platform_interface ffi flutter win32] - path_drawing 1.0.0 [vector_math meta path_parsing flutter] - path_parsing 1.0.0 [vector_math meta] - path_provider_android 2.0.11 [flutter path_provider_platform_interface] - path_provider_ios 2.0.7 [flutter path_provider_platform_interface] - path_provider_linux 2.1.4 [ffi flutter meta path path_provider_platform_interface xdg_directories] - path_provider_macos 2.0.4 [flutter meta path_provider_platform_interface] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.4 [ffi flutter meta path path_provider_platform_interface win32] - pedantic 1.11.1 - permission_handler_platform_interface 3.7.0 [flutter meta plugin_platform_interface] - petitparser 4.4.0 [meta] - platform 3.1.0 - plugin_platform_interface 2.0.2 [meta] - pool 1.5.0 [async stack_trace] - process 4.2.4 [file path platform] - pub_semver 2.1.0 [collection meta] - pubspec_parse 1.2.0 [checked_yaml collection json_annotation pub_semver yaml] - quiver 3.0.1+1 [matcher] - recase 4.0.0 - rxdart 0.27.3 - share_plus_linux 2.0.4 [share_plus_platform_interface file flutter meta url_launcher] - share_plus_macos 2.0.2 [share_plus_platform_interface flutter] - share_plus_platform_interface 2.0.1 [flutter meta mime plugin_platform_interface] - share_plus_web 2.0.4 [share_plus_platform_interface url_launcher flutter flutter_web_plugins meta] - share_plus_windows 2.0.3 [share_plus_platform_interface flutter meta url_launcher] - shared_preferences_android 2.0.9 [flutter meta shared_preferences_platform_interface] - shared_preferences_ios 2.0.8 [flutter meta shared_preferences_platform_interface] - shared_preferences_linux 2.0.3 [file flutter meta path path_provider_linux shared_preferences_platform_interface] - shared_preferences_macos 2.0.2 [flutter shared_preferences_platform_interface] - shared_preferences_platform_interface 2.0.0 [flutter] - shared_preferences_web 2.0.2 [flutter flutter_web_plugins meta shared_preferences_platform_interface] - shared_preferences_windows 2.0.3 [file flutter meta path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - shelf 1.2.0 [async collection http_parser path stack_trace stream_channel] - shelf_web_socket 1.0.1 [shelf stream_channel web_socket_channel] - sign_in_with_apple_platform_interface 1.0.0 [flutter plugin_platform_interface meta] - sign_in_with_apple_web 1.0.1 [flutter flutter_web_plugins sign_in_with_apple_platform_interface js] - sky_engine 0.0.99 - source_gen 1.2.1 [analyzer async build dart_style glob meta path source_span yaml] - source_helper 1.3.1 [analyzer collection source_gen] - source_span 1.8.1 [collection path term_glyph] - sqflite_common 2.1.0 [synchronized path meta] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - stream_transform 2.0.0 - string_scanner 1.1.0 [charcode source_span] - synchronized 3.0.0 - term_glyph 1.2.0 - test_api 0.4.3 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - timing 1.0.0 [json_annotation] - typed_data 1.3.0 [collection] - universal_platform 1.0.0+1 - url_launcher_android 6.0.13 [flutter meta url_launcher_platform_interface] - url_launcher_ios 6.0.13 [flutter meta url_launcher_platform_interface] - url_launcher_linux 2.0.2 [flutter] - url_launcher_macos 2.0.2 [flutter] - url_launcher_platform_interface 2.0.4 [flutter plugin_platform_interface] - url_launcher_web 2.0.5 [flutter flutter_web_plugins meta url_launcher_platform_interface] - url_launcher_windows 2.0.2 [flutter] - vector_math 2.1.1 - video_player_platform_interface 5.0.0 [flutter plugin_platform_interface] - video_player_web 2.0.5 [flutter flutter_web_plugins meta pedantic video_player_platform_interface] - watcher 1.0.1 [async path] - web_socket_channel 2.1.0 [async crypto stream_channel] - win32 2.3.3 [ffi] - xdg_directories 0.2.0 [meta path process] - xml 5.3.1 [collection meta petitparser] - yaml 3.1.0 [collection source_span string_scanner] ```

darshankawar commented 2 years ago

@Tom3652 Can you provide the entire crash log in text format that includes the server response message ? There was a similar issue reported and one of the issue comment is that the error could be coming from firebase-ios-sdk, but I couldn't find the original issue.

Tom3652 commented 2 years ago

Actually there is no server response and that's the problem, it's a custom Crashlytics trace that i have made myself (using the catchError method on the UploadTask) so there is nothing else than this line...

I have seen these comments, so do you suggest i try on Android and see if i get a useful error ?

In any case, there is no way to get a useful error on iOS ? This is very hard to debug especially since the error doesn't occur all the time (a permission-denied would always return an error)

Tom3652 commented 2 years ago

Well on Android i have this error :

E/StorageException(15225): StorageException has occurred.
E/StorageException(15225): An unknown error occurred, please check the HTTP result code and inner exception for server response.
E/StorageException(15225):  Code: -13000 HttpResult: 200
E/StorageException(15225): The server has terminated the upload session
E/StorageException(15225): java.io.IOException: The server has terminated the upload session
E/StorageException(15225):  at com.google.firebase.storage.UploadTask.recoverStatus(UploadTask.java:373)
E/StorageException(15225):  at com.google.firebase.storage.UploadTask.shouldContinue(UploadTask.java:325)
E/StorageException(15225):  at com.google.firebase.storage.UploadTask.run(UploadTask.java:232)
E/StorageException(15225):  at com.google.firebase.storage.StorageTask.lambda$getRunnable$7$StorageTask(StorageTask.java:1072)
E/StorageException(15225):  at com.google.firebase.storage.-$$Lambda$StorageTask$q9YBoR_A8LB-JxTCx8JRQvabaZs.run(Unknown Source:2)
E/StorageException(15225):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/StorageException(15225):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/StorageException(15225):  at java.lang.Thread.run(Thread.java:919)

Also not useful...

darshankawar commented 2 years ago

The Android log is same as mentioned in the original issue and comment.

I'll keep it open and label for further investigation.

/cc @russellwheatley @helenaford. This was originally reported https://github.com/FirebaseExtended/flutterfire/issues/3791 but still seems to be happening.

Tom3652 commented 2 years ago

Yes it's the same first part but there is no clause Caused by... so it's also not explicit in Android :/

I have no clue what this is about in both Android and iOS... Thanks for investigating.

Tom3652 commented 2 years ago

All of my beta testers that have experienced an error during upload show this log in my crashlytics dashboard.
But they all said that it seems that the upload is always finished (100% according to my UI in app) and only then it throws this error, never before uploading.

Capture d’écran 2022-01-07 aΜ€ 13 59 35

I had a related issue server-side on another project without firebase, when uploading MultipartFile in HTTP POST request. The upload was always fine until 100%, then i was getting a 400 Bad request because of a proxy configuration server side. I have no clue about the configuration in FirebaseStorage server, that's why having the "real" error and not unknown would be really helpful if it's a client side issue or server side.

Tom3652 commented 2 years ago

I have reached out Firebase support regarding this because i had logs from iOS especially. They were able to reproduce my issue with a sample code. They told me to add Metadata Content-Type to either video/mp4 or image/jpeg.

Unfortunately this didn't fix the problem... Here are the logs from iOS :

Task <24E18897-20B7-45FD-9621-85FF09DC6326>.<1> finished with error [-1017] Error Domain=NSURLErrorDomain Code=-1017 "cannot parse response" UserInfo={_kCFStreamErrorCodeKey=-1, _NSURLErrorFailingURLSessionTaskErrorKey=BackgroundUploadTask <24E18897-20B7-45FD-9621-85FF09DC6326>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "BackgroundUploadTask <24E18897-20B7-45FD-9621-85FF09DC6326>.<1>",
    "LocalUploadTask <24E18897-20B7-45FD-9621-85FF09DC6326>.<1>"
), NSLocalizedDescription=cannot parse response, _kCFStreamErrorDomainKey=4, NSErrorFailingURLStringKey=https://firebasestorage.googleapis.com/v0/b/mybucket/o/user%2FNyq7dMqe1kcAZ77R1YwH5fsAkV83%2Fcontent%2F43aa2d41-7a19-11ec-bd39-85fcd9d025?uploadType=resumable&name=user%2FNqe1kcAZ77R1YwH5fsAkV83%2Fcontent%2F43aa2d41-7a19-11ec-bd39-8508fcd025&upload_id=ADPycdv0-OYZPx3zAGzLrn25ZdI9srgkgABHGKb_1fCqUO7AAPHsZTkz_iVX1NfuYQsn0LHgCCiOsSzhLiP4Ho7VynSf_ceJJw&upload_protocol=resumable, NSErrorFailingURLKey=https://firebasestorage.googleapis.com/v0/b/mybucket/o/user%2FNyqMqe1kcAZ77R1YwH5fsAkV83%2Fcontent%2F43aa2d41-7a19-11ec-bd39-8508fcd9d025?uploadType=resumable&name=user%2FNyq7dMqe1kcAZ77R1YwH5V83%2Fcontent%2F432d41-7a19-11ec-bd39-8508f9d025&upload_id=ADPycdv0-OYZPx3zAGzLrn25ZdI9srgkgABHGKb_1fCqUO7AAPHsZTkz_iVX1NfuYQsn0LHgCCiOsSzhLiP4Ho7VynSf_ceJJw&upload_protocol=resumable}
GTMSessionFetcher invoking fetch callbacks, data (null), error Error Domain=NSURLErrorDomain Code=-1017 "cannot parse response" UserInfo={_kCFStreamErrorCodeKey=-1, _NSURLErrorFailingURLSessionTaskErrorKey=BackgroundUploadTask <24E18897-20B7-45FD-9621-85FF09DC6326>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "BackgroundUploadTask <24E18897-20B7-45FD-9621-85FF09DC6326>.<1>",
    "LocalUploadTask <24E18897-20B7-45FD-9621-85FF09DC6326>.<1>"
), NSLocalizedDescription=cannot parse response, _kCFStreamErrorDomainKey=4, NSErrorFailingURLStringKey=https://firebasestorage.googleapis.com/v0/b/mybucket/o/users%2FNyq7dMqe1kcAZ77R1YwH5fsAkV83%2Fcontent%2F43aa2d41-7a19-11ec-bd39-8508fcd9d025?uploadType=resumable&name=users%2FNyq7dMqe1kcAZ77R1YwH5fsAkV83%2Fposts%2F43aa2d41-7a19-11ec-bd39-8508fcd9d025s&upload_id=ADPycdv0-OYZPx3zAGzLrn25ZdI9srgkgABHGKb_1fCqUO7AAPHsZTkz_iVX1NfuYQsn0LHgCCiOsSzhLiP4Ho7VynSf_ceJJw&upload_protocol=resumable, NSErrorFailingURLKey=https://firebasestorage.googleapis.com/v0/b/mybucket/o/user%2FNyq7dMqe1kcAZ77R1YwH5fsAkV83%2Fcontent%2F43aa2d41-7a19-11ec-bd39-8508fcd9d025-low_res?uploadType=resumable&name=user%2FNyq7dMqe1kcAZ77R1YwH5fsAkV83%2Fposts%2F43aa2d41-7a19-11ec-bd39-8508f&upload_id=ADPycdv0-OYZPx3zAGzLrn25ZdI9srgkgABHGKb_1fCqUO7AAPHsZTkz_iVX1NfuYQsn0LHgCCiOsSzhLiP4Ho7VynSf_ceJJw&upload_protocol=resumable}

The code sample is :

import 'dart:async';
import 'dart:io';

import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:path_provider/path_provider.dart';
import 'package:uuid/uuid.dart';
import 'package:video_compress/video_compress.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(const TestApp());
}

class TestApp extends StatefulWidget {
  const TestApp({Key? key}) : super(key: key);

  @override
  _TestAppState createState() => _TestAppState();
}

class _TestAppState extends State<TestApp> {
  final List<UploadTask> task = [];

  Future<String> saveTempFile(
      {required File current, bool lowRes = false}) async {
    print("Saving temp file low res : $lowRes");
    Directory dir = await getApplicationDocumentsDirectory();
    Directory dev = Directory(dir.path + "/dev");
    if (!dev.existsSync()) {
      dev.createSync();
    }
    File file = File(dev.path + "/" + const Uuid().v1() + ".mp4");
    file.writeAsBytes(current.readAsBytesSync());
    return file.path;
  }

  void clearDir() async {
    Directory dir = await getApplicationDocumentsDirectory();
    Directory dev = Directory(dir.path + "/dev");
    if (dev.existsSync()) {
      dev.delete(recursive: true);
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Stack(
          children: [
            ListView.builder(
              itemBuilder: (ctx, index) {
                return ShowUploadWidget(task: task[index], count: task.length);
              },
              itemCount: task.length,
            ),
            if (task.length <= 30)
              Center(
                child: GestureDetector(
                  onTap: () async {
                    XFile? picked = await ImagePicker()
                        .pickVideo(source: ImageSource.gallery);
                    if (picked != null) {
                      for (int i = 0; i < 30; i++) {
                        String file = await saveTempFile(current: File(picked.path));
                        UploadTask main = FirebaseStorage.instance
                            .ref()
                            .child("test")
                            .child(const Uuid().v1())
                            .putFile(File(file));
                        main.catchError((error) {

                        });
                        task.add(main);
                      }
                      setState(() {});
                    }
                  },
                  child: Container(
                    width: 200,
                    height: 200,
                    color: Colors.blue,
                    child: const Center(child: Text("Pick video")),
                  ),
                ),
              ),
          ],
        ),
      ),
    );
  }
}

class ShowUploadWidget extends StatefulWidget {
  const ShowUploadWidget({Key? key, required this.task, required this.count})
      : super(key: key);

  final UploadTask task;
  final int count;

  @override
  State<ShowUploadWidget> createState() => _ShowUploadWidgetState();
}

class _ShowUploadWidgetState extends State<ShowUploadWidget> {
  double progress = 0;
  late StreamSubscription subscription;

  String? error;

  void initListener() {
    subscription = widget.task.snapshotEvents.listen((event) {
      setState(() {
        progress = event.bytesTransferred / event.totalBytes * 100;
        print("Progress for task : ${widget.count} : $progress %");
      });
    });
    widget.task.catchError((e) {
      setState(() {
        error = e;
      });
    });
  }

  @override
  void dispose() {
    subscription.cancel();
    super.dispose();
  }

  @override
  void initState() {
    initListener();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: error != null ? Text("Error : $error") : Text("Uploading : $progress"),
    );
  }
}
ggirotto commented 2 years ago

I'm facing the same issue while trying to interact with Firebase Storage Emulator. The picture is uploaded but it fails with this same error.

allyssonmast commented 2 years ago

The same with me on iOS device. For Android and Web works fine. version: firebase_storage: ^10.2.9

Tom3652 commented 2 years ago

I have reduced a lot this error by using putData instead of putFile method.

It seems that there is an issue with how Firebase iOS SDK tries to validate Flutter files

allyssonmast commented 2 years ago

Nice, I tried a couple times use putData and the error did not appear so far (For now).

torstenek commented 2 years ago

putData gives me the error every time on a MBPro M1 Max when I run against the emulators. The file does get uploaded though. I did merge pr 4358 from firebase-tools and can verify that the file is also correctly exported and loaded from export.

russellwheatley commented 2 years ago

I'm facing the same issue while trying to interact with Firebase Storage Emulator. The picture is uploaded but it fails with this same error.

@ggirotto The emulator bug has an issue raised on the firebase-tools here which occurs only on iOS.

Lyokone commented 1 year ago

Since the emulator error and Firebase iOS SDK error have been solved, I'll close this.