Skip to content

🐛 [firebase_storage] Upload hangs when app is backgrounded on macos #4513

Closed
@pschuegr

Description

@pschuegr

Bug report

I am having trouble with my uploads hanging in a "running" state:

await Firestorage.FirebaseStorage.instance.ref(audioTarget).putFile(audioFile);

I trigger the upload this way, and the upload hangs (application remains responsive) and never completes. I checked the status of the UploadTask using the snapshotEvents stream: it emits a single TaskSnapshot with the state running almost immediately and then nothing. Curiously, this only happens if I cmd-tab to a different application while waiting for the upload. If I sit in the app and wait, it completes just fine.

Steps to reproduce

  • Start application (main widgets parented by AudioServiceWidget)
  • Trigger upload with
 Firestore.CollectionReference tracks =
        Firestore.FirebaseFirestore.instance.collection('projects/${Settings.firebaseProjectId}/tracks');
    return tracks.add(_toFirebaseData(fileData)).then((Firestore.DocumentReference track) async {
        var basePath = track.id;
        File audioFile = File(audioPath);
        var audioTarget = '$basePath/${track.id}.mp3';
        await Firestorage.FirebaseStorage.instance.ref(audioTarget).putFile(audioFile);
  • After triggering upload, cmd-tab to another application.
  • Observe that file put never completes (checked firebase storage dashboard to confirm).

Expected behavior

Upload completes in a reasonable time frame (my test files were from 8k to 2.1mb, they would hang indefinitely or at least 30mins+).

When doing this while keeping the app in foreground, uploads were ~10-15s maximum.


Additional context


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
[✓] Flutter (Channel dev, 1.26.0-1.0.pre, on macOS 11.0.1 20B29 darwin-x64, locale en-CA)
    • Flutter version 1.26.0-1.0.pre at /Users/pschuegr/flutter
    • Framework revision 63062a6443 (2 weeks ago), 2020-12-13 23:19:13 +0800
    • Engine revision 4797b06652
    • Dart version 2.12.0 (build 2.12.0-141.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/pschuegr/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.3, Build version 12C33
    • CocoaPods version 1.10.0

[✓] Android Studio (version 4.1)
    • 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 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.52.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.18.0

[✓] Connected device (2 available)
    • Pixel 3a (mobile) • 92SAY040D9 • android-arm64 • Android 11 (API 30)
    • macOS (desktop)   • macos      • darwin-x64    • macOS 11.0.1 20B29 darwin-x64

Flutter dependencies

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

Click To Expand
Dart SDK 2.12.0-141.0.dev
Flutter SDK 1.26.0-1.0.pre
calliope 0.0.1+2

dependencies:
- args 1.6.0
- audio_service 0.16.0 [audio_session rxdart flutter_isolate flutter_cache_manager sqflite js flutter flutter_web_plugins]
- audio_session 0.0.10 [flutter flutter_web_plugins rxdart]
- cloud_firestore 0.14.4 [flutter meta quiver firebase_core firebase_core_platform_interface cloud_firestore_platform_interface cloud_firestore_web]
- cupertino_icons 1.0.2
- firebase_auth 0.18.4+1 [meta firebase_core firebase_core_platform_interface firebase_auth_platform_interface firebase_auth_web flutter]
- firebase_core 0.5.3 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- firebase_storage 5.2.0 [flutter firebase_core firebase_core_platform_interface firebase_storage_web firebase_storage_platform_interface quiver]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- google_sign_in 4.5.6 [google_sign_in_platform_interface flutter meta google_sign_in_web]
- just_audio 0.6.3 [just_audio_platform_interface just_audio_web audio_session rxdart path path_provider async uuid flutter]
- path 1.8.0-nullsafety.3
- provider 4.3.2+3 [collection flutter nested]
- shared_preferences 0.5.12+4 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows]
- util 0.0.0 [chunked_stream dart_numerics]
- uuid 2.2.2 [crypto convert]
- watcher 0.9.7+15 [async path pedantic]

dev dependencies:
- 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]

transitive dependencies:
- archive 2.0.13 [crypto args path]
- async 2.5.0-nullsafety.3 [collection]
- boolean_selector 2.1.0-nullsafety.3 [source_span string_scanner]
- characters 1.1.0-nullsafety.5
- charcode 1.2.0-nullsafety.3
- chunked_stream 1.1.0
- clock 1.1.0-nullsafety.3
- cloud_firestore_platform_interface 2.2.1 [flutter meta collection firebase_core plugin_platform_interface]
- cloud_firestore_web 0.2.1+2 [flutter flutter_web_plugins http_parser meta firebase_core firebase_core_web cloud_firestore_platform_interface js]
- collection 1.15.0-nullsafety.5
- convert 2.1.1 [charcode typed_data]
- crypto 2.1.5 [collection convert typed_data]
- dart_numerics 0.0.5 [tuple]
- fake_async 1.2.0-nullsafety.3 [clock collection]
- ffi 0.1.3
- file 5.2.1 [intl meta path]
- firebase_auth_platform_interface 2.1.4 [flutter meta firebase_core plugin_platform_interface]
- firebase_auth_web 0.3.2+3 [flutter flutter_web_plugins meta http_parser intl firebase_core firebase_core_web firebase_auth_platform_interface js]
- 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 meta js]
- firebase_storage_platform_interface 1.0.2 [flutter meta collection firebase_core plugin_platform_interface]
- firebase_storage_web 0.1.1+1 [async crypto firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta]
- flutter_cache_manager 2.1.0 [flutter path_provider uuid http path sqflite pedantic clock file rxdart image]
- flutter_isolate 1.0.0+14 [flutter uuid]
- flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math]
- google_sign_in_platform_interface 1.1.2 [flutter meta quiver]
- google_sign_in_web 0.9.2 [google_sign_in_platform_interface flutter flutter_web_plugins meta js]
- http 0.12.2 [http_parser path pedantic]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- image 2.1.19 [archive xml meta]
- intl 0.16.1 [path]
- js 0.6.3-nullsafety.3
- just_audio_platform_interface 2.0.0 [flutter meta plugin_platform_interface]
- just_audio_web 0.2.1 [just_audio_platform_interface flutter flutter_web_plugins meta]
- matcher 0.12.10-nullsafety.3 [stack_trace]
- meta 1.3.0-nullsafety.6
- nested 0.0.4 [flutter]
- path_provider 1.6.24 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows]
- path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 0.0.4+6 [flutter]
- path_provider_platform_interface 1.0.4 [flutter meta platform plugin_platform_interface]
- path_provider_windows 0.0.4+3 [path_provider_platform_interface meta path flutter ffi win32]
- pedantic 1.9.2 [meta]
- petitparser 3.1.0 [meta]
- platform 2.2.1
- plugin_platform_interface 1.0.3 [meta]
- process 3.0.13 [file intl meta path platform]
- quiver 2.1.5 [matcher meta]
- rxdart 0.25.0
- shared_preferences_linux 0.0.2+4 [file flutter meta path path_provider_linux shared_preferences_platform_interface]
- shared_preferences_macos 0.0.1+11 [shared_preferences_platform_interface flutter]
- shared_preferences_platform_interface 1.0.4 [meta flutter]
- shared_preferences_web 0.1.2+7 [shared_preferences_platform_interface flutter flutter_web_plugins meta]
- shared_preferences_windows 0.0.1+3 [shared_preferences_platform_interface flutter ffi file meta path path_provider_platform_interface path_provider_windows]
- sky_engine 0.0.99
- source_span 1.8.0-nullsafety.4 [charcode collection path term_glyph]
- sqflite 1.3.2+1 [flutter sqflite_common path]
- sqflite_common 1.0.2+1 [synchronized path meta]
- stack_trace 1.10.0-nullsafety.6 [path]
- stream_channel 2.1.0-nullsafety.3 [async]
- string_scanner 1.1.0-nullsafety.3 [charcode source_span]
- synchronized 2.2.0+2
- term_glyph 1.2.0-nullsafety.3
- test_api 0.2.19-nullsafety.6 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- tuple 1.0.3 [quiver]
- typed_data 1.3.0-nullsafety.5 [collection]
- vector_math 2.1.0-nullsafety.5
- win32 1.7.4 [ffi]
- xdg_directories 0.1.2 [meta path process]
- xml 4.5.1 [collection convert meta petitparser]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions