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] Crash java.lang.ArrayIndexOutOfBoundsException #9830

Closed GabrielAraujo closed 1 year ago

GabrielAraujo commented 2 years ago

Bug report

Describe the bug App crashes when the user tries to upload multiple files in a random order not necessarily waiting for the previous file upload actions to complete.

java.lang.ArrayIndexOutOfBoundsException: length=23; index=23
    at android.util.ContainerHelpers.binarySearch(ContainerHelpers.java:28)
    at android.util.SparseArray.put(SparseArray.java:249)
    at io.flutter.plugins.firebase.storage.FlutterFirebaseStorageTask.<init>(FlutterFirebaseStorageTask.java:55)
    at io.flutter.plugins.firebase.storage.FlutterFirebaseStorageTask.uploadFile
    at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin.lambda$taskPutFile$10(FlutterFirebaseStoragePlugin.java:425)
    at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin.$r8$lambda$C3Ka_3_IyaNcx1GMmRzpGhbHvfI
    at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin$$InternalSyntheticLambda$2$384b79831941738bb0e20044ff014d094712dd6f9c2130c4f8ed12e63c0c6dde$0.run
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:923)

Steps to reproduce

Steps to reproduce the behavior:

  1. Try uploading multiple files multiple times without awaiting for one to complete in order to start the next one.

Expected behavior

The app should not crash.

Sample project

N/A


Additional context

This issue was already reported here. This issue started to happen after we upgraded from the version 10.3.4 to 10.3.7 and still happens with version 10.3.10


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.3.4, on macOS 12.1 21C52 darwin-arm, locale en-BR) [āœ“] Android toolchain - develop for Android devices (Android SDK version 32.0.0) [āœ“] Xcode - develop for iOS and macOS (Xcode 13.4.1) [āœ“] Chrome - develop for the web [āœ“] Android Studio (version 2021.1) [āœ“] VS Code (version 1.72.0) [āœ“] Connected device (5 available) [āœ“] HTTP Host Availability ā€¢ No issues found! ```

Flutter dependencies

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

Click To Expand ``` Dart SDK 2.18.2 Flutter SDK 3.3.4 spectora_mobile 10.0.1+446 dependencies: - amplitude_flutter 3.10.0 [flutter flutter_web_plugins js] - animations 2.0.6 [flutter] - archive 3.3.0 [crypto path] - auto_route 5.0.1 [flutter path collection meta] - auto_size_text 3.0.0 [flutter] - build_runner 2.2.1 [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] - cached_network_image 3.2.2 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web] - camera 0.10.0+3 [camera_android camera_avfoundation camera_platform_interface camera_web flutter flutter_plugin_android_lifecycle quiver] - camerawesome 0.3.3 [rxdart flutter] - cloud_firestore 3.5.0 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - cloud_functions 3.3.9 [cloud_functions_platform_interface cloud_functions_web firebase_core firebase_core_platform_interface flutter] - core_card_io_beta 2.0.1 [flutter dataclass_beta json_annotation] - datetime_picker_formfield 2.0.1 [flutter intl] - device_info_plus 5.0.1 [flutter device_info_plus_platform_interface device_info_plus_macos device_info_plus_linux device_info_plus_web device_info_plus_windows] - drag_and_drop_gridview 2.0.1 [flutter] - easy_debounce 2.0.2+1 - enum_to_string 2.0.1 - exif 3.1.2 [args collection convert json_annotation sprintf] - file_picker 5.2.0+1 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface ffi path win32] - firebase_auth 3.11.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 1.24.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_storage 10.3.11 [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 sky_engine] - flutter_app_badger 1.5.0 [flutter] - flutter_badged 2.0.2 [flutter] - flutter_cache_manager_hive 0.0.9 [clock file flutter flutter_cache_manager hive http meta path path_provider pedantic rxdart uuid] - flutter_credit_card 3.0.4 [flutter] - flutter_data 1.4.7 [analyzer async build build_resolvers collection crypto equatable glob hive http inflection3 json_annotation meta path pubspec_parse recase riverpod source_gen source_helper state_notifier uuid] - flutter_data_json_api_adapter 0.7.1 [collection flutter_data json_api] - flutter_easyrefresh 2.2.2 [flutter] - flutter_hooks 0.18.5+1 [flutter] - flutter_html 2.2.1 [html csslib flutter_layout_grid video_player chewie webview_flutter chewie_audio flutter_svg flutter_math_fork collection numerus flutter] - flutter_image_compress 1.1.3 [flutter] - flutter_isolate 2.0.3 [flutter uuid] - flutter_keyboard_visibility 5.3.0 [meta flutter_keyboard_visibility_platform_interface flutter_keyboard_visibility_web flutter] - flutter_launcher_icons 0.10.0 [args checked_yaml cli_util image json_annotation path yaml] - flutter_local_notifications 12.0.0 [clock flutter flutter_local_notifications_linux flutter_local_notifications_platform_interface timezone] - flutter_native_image 0.0.6+1 [flutter] - flutter_native_splash 2.2.10+1 [args flutter flutter_web_plugins html image js meta path universal_io xml yaml] - flutter_phoenix 1.1.0 [flutter] - flutter_secure_storage 6.0.0 [flutter flutter_secure_storage_linux flutter_secure_storage_macos flutter_secure_storage_platform_interface flutter_secure_storage_web flutter_secure_storage_windows meta] - flutter_slidable 0.6.0 [flutter] - flutter_sticky_header 0.6.1 [flutter value_layout_builder] - flutter_svg 1.1.5 [flutter meta path_drawing vector_math xml] - flutter_vibrate 1.3.0 [flutter] - font_awesome_flutter 9.1.0 [flutter] - fuzzy 0.4.0-nullsafety.0 [latinize] - gallery_saver 2.3.2 [flutter path_provider http path] - google_fonts 3.0.1 [flutter http path_provider crypto] - hive 2.2.3 [meta crypto] - hooks_riverpod 1.0.3+1 [collection flutter flutter_hooks flutter_riverpod riverpod state_notifier] - html_unescape 2.0.0 - http 0.13.5 [async http_parser meta path] - image 3.2.0 [archive meta xml] - image_cropper 3.0.0 [flutter image_cropper_platform_interface image_cropper_for_web] - image_picker 0.8.6 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_platform_interface] - intercom_flutter 7.4.1 [flutter flutter_web_plugins intercom_flutter_platform_interface intercom_flutter_web] - intl 0.17.0 [clock path] - jiffy 5.0.0 [intl] - json_annotation 4.7.0 [meta] - local_auth 2.1.2 [flutter intl local_auth_android local_auth_ios local_auth_platform_interface local_auth_windows] - map_launcher 2.4.0 [flutter] - mime 1.0.2 - modal_bottom_sheet 2.1.2 [flutter] - native_device_orientation 1.1.4 [flutter meta] - package_info_plus 1.4.3+1 [flutter package_info_plus_platform_interface package_info_plus_linux package_info_plus_macos package_info_plus_windows package_info_plus_web] - path_provider 2.0.11 [flutter path_provider_android path_provider_ios path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows] - path_provider_android 2.0.20 [flutter path_provider_platform_interface] - path_provider_ios 2.0.11 [flutter path_provider_platform_interface] - perfect_volume_control 1.0.5 [flutter] - permission_handler 10.1.0 [flutter meta permission_handler_android permission_handler_apple permission_handler_windows permission_handler_platform_interface] - photo_view 0.14.0 [flutter] - recase 4.1.0 - reorderables 0.5.0 [flutter] - responsive_builder 0.4.3 [flutter] - sentry_flutter 6.11.2 [flutter flutter_web_plugins sentry package_info_plus meta] - shimmer_animation 2.1.0+1 [flutter] - sliding_up_panel 2.0.0+1 [flutter] - sliver_tools 0.2.8 [flutter] - smooth_page_indicator 1.0.0+2 [flutter] - stripe_sdk 5.0.0-nullsafety.1 [flutter http url_launcher mask_text_input_formatter flutter_slidable simple_animations supercharged awesome_card credit_card_validator collection webview_flutter universal_html] - syncfusion_flutter_datepicker 20.3.48 [flutter intl syncfusion_flutter_core] - syncfusion_flutter_signaturepad 20.3.48 [flutter syncfusion_flutter_core] - timelines 0.1.0 [flutter] - timer_builder 2.0.0 [flutter] - torch_controller 2.0.1 [flutter] - tuple 2.0.0 [quiver] - url_launcher 6.1.6 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - validators 3.0.0 - video_compress 3.1.1 [flutter] - video_thumbnail 0.5.3 [flutter] - wc_form_validators 1.0.0 [flutter] - webview_flutter 2.1.2 [flutter webview_flutter_platform_interface webview_flutter_android webview_flutter_wkwebview] - wechat_assets_picker 8.1.3 [flutter extended_image photo_manager provider video_player] dev dependencies: - auto_route_generator 5.0.2 [build source_gen analyzer path build_runner code_builder dart_style xml args auto_route] - fake_cloud_firestore 1.3.1 [flutter cloud_firestore cloud_firestore_platform_interface collection plugin_platform_interface quiver rxdart] - faker 2.0.0 [crypto] - firebase_storage_mocks 0.5.1 [flutter firebase_storage] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] - freezed 2.1.0+1 [analyzer build build_config collection meta source_gen freezed_annotation json_annotation] - integration_test 0.0.0 [flutter flutter_driver flutter_test path vm_service archive async boolean_selector characters clock collection crypto fake_async file matcher material_color_utilities meta source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math webdriver] - json_serializable 6.4.1 [analyzer async build build_config collection json_annotation meta path pub_semver pubspec_parse source_gen source_helper] - mockito 5.3.2 [analyzer build code_builder collection dart_style matcher meta path source_gen test_api] - mocktail 0.3.0 [collection matcher test] - path 1.8.2 - pedantic 1.11.1 - source_gen 1.2.5 [analyzer async build dart_style glob meta path source_span yaml] dependency overrides: - firebase_storage 10.3.11 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - flutter_svg 1.1.5 [flutter meta path_drawing vector_math xml] - font_awesome_flutter 9.1.0 [flutter] - webview_flutter 2.1.2 [flutter webview_flutter_platform_interface webview_flutter_android webview_flutter_wkwebview] - webview_flutter_android 2.1.0 [flutter webview_flutter_platform_interface] - webview_flutter_platform_interface 1.2.0 [flutter plugin_platform_interface] - webview_flutter_wkwebview 2.1.0 [flutter webview_flutter_platform_interface] transitive dependencies: - _fe_analyzer_shared 47.0.0 [meta] - _flutterfire_internals 1.0.2 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - analyzer 4.7.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - args 2.3.1 - async 2.9.0 [collection meta] - awesome_card 1.1.7 [flutter] - boolean_selector 2.1.0 [source_span string_scanner] - build 2.3.1 [analyzer async convert crypto glob logging meta path] - build_config 1.1.0 [checked_yaml json_annotation path pubspec_parse yaml] - build_daemon 3.1.0 [built_collection built_value http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 2.0.10 [analyzer async build crypto graphs logging path package_config pool pub_semver stream_transform yaml] - build_runner_core 7.2.4 [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.4.1 [built_collection collection fixnum meta] - 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] - camera_android 0.10.0+2 [camera_platform_interface flutter flutter_plugin_android_lifecycle stream_transform] - camera_avfoundation 0.9.8+5 [camera_platform_interface flutter stream_transform] - camera_platform_interface 2.2.0 [cross_file flutter plugin_platform_interface stream_transform] - camera_web 0.3.0 [camera_platform_interface flutter flutter_web_plugins stream_transform] - characters 1.2.1 - charcode 1.3.1 - checked_yaml 2.0.1 [json_annotation source_span yaml] - chewie 1.3.5 [cupertino_icons flutter provider video_player wakelock] - chewie_audio 1.3.0 [cupertino_icons flutter video_player] - cli_util 0.3.5 [meta path] - clock 1.1.1 - cloud_firestore_platform_interface 5.7.7 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 2.8.10 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - cloud_functions_platform_interface 5.1.18 [firebase_core flutter meta plugin_platform_interface] - cloud_functions_web 4.3.7 [cloud_functions_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - code_builder 4.3.0 [built_collection built_value collection matcher meta] - collection 1.16.0 - convert 3.0.2 [typed_data] - coverage 1.5.0 [args logging package_config path source_maps stack_trace vm_service] - credit_card_type_detector 2.0.0 - credit_card_validator 2.0.1 [credit_card_type_detector] - cross_file 0.3.3+2 [js meta] - crypto 3.0.2 [typed_data] - csslib 0.17.2 [source_span] - cupertino_icons 1.0.5 - dart_style 2.2.4 [analyzer args path pub_semver source_span] - dataclass_beta 1.0.1 [collection] - dbus 0.7.8 [args ffi meta xml] - device_info_plus_linux 4.0.0 [device_info_plus_platform_interface file flutter meta] - device_info_plus_macos 4.0.0 [device_info_plus_platform_interface flutter] - device_info_plus_platform_interface 4.0.0 [flutter meta plugin_platform_interface] - device_info_plus_web 4.0.0 [device_info_plus_platform_interface flutter_web_plugins flutter] - device_info_plus_windows 5.0.0 [device_info_plus_platform_interface ffi flutter win32 meta] - equatable 2.0.5 [collection meta] - extended_image 6.3.1 [extended_image_library flutter meta] - extended_image_library 3.4.0 [crypto flutter http_client_helper path path_provider] - fake_async 1.3.1 [clock collection] - ffi 2.0.1 - file 6.1.2 [meta path] - firebase_auth_platform_interface 6.10.0 [collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 4.6.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.5.1 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 1.7.3 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_storage_platform_interface 4.1.18 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.3.9 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - fixnum 1.0.1 - flutter_blurhash 0.7.0 [flutter] - flutter_cache_manager 3.3.0 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid] - flutter_driver 0.0.0 [file flutter flutter_test fuchsia_remote_debug_protocol path meta vm_service webdriver archive async boolean_selector characters clock collection crypto matcher material_color_utilities platform process source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math] - flutter_keyboard_visibility_platform_interface 2.0.0 [flutter meta plugin_platform_interface] - flutter_keyboard_visibility_web 2.0.0 [flutter_keyboard_visibility_platform_interface flutter_web_plugins flutter] - flutter_layout_grid 1.0.6 [flutter collection meta quiver] - flutter_lints 1.0.4 [lints] - flutter_local_notifications_linux 1.0.0 [flutter flutter_local_notifications_platform_interface dbus path xdg_directories] - flutter_local_notifications_platform_interface 6.0.0 [flutter plugin_platform_interface] - flutter_math_fork 0.6.3+1 [flutter flutter_svg provider meta collection tuple] - flutter_plugin_android_lifecycle 2.0.7 [flutter] - flutter_riverpod 1.0.3+1 [collection flutter meta riverpod state_notifier] - flutter_secure_storage_linux 1.1.1 [flutter flutter_secure_storage_platform_interface] - flutter_secure_storage_macos 1.1.1 [flutter flutter_secure_storage_platform_interface] - flutter_secure_storage_platform_interface 1.0.0 [flutter plugin_platform_interface] - flutter_secure_storage_web 1.0.2 [flutter flutter_web_plugins flutter_secure_storage_platform_interface js] - flutter_secure_storage_windows 1.1.2 [flutter flutter_secure_storage_platform_interface] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - freezed_annotation 2.1.0 [collection json_annotation meta] - frontend_server_client 2.1.3 [async path] - fuchsia_remote_debug_protocol 0.0.0 [process vm_service file meta path platform] - glob 2.1.0 [async collection file path string_scanner] - graphs 2.1.0 [collection] - html 0.15.0 [csslib source_span] - http_client_helper 2.0.3 [http] - http_multi_server 3.2.1 [async] - http_parser 4.0.1 [collection source_span string_scanner typed_data] - image_cropper_for_web 1.0.2 [flutter flutter_web_plugins image_cropper_platform_interface js] - image_cropper_platform_interface 3.0.2 [flutter plugin_platform_interface http] - image_picker_android 0.8.5+3 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - image_picker_for_web 2.1.8 [flutter flutter_web_plugins image_picker_platform_interface] - image_picker_ios 0.8.6+1 [flutter image_picker_platform_interface] - image_picker_platform_interface 2.6.1 [cross_file flutter http plugin_platform_interface] - inflection3 0.5.3+2 - intercom_flutter_platform_interface 1.2.0 [flutter plugin_platform_interface] - intercom_flutter_web 0.2.0 [flutter flutter_web_plugins intercom_flutter_platform_interface uuid] - io 1.0.3 [meta path string_scanner] - js 0.6.4 - json_api 5.2.0 [http http_parser] - latinize 0.1.0-nullsafety.0 - lints 1.0.1 - local_auth_android 1.0.12 [flutter flutter_plugin_android_lifecycle intl local_auth_platform_interface] - local_auth_ios 1.0.9 [flutter intl local_auth_platform_interface] - local_auth_platform_interface 1.0.4 [flutter intl plugin_platform_interface] - local_auth_windows 1.0.3 [flutter local_auth_platform_interface] - logging 1.0.2 - mask_text_input_formatter 2.4.0 [flutter] - matcher 0.12.12 [stack_trace] - material_color_utilities 0.1.5 - meta 1.8.0 - nested 1.0.0 [flutter] - node_preamble 2.0.1 - numerus 1.1.1 - octo_image 1.0.2 [flutter flutter_blurhash] - package_config 2.1.0 [path] - package_info_plus_linux 1.0.5 [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.5 [flutter flutter_web_plugins http meta package_info_plus_platform_interface] - package_info_plus_windows 2.1.0 [package_info_plus_platform_interface ffi flutter win32] - path_drawing 1.0.1 [vector_math meta path_parsing flutter] - path_parsing 1.0.1 [vector_math meta] - path_provider_linux 2.1.7 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_macos 2.0.6 [flutter path_provider_platform_interface] - path_provider_platform_interface 2.0.4 [flutter platform plugin_platform_interface] - path_provider_windows 2.1.3 [ffi flutter path path_provider_platform_interface win32] - permission_handler_android 10.1.0 [flutter permission_handler_platform_interface] - permission_handler_apple 9.0.6 [flutter permission_handler_platform_interface] - permission_handler_platform_interface 3.8.0 [flutter meta plugin_platform_interface] - permission_handler_windows 0.1.1 [flutter permission_handler_platform_interface] - petitparser 5.0.0 [meta] - photo_manager 2.4.1 [flutter] - platform 3.1.0 - plugin_platform_interface 2.1.3 [meta] - pool 1.5.1 [async stack_trace] - process 4.2.4 [file path platform] - provider 6.0.3 [collection flutter nested] - pub_semver 2.1.1 [collection meta] - pubspec_parse 1.2.1 [checked_yaml collection json_annotation pub_semver yaml] - quiver 3.1.0 [matcher] - riverpod 1.0.3+1 [collection meta state_notifier] - rxdart 0.27.5 - sentry 6.11.2 [http meta stack_trace uuid intl] - shelf 1.3.2 [async collection http_parser path stack_trace stream_channel] - shelf_packages_handler 3.0.1 [path shelf shelf_static] - shelf_static 1.1.1 [convert http_parser mime path shelf] - shelf_web_socket 1.0.2 [shelf stream_channel web_socket_channel] - simple_animations 3.2.0 [flutter supercharged flutter_lints] - sky_engine 0.0.99 - source_helper 1.3.3 [analyzer collection source_gen] - source_map_stack_trace 2.1.0 [path stack_trace source_maps] - source_maps 0.10.10 [source_span] - source_span 1.9.0 [collection path term_glyph] - sprintf 6.0.2 - sqflite 2.1.0 [flutter sqflite_common path] - sqflite_common 2.3.0 [synchronized path meta] - stack_trace 1.10.0 [path] - state_notifier 0.7.2+1 [meta] - stream_channel 2.1.0 [async] - stream_transform 2.0.0 - string_scanner 1.1.1 [source_span] - supercharged 2.1.1 [supercharged_dart flutter] - supercharged_dart 2.1.1 - sync_http 0.3.1 - syncfusion_flutter_core 20.3.48 [vector_math flutter] - synchronized 3.0.0+3 - term_glyph 1.2.1 - test 1.21.4 [analyzer async boolean_selector collection coverage http_multi_server io js node_preamble package_config path pool shelf shelf_packages_handler shelf_static shelf_web_socket source_span stack_trace stream_channel typed_data web_socket_channel webkit_inspection_protocol yaml test_api test_core] - test_api 0.4.12 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - test_core 0.4.16 [analyzer async args boolean_selector collection coverage frontend_server_client glob io meta package_config path pool source_map_stack_trace source_maps source_span stack_trace stream_channel vm_service yaml matcher test_api] - timezone 0.9.0 [path] - timing 1.0.0 [json_annotation] - typed_data 1.3.1 [collection] - universal_html 2.0.8 [async csslib charcode collection html meta source_span typed_data universal_io] - universal_io 2.0.4 [collection crypto meta typed_data] - url_launcher_android 6.0.19 [flutter url_launcher_platform_interface] - url_launcher_ios 6.0.17 [flutter url_launcher_platform_interface] - url_launcher_linux 3.0.1 [flutter url_launcher_platform_interface] - url_launcher_macos 3.0.1 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.1.0 [flutter plugin_platform_interface] - url_launcher_web 2.0.13 [flutter flutter_web_plugins url_launcher_platform_interface] - url_launcher_windows 3.0.1 [flutter url_launcher_platform_interface] - uuid 3.0.6 [crypto] - value_layout_builder 0.3.1 [flutter] - vector_math 2.1.2 - video_player 2.4.7 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web] - video_player_android 2.3.9 [flutter video_player_platform_interface] - video_player_avfoundation 2.3.5 [flutter video_player_platform_interface] - video_player_platform_interface 5.1.4 [flutter plugin_platform_interface] - video_player_web 2.0.12 [flutter flutter_web_plugins video_player_platform_interface] - vm_service 9.0.0 - wakelock 0.6.2 [flutter meta wakelock_macos wakelock_platform_interface wakelock_web wakelock_windows] - wakelock_macos 0.4.0 [flutter flutter_web_plugins wakelock_platform_interface] - wakelock_platform_interface 0.3.0 [flutter meta] - wakelock_web 0.4.0 [flutter flutter_web_plugins js wakelock_platform_interface] - wakelock_windows 0.2.1 [flutter wakelock_platform_interface win32] - watcher 1.0.1 [async path] - web_socket_channel 2.2.0 [async crypto stream_channel] - webdriver 3.0.0 [archive matcher path stack_trace sync_http] - webkit_inspection_protocol 1.2.0 [logging] - win32 3.0.0 [ffi] - xdg_directories 0.2.0+2 [meta path process] - xml 6.1.0 [collection meta petitparser] - yaml 3.1.1 [collection source_span string_scanner] ```

darshankawar commented 2 years ago

@GabrielAraujo Thanks for the report. Can you try using the latest version of the plugin https://pub.dev/packages/firebase_storage/changelog#1103 and see if using it, you get same behavior or not ? If yes, please provide a complete minimal code sample that we can use to verify.

orestesgaolin commented 2 years ago

We're using 11.0.4 and it still occurs:

Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: length=11; index=11
       at android.util.ContainerHelpers.binarySearch(ContainerHelpers.java:28)
       at android.util.SparseArray.put(SparseArray.java:260)
       at io.flutter.plugins.firebase.storage.FlutterFirebaseStorageTask.<init>(FlutterFirebaseStorageTask.java:42)
       at io.flutter.plugins.firebase.storage.FlutterFirebaseStorageTask.downloadFile(FlutterFirebaseStorageTask.java:13)
       at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin.lambda$taskWriteToFile$11(FlutterFirebaseStoragePlugin.java:35)
       at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin.$r8$lambda$LNEILVX6m9GNMe_1v7rabfG-oqo(FlutterFirebaseStoragePlugin.java)
       at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin$$InternalSyntheticLambda$2$cfcc3175e48677ba34d0bc91f11e6a89a82a7adf38ee4e422b1a511140d2e9b3$0.run(FlutterFirebaseStoragePlugin.java:6)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
       at java.lang.Thread.run(Thread.java:1012)
GabrielAraujo commented 2 years ago

@orestesgaolin do you have a sample app reproducing it?

darshankawar commented 2 years ago

I tried using firebase_storage plugin example with latest versions and uploaded local file one by one which worked properly without throwing the reported error.

Screenshot 2022-11-17 at 3 19 33 PM

If anyone has concrete steps to replicate along with code, please provide us the same so that we can make this issue actionable.

GabrielAraujo commented 2 years ago

This issue only happens on android, it seems to happen if you randomly upload multiple files different times without waiting for the completion of one to start uploading the next file.. That is how we use it in our app

Screen Shot 2022-11-17 at 10 00 45

PetrKubes97 commented 1 year ago

We are experiencing the same issue when attempting to download multiple files at once. I've set the limit to allow parallel download only 4 files at once, but still occurs. Interestingly, there is something up with the index 11, because all of my crashes have similar error message:

Exception java.lang.ArrayIndexOutOfBoundsException: length=11; index=11
  at android.util.ContainerHelpers.binarySearch (ContainerHelpers.java:28)
  at android.util.SparseArray.put (SparseArray.java:260)
  at io.flutter.plugins.firebase.storage.FlutterFirebaseStorageTask.<init> (FlutterFirebaseStorageTask.java)
  at io.flutter.plugins.firebase.storage.FlutterFirebaseStorageTask.downloadFile (FlutterFirebaseStorageTask.java)
  at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin.lambda$taskWriteToFile$11 (FlutterFirebaseStoragePlugin.java)
  at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin.lambda$taskWriteToFile$11$FlutterFirebaseStoragePlugin (FlutterFirebaseStoragePlugin.java)
  at io.flutter.plugins.firebase.storage.-$$Lambda$FlutterFirebaseStoragePlugin$LNEILVX6m9GNMe_1v7rabfG-oqo.run (-.java)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1137)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:637)
  at java.lang.Thread.run (Thread.java:1012)
Exception java.lang.ArrayIndexOutOfBoundsException: length=11; index=12
  at android.util.ContainerHelpers.binarySearch (ContainerHelpers.java:28)
  at android.util.SparseArray.put (SparseArray.java:260)
  at io.flutter.plugins.firebase.storage.FlutterFirebaseStorageTask.<init> (FlutterFirebaseStorageTask.java)
  at io.flutter.plugins.firebase.storage.FlutterFirebaseStorageTask.downloadFile (FlutterFirebaseStorageTask.java)
  at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin.lambda$taskWriteToFile$11 (FlutterFirebaseStoragePlugin.java)
  at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin.lambda$taskWriteToFile$11$FlutterFirebaseStoragePlugin (FlutterFirebaseStoragePlugin.java)
  at io.flutter.plugins.firebase.storage.-$$Lambda$FlutterFirebaseStoragePlugin$LNEILVX6m9GNMe_1v7rabfG-oqo.run (-.java)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1137)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:637)
  at java.lang.Thread.run (Thread.java:1012)
Exception java.lang.ArrayIndexOutOfBoundsException: length=11; index=11
  at android.util.SparseArray.gc (SparseArray.java:213)
  at android.util.SparseArray.put (SparseArray.java:252)
  at io.flutter.plugins.firebase.storage.FlutterFirebaseStorageTask.<init> (FlutterFirebaseStorageTask.java)
  at io.flutter.plugins.firebase.storage.FlutterFirebaseStorageTask.downloadFile (FlutterFirebaseStorageTask.java)
  at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin.lambda$taskWriteToFile$11 (FlutterFirebaseStoragePlugin.java)
  at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin.lambda$taskWriteToFile$11$FlutterFirebaseStoragePlugin (FlutterFirebaseStoragePlugin.java)
  at io.flutter.plugins.firebase.storage.-$$Lambda$FlutterFirebaseStoragePlugin$LNEILVX6m9GNMe_1v7rabfG-oqo.run (-.java)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
  at java.lang.Thread.run (Thread.java:919)
Exception java.lang.ArrayIndexOutOfBoundsException: src.length=11 srcPos=11 dst.length=11 dstPos=12 length=-7
  at java.lang.System.arraycopy (System.java:634)
  at com.android.internal.util.GrowingArrayUtils.insert (GrowingArrayUtils.java:154)
  at android.util.SparseArray.put (SparseArray.java:269)
  at io.flutter.plugins.firebase.storage.FlutterFirebaseStorageTask.<init> (FlutterFirebaseStorageTask.java)
  at io.flutter.plugins.firebase.storage.FlutterFirebaseStorageTask.downloadFile (FlutterFirebaseStorageTask.java)
  at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin.lambda$taskWriteToFile$11 (FlutterFirebaseStoragePlugin.java)
  at io.flutter.plugins.firebase.storage.FlutterFirebaseStoragePlugin.lambda$taskWriteToFile$11$FlutterFirebaseStoragePlugin (FlutterFirebaseStoragePlugin.java)
  at io.flutter.plugins.firebase.storage.-$$Lambda$FlutterFirebaseStoragePlugin$LNEILVX6m9GNMe_1v7rabfG-oqo.run (-.java)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
  at java.lang.Thread.run (Thread.java:923)
darshankawar commented 1 year ago

Thanks for the updates. Based on the reports, I am going ahead and labeling this for further insights and team's attention.

/cc @russellwheatley

russellwheatley commented 1 year ago

@GabrielAraujo Please provide a sample app with instructions on how to reproduce and I will take a look. Thanks.

google-oss-bot commented 1 year ago

Hey @GabrielAraujo. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

jamesdixon commented 1 year ago

@russellwheatley I'll see if I can get a reproducible example working.

I am one of @GabrielAraujo's colleagues and just ran into this again while testing to see if batching files x at a time would prevent the crash, but we're still seeing it.

jamesdixon commented 1 year ago

@russellwheatley still working on trying to reproduce this in the sample app (the issue is intermittent), but I noticed something interesting when looking at the FlutterFire code. Check out this line:

https://github.com/firebase/flutterfire/blob/dea46c4ca89eda879befb0dbce4190f4090d6d48/packages/firebase_storage/firebase_storage/android/src/main/java/io/flutter/plugins/firebase/storage/FlutterFirebaseStorageTask.java#L77

It appears a suspiciously similar issue is happening in https://github.com/firebase/flutterfire/issues/4334, which was handled just by catching and ignoring the exception.

One thing I will say is that if we switch our app to only uploading a single file at a time, we're not seeing any crashing. However, our users are sometimes uploading 200 - 400 pictures in a session (home inspectors), so uploading 1 at a time ends up being a very slow process even on a fast connection.

jamesdixon commented 1 year ago

@GabrielAraujo wanna post your solution here?

GabrielAraujo commented 1 year ago

Hey! I've forked the flutterfire lib and changed the FlutterFirebaseStorageTask.java to use HashMap instead of a SparseArray to handle inProgressTasks.

Here you can see the commit I made and it seems to fix the problem as we are having a hard time to reproduce it on a sample project.

@russellwheatley thoughts?

Lyokone commented 1 year ago

Hello @GabrielAraujo I'm not sure why we would get no more errors with a HashMap (since SparseArray is supposed to be a more optimised implementation of HashMap). I'll check if we still have concurrency issues.

GabrielAraujo commented 1 year ago

@Lyokone thank you for looking into it. The idea with the HashMap usage is to avoid the BinarySearch operations that take place once you interact with the SparseArray, based on the logs from the multiple reports not only from me but other devs on other issues too it is the main source of problems. I'm also deploying a production release to our users soon with this forked version of flutterfire so we can monitor if the issue gets fixed with it. (Note that the forked version also contain some changes related to manually adjusting the thread limit for download/upload operations on the native sdk | PR for reference).

Lyokone commented 1 year ago

We're going to release a tentative fix today, let's see how it goes. If it doesn't solve this we'll move to HashMap :)

GabrielAraujo commented 1 year ago

Nice! Thanks, I'll do some testing with this release too. Our production release using HashMap did not present the out of bounds exception so far.

Lyokone commented 1 year ago

The fix was released. I'll close this issue. Feel free to reopen if you get new reports.