Firestore: Remove copies in FieldValueInternal to reduce global refs consumption. #1111
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In
field_value_android.h
, change thestd::vector<FieldValue>
andMapFieldValue
constructors to take const references, instead of values. This reduces by half the number of global references needed whenDocumentReference::Set()
,DocumentReference::Update()
, andCollectionReference::Add()
are called on Android.Since these 3 methods are part of the public interface and take const references as their arguments, they are not able to
std::move
these values into theFieldValueInternal
constructor, thus requiring copies. On Android, these copies necessitate doubling the number of JNI global references in use, making it much easier to hit the 51,200 hard limit.This is the first part of a proper fix for the global refs exhaustion issue reported in firebase/quickstart-unity#1303 and firebase/quickstart-unity#1193 (comment) (Googlers see b/251869890 for more details). This should help alleviate the immediate problems being experienced by these customers. A proper fix is much more complicated and will take time to implement. Hopefully the improvement in this PR will be sufficient to unblock those customers.