fix(firestore): chunk large Android query snapshots - #18601
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 馃憤 and 馃憥 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Description
Android query listeners currently convert an entire Firestore
QuerySnapshotinto oneInternalQuerySnapshotand send it through one Pigeon event-channel envelope. Large result sets therefore require the full native model and a second large encoded buffer to coexist. In the downstream reproduction, 6,112 documents produce a single success envelope larger than 30 MiB and can exhaust the Android heap duringStandardMessageCodec.writeValue.This PR keeps one Firestore query and one snapshot listener, but sends each Android query snapshot as a framed sequence of messages capped at 512 KiB by their actual encoded success-envelope size. The platform interface reassembles the frames before emitting anything to the public query stream, preserving the existing atomic snapshot, document ordering, metadata, and document-change semantics. Other platforms continue to send
InternalQuerySnapshotdirectly and pass through unchanged.It also closes a listener-registration cancellation race so cancelling during registration cannot leave the Firestore listener active.
Validation includes:
:cloud_firestore:testDebugUnitTestand existing:firebase_crashlytics:testDebugUnitTesttasks;cloud_firestore_platform_interface;This does not paginate the Firestore query and does not multiply document reads.
Related Issues
flutter/flutterissue yet.Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]).This will ensure a smooth and quick review process. Updating the
pubspec.yamland changelogs is not required.///).melos run analyze) does not report any problems on my PR. Focused package analysis passes; the repository-wide command was not run.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?