[firebase_storage] Windows native crash in upload progress callback, sink ownership and thread dispatch
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #18667 by @SelaseKay — closed without merging
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- desktop-dev, operating-systems
Research direction
Start with the Windows PutDataStreamHandler, PutFileStreamHandler, and GetFileStreamHandler ownership and callback paths, then run the supplied concurrent putData harness on Windows. Compare the unchanged plugin with commit f9ea66025cbdd8b2b32fa762282194b4ba454d40 and its listed stress checks. Done means repeated uploads complete without a native crash or pending Dart completions, with byte-for-byte SDK readback.
Written by the indexing model from the issue text.
Description
Concurrent putData calls can terminate the Windows process with an unhandled access violation in TaskStateListener::OnProgress / flutter::EventSink::Success. A Dart catch cannot catch this native exit.
Reproduced with firebase_storage 12.4.10, Firebase C++ SDK 12.7.0, and a Windows release build on Windows Server 2019 (17763). The relevant ownership and callback code is also present in current main (a57837ef40f73f0187b45125ecc0d81811b71bd9, firebase_storage 13.5.0); I have inspected that source but have not runtime-tested 13.5.0.
After normal Firebase initialization and authentication, run repeated bursts of small uploads to an authorized test path:
final bytes = Uint8List.fromList(utf8.encode(jsonEncode({
'id': List.generate(300, (i) => i),
'label': List.generate(300, (i) => 'Synthetic customer $i'),
})));
for (var round = 0; round < 3; round++) {
await Future.wait(List.generate(13, (i) => FirebaseStorage.instance
.ref('YOUR_TEST_PATH/${DateTime.now().microsecondsSinceEpoch}_$i.json')
.putData(bytes, SettableMetadata(contentType: 'application/json'))));
}
The storage-only reproduction initializes Core/Auth/Storage, with no Hive, Firestore database initialization, or SQL. The unchanged plugin exited with 0xC0000005 about 14 seconds into one run. A separate release-app dump identifies the progress callback stack:
flutter::EventSink<flutter::EncodableValue>::Success
TaskStateListener::OnProgress
firebase::storage::internal::RestOperation::NotifyListenerOfProgress
Three relevant findings in the Windows plugin:
PutDataStreamHandler,PutFileStreamHandler, andGetFileStreamHandlerstore the sink as astd::unique_ptr<...>&&member.OnListenInternalassigns into that referenced temporary instead of owning the incoming sink.- Progress and completion call
EventSink::Successfrom SDK worker threads. Flutter's platform message API requires the platform thread. - Keeping only the sink alive was insufficient in our stress checks: transfers could upload remotely while Dart completions remained pending. Keeping the exact
StorageReferencethat starts each operation alive through completion, and moving completion processing onto the platform thread, resolved the tested stalls. SDK 12.7 source shows a potential FutureManager/API mutex inversion when a reference is orphaned during a pending Metadata result; I am not claiming the dump alone proves that entire lock cycle.
A local plugin candidate owns the sinks, posts events through a message-only Windows window, retains operation references and buffers until completion, and drops callbacks after plugin shutdown. It has passed 140 small uploads with byte-for-byte SDK readback (including ten bursts of 13), metadata updates, putString, putFile/writeToFile, overwrite, download URL, a 13 MB result, accepted pause/resume, eight accepted cancellations, missing-object and signed-out errors, and uploads after signing back in. The unchanged native plugin still crashes with the same Dart harness. Requested close during 13 active uploads exits without leaving a process. A separate super_native_extensions/msctf error during requested process shutdown also occurs without any Storage upload in the unchanged plugin, and in our previous full-app build; that is outside this report.
Candidate patch: https://github.com/BlazeSQL/flutterfire/commit/f9ea66025cbdd8b2b32fa762282194b4ba454d40 (based on our existing Firestore fork; this commit changes only Windows Storage).
Could you confirm the intended sink/reference lifetime and platform-thread dispatch approach? I can supply a minimal patch or further diagnostics. No customer data is needed to reproduce this.
- Dominant language
- Dart
- Stars
- 9.3k
- Forks
- 4.1k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 79
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from firebase/flutterfire
-
blocked: customer-response Needs Attention platform: ios plugin: messaging Stale type: bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
firebase/flutterfire#18776 · 5 comments ·
Maintainers usually reply within 1 day
-
[core] Decouple platform_interface from Flutter for pure-Dart webPossibly taken @Lyokone claimed this 36 days ago. OpenNeeds Attention platform: all platform: web plugin: core type: enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
firebase/flutterfire#18645 · 3 comments · 2 reactions · 1 assignee ·
Maintainers usually reply within 1 day
-
blocked: firebase-sdk platform: android plugin: messaging reproduced type: bug
Difficulty 3/5 1-2 days Newbie friendliness 56/100
firebase/flutterfire#18644 · 3 comments ·
Maintainers usually reply within 1 day
-
[firebase_database, windows] Listener callbacks are delivered on a non-platform thread and crash the processMay be free again A pull request for this issue was closed without being merged. Openblocked: flutter platform: windows plugin: database reproduced type: bug
Difficulty 4/5 3-5 days Newbie friendliness 52/100
firebase/flutterfire#18630 · 2 comments ·
Maintainers usually reply within 1 day
-
Needs Attention plugin: auth type: enhancement
Difficulty 5/5 Over a week Newbie friendliness 25/100
firebase/flutterfire#18324 · 4 reactions ·
Maintainers usually reply within 1 day
All issues in firebase/flutterfire
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
atsign-foundation/at_server#2896 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
lugassawan/swe-workbench#823 ·
Maintainers usually reply within 1 day
-
auto-implement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
bannzai/kashakeibo#142 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
meddouribadis/arclauncher#53 ·
Maintainers usually reply within 1 day
-
p: material_ui package team-design
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
flutter/flutter#195096 · 1 comment ·
Maintainers usually reply within 1 day