Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Async, FieldValue.Delete not working on multiple fields #882

Closed
npicouet opened this issue Dec 1, 2020 · 5 comments
Closed

Update Async, FieldValue.Delete not working on multiple fields #882

npicouet opened this issue Dec 1, 2020 · 5 comments

Comments

@npicouet
Copy link

npicouet commented Dec 1, 2020

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2019.4.12f1
  • Firebase Unity SDK version: 6.16.1
  • Source you installed the SDK: UPM
  • Problematic Firebase Component: Firestore
  • Other Firebase Components in use: Everything
  • Additional SDKs you are using: Facebook, Google Sign In, Apple Sign In
  • Platform you are using the Unity editor on: Mac
  • Platform you are targeting: Mobile (iOS and Android)
  • Scripting Runtime: IL2CPP

[REQUIRED] Please describe the issue here:

When attempting to delete multiple fields in an UpdateAsync call, only the last field in the array actually gets deleted.

Steps to reproduce:

What's the issue repro rate? 100%

What happened? How can we make the problem occur?
Expected all the fields to be deleted. Only one gets deleted. Specifically in my case, only "Rooms" field gets deleted. If I comment out "Rooms", then "Pending Rooms" gets deleted. It's only ever 1 field at a time, even though I want to delete them all in my update.

Relevant Code:

//Create Dictionary
Dictionary<string, object> userUpdate = new Dictionary<string, object>()
{
	{ "Quickplay Rooms", FieldValue.Delete },
	{ "Pending Rooms", FieldValue.Delete },
	{ "Rooms", FieldValue.Delete },
	// { "Room Version", SaveManager.RoomVersion }
};

//Update User Profile
docRef.UpdateAsync(userUpdate).ContinueWithOnMainThread(innerTask =>
{
	//Callback code in here
});
@npicouet npicouet added the new New issue. label Dec 1, 2020
@dconeybe dconeybe self-assigned this Dec 1, 2020
@dconeybe
Copy link

dconeybe commented Dec 1, 2020

Thank you for reporting this. I have been able to reproduce and will investigate.

@dconeybe
Copy link

dconeybe commented Dec 2, 2020

Update: I've found the root cause and it is indeed a bug. In the special handling of FieldValue.Delete, a break statement is incorrectly being used instead of a continue statement: https://github.com/firebase/firebase-cpp-sdk/blob/f0a9d5b65e3a014aee347ea9bb3b664cdce2ae55/firestore/src/ios/user_data_converter_ios.cc#L481.

With this bug present, including FieldValue.Delete in an update causes some of the fields being requested to be updated to be excluded from the update.

Unfortunately, I do not know if the fix will make it into the next release. I will update this thread once I can confirm. Fortunately, there are feasible workarounds.

Workaround 1: UpdateAsync() with exactly one key/value pair for delete

In a call to UpdateAsync(), either include no FieldValue.Delete values or the only key/value pair should be the delete. Since the first "delete" is processed correctly, but potentially causes other fields to be incorrectly excluded, having the only key being updated to a FieldValue.Delete value will behave correctly.

Workaround 2: Use WriteBatch

Fortunately, WriteBatch is not affected by this bug as long as the fields to be deleted are added to the write batch one at a time (instead of all at once in a single Dictionary). For example, the code in the opening comment could be re-written as follows:

docRef.Firestore.StartBatch()
    .Update(docRef, "Quickplay Rooms", FieldValue.Delete)
    .Update(docRef, "Pending Rooms", FieldValue.Delete)
    .Update(docRef, "Rooms", FieldValue.Delete)
    .CommitAsync().ContinueWithOnMainThread(innerTask =>
        {
	    //Callback code in here
        });

@npicouet
Copy link
Author

npicouet commented Dec 2, 2020

Thank you for looking into it, and thank you for the workarounds!
Glad it was something that can be fixed.

@DellaBitta DellaBitta added type: bug and removed new New issue. labels Dec 3, 2020
@dconeybe
Copy link

dconeybe commented Dec 4, 2020

Update: The fix for this bug has been submitted. It did not make it into the Unity SDK 7.0.0 release but should make it into the next release (for which I do not have an ETA). Until then, please use one of the workarounds documented in the earlier comment #882 (comment).

Since there are no further actions to take to address this issue I am going to close it. Feel free to re-open if the bug is not resolved in a future release with release notes entry that reads something like this:

Fixed partial updates in UpdateAsync() with FieldValue.Delete

Note to Googlers: The internal ticket is b/174676322 and the fix is cl/345664484.

@dconeybe dconeybe closed this as completed Dec 4, 2020
a-maurice pushed a commit to firebase/firebase-cpp-sdk that referenced this issue Dec 9, 2020
…ial updates.

The easiest fix would have been to replace `break` with `continue`; however, I changed it to an if/else statement to be in line with the other SDKs. See b/174676322 for details.

This bug affects both the Firestore Unity and C++ SDKs. Therefore, I have added unit test coverage to both for this specific case.

This bug was originally reported by a customer: firebase/quickstart-unity#882

PiperOrigin-RevId: 345664484
DellaBitta added a commit to firebase/firebase-cpp-sdk that referenced this issue Dec 17, 2020
* Use Executor::CreateSerial

PiperOrigin-RevId: 316809187

* Fix future crash that cause unity editor to crash second time enter play mode.

FutureProxyManager still grabs FutureHandle that supposed to be cleaned up and released. Force release them during proxy manager's destructor.

PiperOrigin-RevId: 316809477

* Fix integration test caused by curl http2 default setting

PiperOrigin-RevId: 317136423

* Pin the Firestore pod used by the open source repo to the version from 6.26.0

PiperOrigin-RevId: 317141369

* Project import generated by Copybara.

PiperOrigin-RevId: 317141369

* Add unit tests for the Firebase libraries

PiperOrigin-RevId: 317141369

* Add empty workflow to manually trigger.

* Add a user callback executor for android.

Also fixes a flaky test because assertion is some times done before expected remote event arrives.

PiperOrigin-RevId: 317154095

* Migrating deprecated aliases for absl::StrSplit, and the corresponding predicates.

See b/158478280 and go/absl-cleanup-lsc for more details.

This change was produced using rename_function with the spec:
rename {
  rename_spec {
    new_header: "third_party/absl/strings/str_split.h"
    old_name: "strings::Split"
    new_name: "absl::StrSplit"
  }
}

Additionally, a global find/replace was done on:
strings::AllowEmpty -> absl::AllowEmpty
strings::SkipEmpty -> absl::SkipEmpty
strings::SkipWhitespace -> absl::SkipWhitespace

Tested:
    TAP sample presubmit queue
    http://test/OCL:317011231:BASE:317041434:1592460837225:fc71f604
PiperOrigin-RevId: 317399788

* Incremented version numbers to 6.15.1

PiperOrigin-RevId: 317402209

* Automated g4 rollback of changelist 317154095.

*** Reason for rollback ***

Not ready for release yet

*** Original change description ***

Add a user callback executor for android.

Also fixes a flaky test because assertion is some times done before expected remote event arrives.

***

PiperOrigin-RevId: 317736475

* Automated g4 rollback of changelist 314233757.

*** Reason for rollback ***

Not ready for release yet

*** Original change description ***

[C++] Provide a default executor with settings on iOS

***

PiperOrigin-RevId: 317791137

* Fix a missing call to `ClearListeners` in ~FirestoreInternal.

Also fix a memory leak during listener unregistration

PiperOrigin-RevId: 318538053

* Enable full stack traces for crashes in unit tests

Fix leaks in firestore_test that the HeapChecker found.

Test with `blaze test -c dbg` to get line numbers in stack frames.

PiperOrigin-RevId: 318644593

* Hooked up Persistence into Realtime Database.

PiperOrigin-RevId: 318885157

* Automated g4 rollback of changelist 317736475.

*** Reason for rollback ***

re-roll cl/317154095

SKIP_FIRESTORE_KOKORO_BUILD_TEST=true

*** Original change description ***

Automated g4 rollback of changelist 317154095.

*** Reason for rollback ***

Not ready for release yet

*** Original change description ***

Add a user callback executor for android.

Also fixes a flaky test because assertion is some times done before expected remote event arrives.

***

***

PiperOrigin-RevId: 318891491

* Removed errant include.

PiperOrigin-RevId: 318899934

* Automated g4 rollback of changelist 317791137.

*** Reason for rollback ***

Re-roll cl/314233757

SKIP_FIRESTORE_KOKORO_BUILD_TEST=true

*** Original change description ***

Automated g4 rollback of changelist 314233757.

*** Reason for rollback ***

Not ready for release yet

*** Original change description ***

[C++] Provide a default executor with settings on iOS

***

***

PiperOrigin-RevId: 318938740

* Fix issues with event accumulation in Firestore C++ integration tests

There are several related flaws fixed here:

  * The mutex in TestEventListener was not applied consistently, leading to
    data races that showed up as strangely failing tests on forge.
  * The result of FirestoreIntegrationTest::Await was implicitly trusted to
    produce some results, but this isn't the case when it times out. In this
    error case the caller would read uninitialized memory almost immediately
    after, leading to crashes before the log message about the timeout had
    necessarily been writen.
  * The result of FirestoreIntegrationTest::Await was implicitly trusted not to
    produce more results than requested, but this didn't always happen either.
    This would cause failures where a test would request `n` events, and use
    the last `n` that arrived, skipping extra events. Now the EventAccumulator
    ensures that it consumes events in sequence.

PiperOrigin-RevId: 318943435

* Fix test warm-up

Certain tests include a warm-up step to ensure that the backend was actually
available, but only waited for any event. Unfortunately this doesn't work,
because when the server is unavailable, the SDK will serve a from-cache event
indicating the document doesn't exist.

Change all these to wait for a from-cache: false event, guaranteeing that the
server is actually available and confirming the document doesn't exist.

PiperOrigin-RevId: 318948824

* Implement type map for public to internal types

This simplifies the specification of promises, cleanup functions, and
converters, since they now only need to specify the public type.

PiperOrigin-RevId: 318960642

* Split PromiseFactory out of WrapperFuture

This makes promise creation more closely match iOS and paves the way for
removing WrapperFuture altogether.

Use PromiseFactory in all internal type implementations instead of extending
WrapperFuture and then dDelete WrapperFuture.

PiperOrigin-RevId: 319025783

* Remove LastResult implementations

PiperOrigin-RevId: 319034882

* Fix enabling debug logging from Unity in iOS.

Previously, setting FirebaseFirestore.LogLevel to LogLevel.Debug would get bumped back to LogLevel.Info as an unexpected side effect of creating of a new firebase::App object. The apparent effect to users was that enabling debug logging had no effect. This made it challenging to debug issues with customers because they were unable to collect valuable debug logs when using iOS as their platform.

PiperOrigin-RevId: 319056991

* Cleanup listener callbacks on `DocumentReference` and `Query`.

This CL is the last in a series described in cl/312713181, cl/317397413, and resolves b/156024690.

In this CL the new pattern for managing listener callbacks implemented in `FirebaseFirestore.ListenForSnapshotsInSync()` is being applied to all other places where we expose listeners (i.e. `Query` and `DocumentReference`).

PiperOrigin-RevId: 319089024

* Migrate const std::string& parameters to absl::string_view.

THIS CHANGE IS BELIEVED SAFE

Templated asynchronous code can change the lifetime of string data as a result
of this change; however, the most common uses of these (lambdas and callbacks)
are excluded from this change.
Further, your TAP tests pass.

go/string-ref-to-string-view-lsc

Tested:
    TAP --sample ran all affected tests and none failed
    http://test/OCL:319219698:BASE:319213711:1593616691507:a583f044
PiperOrigin-RevId: 319286243

* Avoid double deletion of internal objects during cleanup.

This has been observed during cleanup when a DocumentReferenceInternal is
destroyed, its Future API can end up deleting orphaned Future APIs that contain
Futures holding the containing `DocumentReference`.

PiperOrigin-RevId: 320260380

* Avoid empty statement warnings in Firebase assertions

Wrapping macro bodies in do { } while(false) makes them into a statement that
legitimately should be followed by a semicolon.

PiperOrigin-RevId: 320272779

* Miscellaneous test-only fixes

  * Avoid dereferencing awaited pointers after Await has failed, preventing
    crashes after test timeouts.
  * Await `CollectionReference::Add`, preventing nondeterminism in tests.

PiperOrigin-RevId: 320449430

* Delete C++ Firestore objects when C# has no more references to them.

This was achieved by using the CppInstanceManager, which provides this functionality elsewhere in the Unity SDK. When running UIHandlerAutomated, this eliminates all 11 leaks from Firestore::GetFirestore().

PiperOrigin-RevId: 320609048

* Remove the unconditional calls to Firebase::Terminate() in test cleanup.

These calls were present as a workaround for bugs in the Firestore destructor; however, since those bugs have been fixed the calls to Terminate() are now superfluous and, worse, can hide bugs. As a result, they are being removed.

PiperOrigin-RevId: 320627333

* Change std:unique_ptr to UniquePtr

This is causing Rapid build fail with error message like "error: no template named 'make_unique' in namespace 'std'; did you mean 'MakeUnique'?"
Since we have our own implementation, we should use it consistently.

PiperOrigin-RevId: 320681249

* Update Android deps to latest

PiperOrigin-RevId: 320688041

* Make test failures in numeric transforms tests easier to read

Previously, if the value was of the wrong type, you'd get a message like:

    Value of: snap.Get("sum").is_integer()
      Actual: false
    Expected: true

Which would give no indication of what the actual type or value was. Now tests
will fail like this:

   Expected equality of these values:
     snap.Get("sum")
       Which is: 1337 (Type::kDouble)
     FieldValue::Integer(value)
       Which is: 1337 (Type::kInteger)

As an added bonus this also simplifies the calling code because now we can just
assert that a value in a snapshot is equal to some expected value and
GoogleTest will do the heavy lifting of printing the differences.

One unsolved problem with this approach is how to handle equality within
epsilon for floating point values. This turns out to be non-trivial without
writing custom matchers, which is beyond the scope of what I wanted to tackle
here. Instead of solving this I've changed the tests to use values that have an
exact representation as doubles. This is easier to do for integral values than
for fractional ones so the tests now use integer-valued doubles to achieve the
same effect of cumulative addition as before.

PiperOrigin-RevId: 321022746

* Add JNI Object wrapper and type conversion traits

This is the first in a series of commits that aims to convert our JNI usage to
a more modern approach while still remaining STLPort compatible.

PiperOrigin-RevId: 321059370

* Add JNI ownership types

These generate local and global reference subtypes of a given JNI wrapper that
make it possible to automatically emit DeleteLocalRef and DeleteGlobalRef
calls in the course of regular usage.

PiperOrigin-RevId: 321175591

* Add FIREventScreenView and params

PiperOrigin-RevId: 321183165

* Add another line in the generate constant header script

The generated headers are currently missing a newline prior to @ifdef cpp_examples which is causing doc generation to fail.

PiperOrigin-RevId: 321272103

* Add initial Env with minimal support for Strings

PiperOrigin-RevId: 321475293

* Rework ToJni conversions to enable pass-through of JNI types

Previously, all types needed to be in the JniTypeMap, but this was never
intended to be the end state because it would require an entry for all subtypes
of Object which couldn't scale.

The new implementation based on ranked choice overload selection also resolves
ambiguities. For example: unsigned char could be a uint8_t (which converts to
jbyte) or the underlying type for jboolean. Absent the ranking, an argument of
type unsigned char would resolve to multiple overloads and would be ambiguous.

PiperOrigin-RevId: 321835773

* Add support for calling methods and getting fields.

PiperOrigin-RevId: 322398533

* Create dummy workflow for integration tests (#106)

To manually trigger a workflow in a branch, a workflow with the same name needs to exist in master. This adds such a workflow.

* Create feature-request.md

* Update and rename firebase-cpp-sdk-issue.md to issue.md

Update issue template

* Update issue.md

* Update issue templates

Add a new "General Question" template
Also make sure new feature request issues are marked with "new" label

* Update feature-request.md

* Revise string methods to be wrapper-only

Based on our offline discussion about reducing the number of overloads.

PiperOrigin-RevId: 322722526

* Fix deletion of the pointers returned from CreateFirestore().

The pointers returned from CreateFirestore() should be explicitly deleted, as well as the underlying app pointer, as is done in the ~FirestoreIntegrationTest() destructor for Firestore pointers returned from firestore() and CachedFirestore(). Several test cases in firestore_test.cc were failing to perform this deletion on the pointers returned from CreateFirestore(), resulting in memory leaks.

To facilitate consistency in this deletion logic, I exposed the Release() method so that they could be called by tests that use CreateFirestore().

I then updated the code in firestore_test.cc to call Release() on every pointer returned from CreateFirestore(). This fixes the memory leaks of the objects returned from CreateFirestore(), at least in the case that the tests pass. A future changelist will migrate usages of CreateFirestore() to CachedFirestore() to ensure that the Firestore pointers are deleted whether or not the test passes.

PiperOrigin-RevId: 322814077

* Add exception support to Env

This includes a Throwable wrapper for jthrowable, Env implementatinos of
JNIEnv::Throw, plus tools for writing exception resilient code.
PiperOrigin-RevId: 322836751

* Add logic to ignore a specific file in Kokoro build logic

The chromium_certificate_verifier uses a cc file as an include file, which breaks the CMake logic with add_library.  By excluding that file from the add_library, but keeping it in the zip file, it will still be available for the build to work, but will no longer try to treat it as a source file, which caused the problem.

Also, made the local_test script use the regular_grpc flag, since it is now needed

PiperOrigin-RevId: 323644686

* Add support for cacheable global declarations of JNI types

This includes:

  * constructors
  * instance methods
  * static fields
  * static methods

PiperOrigin-RevId: 323697946

* Add support for embedded files and other odds and ends

PiperOrigin-RevId: 323710861

* Convert CollectionReference to new JNI framework

PiperOrigin-RevId: 323822884

* Add C++ proxies for Java standard library types

This includes proxies for commonly used elements of java.util:

  * ArrayList
  * Collection
  * HashMap
  * Iterator
  * List
  * Map
  * Set

Only commonly used methods are included. Additional methods can be added as
needed.

PiperOrigin-RevId: 324895315

* Fix assertion incorrectly checking a moved-from rather than the moved-to object.

This should fix https://github.com/firebase/firebase-cpp-sdk/issues/85.

Note that this _was_ covered by tests (checked manually). Presumably, because a moved-from `std::function` is in a valid but unspecified state, it might or might not be left empty, depending on the implementation.

PiperOrigin-RevId: 324919105

* Improve `Variant` error message when used with an unsupported type.

In the previous implementation, `set_value_t` was declared to be a template function but never defined (instead, a few specializations were defined). This could cause a linker error when a `Variant` is used with an unsupported type (using `firestore::FieldValue` as the example):
```
ld.lld: error: blaze-out/k8-fastbuild/bin/_solib_k8/libfirebase_Sfirestore_Sclient_Scpp_Slibfield_Uvalue_Utest.ifso: undefined reference to void firebase::Variant::set_value_t<firebase::firestore::FieldValue>(firebase::firestore::FieldValue) [--no-allow-shlib-undefined]
```
(see https://sponge.corp.google.com/invocation?id=0dbf93d2-8644-4058-9b98-0513ad032e08&searchFor=user%3Avarconst)

Deleting the regular template has the advantage of turning it into a compile-time error that contains a reference to the line in the source code that triggers it:

```
In file included from firebase/firestore/client/cpp/src/tests/field_value_test.cc:17:
./firebase/app/client/cpp/src/include/firebase/variant.h:134:5: error: call to deleted member function 'set_value_t'
    set_value_t(value);
    ^~~~~~~~~~~
firebase/firestore/client/cpp/src/tests/field_value_test.cc:295:10: note: in instantiation of function template specialization 'firebase::Variant::Variant<firebase::firestore::FieldValue>' requested here
  return FieldValue{};
         ^
./firebase/app/client/cpp/src/include/firebase/variant.h:1114:8: note: candidate function [with T = firebase::firestore::FieldValue] has been explicitly deleted
  void set_value_t(T value) = delete;
       ^
1 error generated.
```
(see https://sponge.corp.google.com/invocation?id=8122d244-50d5-4072-98fb-9c5c11dc42ad&searchFor=user%3Avarconst)

This should be a non-breaking change (the code that was compiling previously should be unaffected).

PiperOrigin-RevId: 324927992

* Add support for creating and manipulating Java arrays to the `JNIEnv` wrapper

PiperOrigin-RevId: 325087878

* Improve the tests for ClearPersistence() to use the default Firebase app instead of a custom one.

This fixes a concern raised by @pengzk in cl/309775646 that the Firestore* pointers were leaking. By using the default Firestore object retrieved via firestore() instead of a custom Firestore object returned from CreateFirestore() the Firestore* pointer will be properly cleaned up upon test completion.

PiperOrigin-RevId: 325229850

* Convert DocumentReference and supporting classes to the new JNI framework

This includes:
  * SourceInternal
  * MetadataChangesInternal
  * FieldPathConverter
  * SetOptionsInternal
  * DocumentReferenceInternal

This also includes some changes to other types (like QueryInternal) to shim in
usage of the changed types. In some cases both the new and old ways coincide
within a method leading to some temporary bloat. These will be cleaned up in a
subsequent CL.

PiperOrigin-RevId: 325352325

* Rework MapFieldValue and MapFieldPathValue calls

Also:

  * Centralize Java update methods' first-pair-separate-from-varargs handling
    in a new MakeUpdateFieldPathArgs method
  * Also begin work on new-style error handling in transactions by bridging
    Env::UnhandledExceptionHandler to TransactionInternal::PreserveException.

PiperOrigin-RevId: 325468252

* Automated g4 rollback of changelist 325229850.

*** Reason for rollback ***

firestore_test_android appears to have been broken by this change (b/163526671).

*** Original change description ***

Improve the tests for ClearPersistence() to use the default Firebase app instead of a custom one.

This fixes a concern raised by @pengzk in cl/309775646 that the Firestore* pointers were leaking. By using the default Firestore object retrieved via firestore() instead of a custom Firestore object returned from CreateFirestore() the Firestore* pointer will be properly cleaned up upon test completion.

***

PiperOrigin-RevId: 326267389

* Updated MessageForwardingService to be a JobIntentService for Android O.

As of Android O, background services can no longer spawn other background
services, they must instead create JobIntentServices, which can queue up work
for the OS to perform when it is ready. This change also requires that the
JobIntentService be declared in the manifest file.

PiperOrigin-RevId: 326749322

* Deprecating Send.

When Send is actually removed from the underlying iOS SDK, we should check in cr/322694231 which removes it from C++ entirely.

PiperOrigin-RevId: 326753736

* LSC: Change for loops to use const refs, per performance-for-range-copy
clang-tidy.

This CL optimizes C++11 range-based for loops where the variable is copied in
each iteration but it would suffice to obtain it by const reference.  This is
only applied to loop variables of types that are expensive to copy which means
they are not trivially copyable or have a non-trivial copy constructor or
destructor.

To ensure that it is safe to replace the copy with a const reference the
following heuristic is employed:
  The loop variable is const qualified.
  The loop variable is not const, but only const methods or operators are
  invoked on it, or it is used as const reference or value argument in
  constructors or function calls.

See go/lsc-performance-for-range-copy for details.

Applied ClangTidy fixes to google3 paths matching '[abcdefghijklmnoprs].*'.

The changelist was automatically generated using the apply_fixes.sh script:
  devtools/cymbal/clang_tidy/apply_fixes.sh --checks=-*,performance-for-range-copy --create_changelist --files_to_process=[abcdefghijklmnoprs].*

Track: canary
Findings source: /placer/prod/home/devtools-cxx-clang-tidy/canary/latest/clang_tidy-?????-of-?????
Subcategories: performance-for-range-copy

WARNING: Automatically generated changes should be carefully inspected. For most
ClangTidy warnings multiple alternative fixes are possible and only one of them
is suggested. There's no guarantee that it will be the best one (or even a right
fix). The amount of reviewers' attention to automated changes should be at least
the same as for manually written code.

Tested:
    tap_presubmit: http://test/OCL:323300886:BASE:324354295:1596315075612:bb83204a
    Some tests failed; test failures are believed to be unrelated to this CL
PiperOrigin-RevId: 326827164

* Update the Android dependencies for M77

PiperOrigin-RevId: 327556559

* Convert DocumentChange to the new JNI framework

PiperOrigin-RevId: 327653990

* Convert ServerTimetampBehavior to new JNI framework

PiperOrigin-RevId: 327717920

* Convert SnapshotMetadata to the new JNI framework

PiperOrigin-RevId: 327727645

* Make Unity send Cloud API headers indicating the language version and the Firestore version.

This only works for iOS and Android for now; Android is still a TODO.

Also bump the Firestore version to 1.16.4 (it hasn't been updated in a long time and was still 1.1.0).

From debug logging, the value sent via the header looks like:
```
gl-dotnet/4.0.30319.42000 fire/1.16.4 grpc/1.32.0-dev
```

PiperOrigin-RevId: 327871420

* Convert DocumentSnapshot to the new JNI framework

PiperOrigin-RevId: 327886189

* Improve the error message that is generated when a Future fails.

PiperOrigin-RevId: 328179796

* Convert Blob to the new JNI framework

Also fix redundant blob caching behavior in `FieldValueInternal`, consolidating
the code to populate `cached_blob_` in a single `EnsureCachedBlob` method.

PiperOrigin-RevId: 328849949

* Convert Direction to the new JNI framework

Note that this gets rid of the enum caching mechanism in favor of just making a
JNI call to get the associated field. This reduces complexity, removes static
state, and greatly reduces the amount of code, with a minor performance penalty
to code that's not remotely performance critical.

PiperOrigin-RevId: 328856579

* Convert Settings to the new JNI framework

PiperOrigin-RevId: 329734038

* Convert WriteBatch to the new JNI framework

PiperOrigin-RevId: 329805287

* Convert Timestamp to the new JNI framework

PiperOrigin-RevId: 329814232

* Change forward declaration for SignInResult to struct

SignInResult is declared as a struct in user.h but forward declared here as a class.
This did not cause error in our build but is causing compiler error for user.

Fixed #120

PiperOrigin-RevId: 329958702

* Convert QuerySnapshot to the new JNI framework

PiperOrigin-RevId: 330111277

* Update the Android dependencies for M78

PiperOrigin-RevId: 330559438

* Re-write `run_local_tests.sh` to run the tests in parallel.

When I profiled this change locally, the runtime of the script was reduced from about 30 minutes down to 12 minutes when the blaze commands were run in parallel. This makes sense because a lot of the time is spent just waiting for Kokoro to perform the build.

PiperOrigin-RevId: 330748434

* Plumb through error messages for Query and Document listens in C++ and Unity.

NOTE: This changelist is a breaking change in that it changes the public C++ Firestore API in a backwards-incompatible manner.
PiperOrigin-RevId: 330757239

* Check that calls to Terminate() and ClearPersistence() actually succeed.

I had incorrectly assumed that `Await()` would fail the test if the `Future` it was specified failed. This incorrect assumption hid the fact that `ClearPersistence()` failed on Android, resulting in unexplained downstream failures, resulting in a rollback: cl/326267389.

With this change, the failure of the `Future` objects returned from `ClearPersistence()` and `Terminate()` will be noted, highlighting the source of the test failures.

PiperOrigin-RevId: 330777066

* Add logic to detect the compiler version and the C++ language standard used.

This is largely adapted from the Cloud C++ APIs with the following changes:

* added C++20 to the list of possible standards;
* added "latest" as a possible C++ standard for MSVC;
* added the C++ standard library vendor to the compiler info string, primarily
  to track STLPort.

Here are some sample values I'm getting:
* on my Mac laptop: `AppleClang-11.0.3.11030032-ex-2011-libcpp`;
* google3 Android build: `Clang-9.0.8-ex-2017-libcpp`;
* google3 Windows build: `MSVC-19.22.27905-ex-2017-msvc`;
* google3 Linux build: `Clang-9999.0.0-noex-2017-libcpp` (unfortunately,
  Clang trunk in google3 simply sets the version to 9999:
  https://source.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang/BUILD;l=374-383;rcl=330443088)

Note that as long as the C++ SDKs are distributed in precompiled form, the compiler version reported will be from the compiler we used to compile the binaries, not the compiler used by our users. Unfortunately, there is no clear way to avoid this that wouldn't cause an ODR violation (if e.g. `CompilerId` were placed in a header as an inline function, it would end up having different definitions depending on whether it's included internally or by the user (indirectly)). However, this shouldn't be a big issue as the metrics will still allow tracking total C++ usage and, to an extent, usage by platform.

PiperOrigin-RevId: 331654266

* Automated g4 rollback of changelist 326267389.

*** Reason for rollback ***

Roll forward cl/325229850: Improve the tests for ClearPersistence() to use the default Firebase app instead of a custom one.

I've added a workaround for the broken test, a call to Terminate() in Android, and created b/168628900 to track the underlying bug.

*** Original change description ***

Automated g4 rollback of changelist 325229850.

*** Reason for rollback ***

firestore_test_android appears to have been broken by this change (b/163526671).

*** Original change description ***

Improve the tests for ClearPersistence() to use the default Firebase app instead of a custom one.

This fixes a concern raised by @pengzk in cl/309775646 that the Firestore* pointers were leaking. By using the default Firestore object retrieved via firestore() instead of a custom Firestore object return...

***

PiperOrigin-RevId: 331991549

* Temporarily add a platform token to the Cloud API headers.

Until b/135633112 is resolved and support for Firebase platform logging is
rolled out on the Firestore backend, there is no good way to estimate the
number of users of the Firestore C++ SDK by platform. As a workaround, add
a platform token to the Cloud headers. Proper support for platform tokens was
actually never added to Cloud headers, but the data processing pipeline
simply ignores unknown tokens so there is no harm in doing this addition.

The implementation reuses the notion of a client language in the Core API to
lump together two tokens (the language and the platform). This is deemed
acceptable only due to the temporary nature of this workaround.

Sample of the header values I'm seeing:
- running C++ tests on Linux in google3:
  `gl-cpp/Clang-9999.0.0-noex-2017-libcpp gl-linux/ fire/1.17.1 grpc/1.33.0-dev`
  (notice the `gl-linux/` token);
- in Unity: `gl-dotnet/4.0.30319 gl-macos/ fire/1.17.1 grpc/1.33.0-dev` (notice
  the `gl-mac/` token);

PiperOrigin-RevId: 332094253

* Add play-services-base to Android deps for analytics/admob/remote_config.

Due to a change in the transitive dependencies of analytics, play-services-base is no longer present. This is needed to check for the presence of Google Play Services. Admob and Remote Config both depend on analytics (through 'app'), which is how they previously got that dependency. Other APIs depend directly on play-services-base at the Android level.

PiperOrigin-RevId: 332267491

* Update the Build and Podfiles

PiperOrigin-RevId: 332327282

* Update the version numbers for 6.16.0

PiperOrigin-RevId: 332496615

* Convert GeoPoint to the new JNI framework

PiperOrigin-RevId: 333116446

* Handling `IllegalStateException` when loading or creating interstitial ads.
(reported in https://github.com/firebase/firebase-cpp-sdk/issues/121

New error code and message for the default fallback case in switch statements- ConstantsHelper.CALLBACK_ERROR_UNKOWN and ConstantsHelper.CALLBACK_ERROR_MESSAGE_UNKNOWN.
Corresponding new error code added to C++ side (admob/types.h)

Removed a redundant overridden method as it was just calling its base class method directly.

Updated release notes with this bugfix

PiperOrigin-RevId: 333125360

* Convert Query to the new JNI framework

PiperOrigin-RevId: 333157347

* Copybara Firestore

PiperOrigin-RevId: 333174406

* Added a test for C++ namespace renaming to Blastdoor tests, and added a fix to
rename symbols that are external references implemented in other files.

This fixes a Blastdoor issue where a symbol that needs to be renamed is passed
between multiple internal libraries -- it needs to be renamed regardless of whether its
implementation is present or if it is an external symbol.

PiperOrigin-RevId: 333175764

* Set the language in Cloud headers to `gl-cpp/` in the C++ SDK on Android.

This is possible now that the Copybara CL cr/333174406 is submitted. This CL requires on Android functionality available starting from M80 (Firestore 21.7.0).

PiperOrigin-RevId: 333356092

* Convert FirestoreInternal to the new JNI framework

This converts all method invocations but does not necessarily convert all uses
of older APIs because those are still needed to support classes that have not
yet converted.

PiperOrigin-RevId: 333429091

* Convert ListenerRegistration to the new JNI framework

PiperOrigin-RevId: 333539837

* Fix it so only external C++ symbols matching the list of namespaces to rename
are renamed. C symbols that are external will not be renamed.

Also adds a flag to turn off this new behavior, though it's on by default for
now.

PiperOrigin-RevId: 333613425

* Convert EventListener to the new JNI framework

PiperOrigin-RevId: 334212158

* Clean up exception naming

Rename FirebaseFirestoreExceptionInternal to ExceptionInternal.  Rename methods
in ExceptionInternal to better reflect their function.

PiperOrigin-RevId: 334219916

* Convert ExceptionInternal to the new JNI framework

Also partially convert TransactionInternal since these are so intertwined.

PiperOrigin-RevId: 334241429

* Make snapshot from TransactionGetResult return by value.

This ensure C# DocumentSnapshot will own the C++ DocumentSnapshot when it is read from within a transaction.

PiperOrigin-RevId: 334276809

* Add Ad Impression constants to public header

PiperOrigin-RevId: 334451358

* Finish conversion of TransactionInternal to the new JNI framework

PiperOrigin-RevId: 334459761

* Add boxed primitive types to the JNI library

PiperOrigin-RevId: 334472082

* Add example to ad unit in header file

PiperOrigin-RevId: 334482610

* Add note about value param in ad impression event

PiperOrigin-RevId: 334497833

* Add Equals to the JNI Object proxy.

Also add GetClass to some JNI proxies.

Remove Wrapper::EqualsJavaObject

PiperOrigin-RevId: 334501941

* Add a cache of Firestore Java references to FirestoreInternal pointers

Use it in DocumentSnapshotInternal::Create, removing the need for FieldValue to
have a FirestoreInternal pointer.

PiperOrigin-RevId: 334519517

* Update to the Messaging Library Manifest File which caused build issues in GH CI.  Embedding the service clause inside application.

PiperOrigin-RevId: 334851815

* Automated g4 rollback of changelist 333356092.

*** Reason for rollback ***

Temporary rollback to unblock the FPL release (which depends on Android M79).

*** Original change description ***

Set the language in Cloud headers to `gl-cpp/` in the C++ SDK on Android.

This is possible now that the Copybara CL cr/333174406 is submitted. This CL requires on Android functionality available starting from M80 (Firestore 21.7.0).

***

PiperOrigin-RevId: 335476967

* Remove FirestoreInternal::Wrap and Internal

Also remove the related ApiType using declarations.

PiperOrigin-RevId: 335887511

* Convert FieldValue to the new JNI framework

PiperOrigin-RevId: 335989850

* Convert Wrapper to the new JNI framework

PiperOrigin-RevId: 335995848

* Reduce dependencies on app's util_android.h

PiperOrigin-RevId: 336138470

* Post-migration clean-up

  * Remove references to jni.h where JNI types aren't directly used
  * Clean up remaining jobject APIs that don't belong anymore
  * Clean up method names now that conflicts are gone

PiperOrigin-RevId: 336164270

* Reorganize utilities

  * Move exception utilities into exception_android.h
  * Move collection conversion utilities in Wrapper into util_android.h

This more-or-less achieves the goal of reducing the role of Wrapper as a
dumping ground for random functionality and brings exception-related code into
a single location.

PiperOrigin-RevId: 336189320

* [FIS]CPP package change (8/n)

PiperOrigin-RevId: 336203653

* Fix a deadlock between snapshot listeners and cleanup.

The deadlock may be triggered by the following steps:
1. Add a snapshot listener to a collection (a document reference or a query will likely work as well, but not tested).
2. Wait for the listener to fire.
3. Immediately after that, delete the App or the Firestore instance (which invokes cleanup).

Note that because the deadlock is timing-based, it's not guaranteed to happen.

With simplifications, this leads to the following call stacks (using collection listeners for the sake of the example):

  User callback thread
- `AsyncEventListener::OnEvent` locks the listener mutex (LM);
- `AsyncEventListener::OnEvent` invokes the user callback;
- when the user callback is finished, a `QuerySnapshot` passed to the callback is destroyed
- the destructor of `QuerySnapshot` tries to unregister itself from the cleanup;
- the unregister function tries to acquire the cleanup mutex (CM).

  “Main” thread (the thread on which the Firestore instance is destroyed)
- Firebase App is destroyed;
- Firestore instance is destroyed;
- `Firestore` destructor triggers cleanup;
- Cleanup locks the cleanup mutex (CM);
- Cleanup invokes `firestore::ListenerRegistration::Cleanup`;
- Listener registration cleanup invokes `AsyncEventListener::Mute`;
- `AsyncEventListener::Mute` tries to acquire the listener mutex (LM).

To work around this, make sure to clear the listeners _before_ invoking the cleanup in `Firestore` destructor.

An alternative fix would be to make sure `CleanupNotifier` doesn't hold the mutex while invoking cleanup callbacks. Unfortunately, cleanup callbacks might destroy objects that are subject to cleanup as well and thus would try to unregister themselves, preventing this approach. In other words, if `CleanupNotifier` contains, say, 10 callbacks, there is no guarantee that it will still contain 10 callbacks after the first one is invoked.

PiperOrigin-RevId: 336603266

* Update the version numbers to 6.16.1

PiperOrigin-RevId: 336993745

* Added helper function to create directories recursively on desktop platforms(mac, windows and linux).

This fixes SEGFAULTS that were seen on running database integration tests. Issue was that "app_name" is usually a string with a "/" in it and mkdir calls on Mac and Windows were not creating directories recursively.

Changes were first done on github in this PR,
https://github.com/firebase/firebase-cpp-sdk/pull/124

Updated C++ and Unity release notes.

Created an accompanying unit test in `database/util_desktop_test UtilDesktopTest.TestSplitString`

Modified UtilDesktopTest.TestGetAppDataPath to test with an app path with a delimiter (the reason our previous release didn't catch this bug).

PiperOrigin-RevId: 337121244

* Remove the call from Database to variant_utils that take Flexbuffers

Because of a problem with the merge_libraries script, functions that take Flexbuffers as parameters are not being handled correctly. Until this is fixed, work around it by not relying on those functions.

PiperOrigin-RevId: 337611271

* Remove the dependency on variant_util from Database

PiperOrigin-RevId: 337929528

* [FIS] mark IID deprecated

PiperOrigin-RevId: 338139599

* Import Firestore release 1.19.0 from GitHub (Firebase 6.34.0, M81).

Manual changes:
- add a new build target for `FirebaseMetadataProvider` and related plumbing;
- downgrade the constants defined in `FirebaseMetadataProvider` from `constexpr` to just `const` to work around a Visual Studio compiler bug;
- remove `core_portable` build target (it's an unused target);
- revert the manual import of https://github.com/firebase/firebase-ios-sdk/pull/6778 (affecting `remote/serializer.cc`) being overwritten (it's part of M82, not M81);
- prevent cr/337586325 from being overwritten by the import;
- bump the Firestore version in `third_party/firebase/ios/Releases/FirebaseFirestore/version.bzl`;
- revert the google3-internal change to `util/exception.cc` being overwritten (see cr/295257418).

BUG=130370442

Copybara-generated description follows:

  - 2d7778cdfb43a9fe7e042f5beea89e8056fb74e7 Add a changelog entry for Firestore platform logging (#66... by Konstantin Varlamov <var-const@users.noreply.github.com>
  - a039948badb3e35f3c9d773972c7eb477911bec1 Update CHANGELOG for Firestore v1.19.0 (#6601) by Gil <mcg@google.com>
  - 393d32f05e072cb65242340e7737b860b1f73f57 Make FirestoreException a type defined by Firestore/core ... by Gil <mcg@google.com>
  - 54e0bb81fd054d8d822592db17762591972a55af Always send the user agent regardless of the heartbeat va... by Konstantin Varlamov <var-const@users.noreply.github.com>
  - 2311c36dbcd19f2f6e89f0f2747582f0647442f7 Integrate Firestore with Firebase platform logging (#6507) by Konstantin Varlamov <var-const@users.noreply.github.com>
  - 24a77d04c88fd9e6466009cd343a4d7553b65cc3 Import Spec tests (#6525) by Sebastian Schmidt <mrschmidt@google.com>
  - 47fcf141ad7cd2905068a1b1a08988a92fc2bc6c Fix FSTGoogleTestTests under Xcode 12 (#6478) by Gil <mcg@google.com>

PiperOrigin-RevId: 338359239

* Make Android's FirestoreException match iOS

This prepares for the copybara import of
https://github.com/firebase/firebase-ios-sdk/pull/6589, keeping any dependent
work in this stream independent of when we actually perform the import into
third_party.

PiperOrigin-RevId: 339161530

* [M82]Update android dependencies

PiperOrigin-RevId: 339288456

* [RemoteConfig V2] update api deprecation for Fireconf

PiperOrigin-RevId: 339295475

* Update the Build and Podfiles for 7.0.0

PiperOrigin-RevId: 339314101

* Removing deprecated Send and Direct Channel functionality

Cloned from CL 322694231 and 319894420

PiperOrigin-RevId: 339360356

* [FCM]Add GetToken, DeleteToken function

PiperOrigin-RevId: 339497618

* [M82]Fix an RC change that fails build unity

PiperOrigin-RevId: 339517841

* Updated the raw_data field in messaging.h to be a vector of bytes instead of a
string.

Using a string makes it difficult to work with byte streams that have embedded
null characters. In these situations it makes more sense to represent the data
as what it actually is, a sequence of raw bytes.

Previously this field was unused in C++ and never populated, so although this
is a change to a public header it should not break anyone, and anyone who is
broken by this was not using it correctly anyway.

Patch of CL 288600981, 288601322, 288601437

PiperOrigin-RevId: 339735518

* Remove deprecated SetMinimumSessionDuration in Analytics

SetMinimumSessionDuration has been deprecated for more than a year, so removing it.

PiperOrigin-RevId: 339744045

* Update the version numbers to 7.0.0

PiperOrigin-RevId: 340263010

* Automated g4 rollback of changelist 335476967.

*** Reason for rollback ***

Firebase C++ now depends on Android M82, so this is fine to resubmit.

*** Original change description ***

Automated g4 rollback of changelist 333356092.

*** Reason for rollback ***

Temporary rollback to unblock the FPL release (which depends on Android M79).

*** Original change description ***

Set the language in Cloud headers to `gl-cpp/` in the C++ SDK on Android.

This is possible now that the Copybara CL cr/333174406 is submitted. This CL requires on Android functionality available starting from M80 (Firestore 21.7.0).

***

***

PiperOrigin-RevId: 340267852

* Port WhereNotEqualTo and WhereNotIn to C++ SDK

PiperOrigin-RevId: 340640828

* LSC: Add absl::GetFlag and absl::SetFlag to uses of some flags so they can be migrated to v2 flags (i.e. ABSL_FLAG).

Affected flags: all relevant call sites under [d-i].*

More information: go/v2_flags_migration_lsc

Tested:
    TAP sample presubmit queue
    http://test/OCL:340643476:BASE:340643884:1604503763836:7248bd60
PiperOrigin-RevId: 340706255

* [Unity] Port NotEqual and NotIn Queries to Unity SDK

iOS: https://github.com/firebase/firebase-ios-sdk/pull/6418
Android: https://github.com/firebase/firebase-android-sdk/pull/1975
C++: cl/340640828
PiperOrigin-RevId: 341115259

* Add support for setting and retrieving the cache size to `Settings`.

PiperOrigin-RevId: 341144709

* #cleanup Unable to fix after @UiThread or runOnMainSync

(Not submitting until 11/9)

A go/rosie is not being done for this as adding the new calls and removing the old calls must be done at the same time (if we did one before the other, the tests would be failing in between)

For several years now, Android instrumentation tests in Google3 have been using the incorrect flag to specify test timeouts to AndroidJUnitRunner. However, due to an old bit of hacky behavior in Google3InstrumentationTestRunner, we cannot simply fix the problem by switching the code to use the correct flag.

In particular, Google3InstrumentationTestRunner currently starts a Looper that allows tests to be able to post events from the test thread (when tests aren’t supposed to be able to). Since using the correct flag in AndroidJUnitRunner would cause the test to now run in a separate thread from before, any tests that relied on this Looper would start to fail.

So, before we can turn on the flag, we need to go through and address all the tests that relied on the above behavior in Google3InstrumentationTestRunner.

If your test is in this changelist, it means that the test is posting events from the test thread, and we were unable to find a simple fix to suggest. To unblock everyone else, we’ve decided to move the associated Looper call to your tests’ setup so that your tests will still work when timeout enforcement is done correctly. A TODO(b/…) is being added next to the new call as a tracking bug for teams who wish to later (on their own time/schedule) refactor their test to no longer rely on the call.
```
# Startblock config for deferred review.
Startblock:
  has lgtm
  and then
  add tedbisson
```
PiperOrigin-RevId: 341435027

* [FIS]Add unit test for getId, getToken, delete

PiperOrigin-RevId: 341440510

* Make `Query` methods that return new queries (e.g. `WhereEqualTo`) const.

PiperOrigin-RevId: 341469549

* Remove deprecated Dynamic Links properties in C++ and Unity SDK

PiperOrigin-RevId: 341662413

* Extract the has-exceptions test into a common header

Also make some portable definitions of Abseil support macros in preparation for
future CLs.

PiperOrigin-RevId: 341724467

* Implement Firebase Heartbeat in C++.

Also integrates the Firestore C++ SDK with the heartbeat and Firebase platform logging.

See go/firestore-sdk-metrics for more context.

Sample user agent strings I'm seeing in tests:

C++ Linux
```
fire-cpp/6.16.1 fire-cpp-arch/x86_64 fire-cpp-os/linux fire-cpp-stl/libcpp fire-fst/1.19.0
```

C++ macOS
```
fire-cpp/6.16.1 fire-cpp-arch/x86_64 fire-cpp-os/darwin fire-cpp-stl/libcpp fire-fst/1.19.0
```

Unity macOS
```
fire-cpp/6.16.1 fire-cpp-arch/x86_64 fire-cpp-os/darwin fire-cpp-stl/libcpp fire-fst/1.19.0 fire-unity/6.16.1 fire-unity-ver/2019.2.0f1
```

Unity iOS
```
apple-platform/ios apple-sdk/18A390 fire-analytics/6.9.0 fire-auth/6.9.2 fire-cpp-arch/arm64 fire-cpp-os/ios fire-cpp-stl/libcpp fire-cpp/6.16.1 fire-fst/1.19.0 fire-install/1.7.0 fire-ios/6.10.4 fire-unity-ver/2019.2.0f1 fire-unity/6.16.1 swift/true xcode/12A7300
```

C++ Windows
```
fire-cpp/6.16.1 fire-cpp-arch/x86_64 fire-cpp-os/windows fire-cpp-stl/MT fire-fst/1.19.0
```

PiperOrigin-RevId: 341930017

* Fix Unity Editor hang on Windows when Listen() is invoked (b/172566004).

The issue is that when the C++ callback crosses the boundary into C# via P/Invoke, C# becomes aware of the existence of the thread. Later, when the "play" button is used in the Unity Editor to restart the app, the AppDomain unloading process starts, first signaling all threads that it knows exist then waiting for all of those threads to terminate; however, the callback thread is part of a thread pool and does not terminate in response to the signal, causing AppDomain unloading to deadlock.

This fix converts the callbacks to use `callback.h`, which was created a few years ago by the FPL team to address this exact issue. It addresses the issue because the thread that crosses the P/Invoke boundary is one that *is* terminated in response to the signal sent during AppDomain unloading, thus avoiding deadlock.

This fix probably also fixes b/170201731, where the Unity Editor hangs intermittently on non-Windows hosts as well.

PiperOrigin-RevId: 342100274

* Fix Android crash when Firestore is disposed during a transaction callback.

PiperOrigin-RevId: 342108114

* Copybara Firestore

PiperOrigin-RevId: 342159130

* Re-write the transaction logic to run the user-supplied callback asynchronously.

The motivation for this change is to work around the `ThreadAbortException` that crashes the Unity Editor if Play/Pause is toggled while a transaction is in progress (b/169264353).

Previously, the user-supplied C# transaction callback was called from C++ and would block in C# until the callback, and all of its asynchronous tasks, especially I/O-bound `Transaction.GetSnapshotAsync()` tasks, completed. If the Play/Pause button was used to restart the app in the Unity Editor during the time that the C++ thread was blocked in C# then the `ThreadAbortException` would occur and unavoidably cross the P/Invoke boundary into C++, causing the crash.

The fix is to still call the user-supplied C# transaction callback synchronously from C++; however, instead of blocking in C# until all of the asynchronous tasks complete, the callback returns to C++ and C++ waits for C# to signal the completion of the asynchronous tasks. This reduces the window during which the `ThreadAbortException` could occur to be on par with other listener callbacks that do not suffer from `ThreadAbortException`-related crashes.

PiperOrigin-RevId: 342923297

* Clean up `Firestore` instance management.

The main change is to merge the `firestore()`, `CachedFirestore()`, and `CreateFirestore()` methods into a single new method: `TestFirestore()`. The new `TestFirestore()` method accepts an app name that defaults to the default app's name.

The old methods map to the new methods as follows:
- `firestore()` -> `TestFirestore()`.
- `CachedFirestore(app_name)` -> `TestFirestore(app_name)`
- `CreateFirestore(app_name)` -> `db = TestFirestore(app_name)` followed by `DeleteFirestore(db)` or `RemoveFirestore(db)`

Finally, instead of explicitly calling `delete` on `App` and `Firestore` instances, use the methods `DeleteFirestore()` and `DeleteApp()`, respectively. All objects returned from `TestFirestore()` will be automatically deleted at the end of the test, so deleting these objects explicitly would result in double-deletion in the `FirestoreIntegrationTest` destructor. This is different from the old `CreateFirestore` method, which required that the caller explicitly delete the returned `Firestore` instance and its `App`.

PiperOrigin-RevId: 343482286

* Remove unnecessary std before strlen, as it causes problems

PiperOrigin-RevId: 343586290

* Update Integration and Testapp minimum target iOS version to fix rapid buid failures.

PiperOrigin-RevId: 343591435

* A second update to the integration and testapp XCode projects to bump the minimum target iOS version.  The previous attempt to set the version to 10.0 didn't work.  Should have been 10.12 according to second bullet point in the [Firebase release notes](https://firebase.google.com/support/release-notes/ios#version_700_-_october_26_2020).

PiperOrigin-RevId: 343888975

* Automated g4 rollback of changelist 343888975.

*** Reason for rollback ***

The version should have been 10.0 all along.  I misread the release notes - it's the Mac OSX version must be 10.12, not the iOS version.

I've determined that this issue is caused by the Unity project which targets iOS 9.0, a version beneath our minimum supported version.

*** Original change description ***

A second update to the integration and testapp XCode projects to bump the minimum target iOS version.  The previous attempt to set the version to 10.0 didn't work.  Should have been 10.12 according to second bullet point in the [Firebase release notes](https://firebase.google.com/support/release-notes/ios#version_700_-_october_26_2020).

***

PiperOrigin-RevId: 344283048

* Fix invalid conversion from AuthError to a Firestore Error.

PiperOrigin-RevId: 344844086

* Fix AdMob Android to initialize JavaVM earlier in initialization.

Fixes publicly reported bug: https://github.com/firebase/firebase-cpp-sdk/issues/192

PiperOrigin-RevId: 344901416

* Fix 1 ClangTidyReadability finding:
* unqualified call to function 'std::getline' uses ADL For more info see go/clang_tidy/checks/google3-readability-adl-call

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Suggest a fix on the CL (go/how-to-suggest-fix).
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/clang-tidy-bug for category ClangTidyReadability if the change looks generally problematic.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

#codehealth

PiperOrigin-RevId: 345303103

* Fix memory leaks in ReleaseXArrayElements:

The inspected code used JNI_COMMIT as a release mode,
which is specified as a release mode that copies
the changes to the Java array, but does not free the
native buffer (in case when the array is a copy) [1, 4].
Hence, when used as the last Release... mode, it effectively
leaks the native buffer when the provided array is a copy
(see the Hotspot implementation [2, 3], which always copies).

Instead, in this use-case "0" mode must be used.

The code fragments have been inspected to not do anything fancy with
the buffer pointer — they all store the buffer in local variables,
and release the array after they are done.

A full-blown fix is to use a safer alternative, jni_helper,
as `CHECK_JNI(FATAL, env).GetXArrayElements`, see
http://google3/util/java/jni_helper.h?l=141-150&rcl=341324486

Ironically, the issue was discovered when I searched for any good examples
of JNI_COMMIT usage IRL, to aid in making a decision on supporting this
flag in jni-rs, safe JNI bindings for Rust.

The code under third_party is not yet inspected.

[1]: https://docs.oracle.com/en/java/javase/11/docs/specs/jni/functions.html#releaseprimitivetypearrayelements-routines
[2]: http://google3/third_party/java_src/jdk/head/src/src/hotspot/share/prims/jni.cpp?l=2613&rcl=302688582
[3]: http://google3/third_party/java_src/jdk/head/src/src/hotspot/share/prims/jni.cpp?l=2665-2670&rcl=302688582
[4]: https://developer.android.com/training/articles/perf-jni#primitive-arrays

Tested:
    TAP --sample ran all affected tests and none failed
    http://test/OCL:341596811:BASE:341578570:1605013504633:7ec031b2
PiperOrigin-RevId: 345402895

* Fix bug where including a "delete" operation in an update causes partial updates.

The easiest fix would have been to replace `break` with `continue`; however, I changed it to an if/else statement to be in line with the other SDKs. See b/174676322 for details.

This bug affects both the Firestore Unity and C++ SDKs. Therefore, I have added unit test coverage to both for this specific case.

This bug was originally reported by a customer: https://github.com/firebase/quickstart-unity/issues/882

PiperOrigin-RevId: 345664484

* [M82][RemoteConfig] Remove deprecated android apis in 7.0.0

This is a hacky fix to switch the old api into new ones. Some of the old apis are not functional at all, but need to make sure app is not crash.

Android Api removed:
FirebaseRemoteConfig.activateFetched
FirebaseRemoteConfig.setDefaults(int)
FirebaseRemoteConfig.setDefaults(Map)
FirebaseRemoteConfig.setConfigSettings
FirebaseRemoteConfig.getByteArray

FirebaseRemoteConfigSettings.isDeveloperModeEnabled
FirebaseRemoteConfigSettings.Builder.setDeveloperModeEnabled

PiperOrigin-RevId: 345794794

* Adding play services base to app resources

* removed deleted src/ios/firebase_firestore_settings_ios files

* update ios target version

* move play-services-base to google_api_resources build.gradle

* fixed version control conflict marker

* Search headers in xcframework path

Update the CMakeLists, so that it searches headers in xcframework path.

* fail if build subprocess fail

build fail if any subprocess fail

* fixing merge conflict remnant

* add gPRC dependency

* build fail when subprocess fail

* Update podfile in iOS integration test as well

* Build fixes for dev branch (#210)

- fixed gmock include paths for files in app/tests directory.
- removed util_desktop_windows, util_desktop_linux, and util_desktop_maco from CMakefiles.

* Firestore Dependency update & gmock include fix (#214)

Updated Firestore depenency in cmake external to a the checksum for 7.0.0.

Fixed gmock header issues.

* added release notes

* Fixes for packaging steps (#215)

 - Replaced std mutex with our own app mutex in app/src/heartbeat_date_storage_desktop.cc.
 - Removed heartbeat code from Android builds.

Co-authored-by: wuandy <wuandy@google.com>
Co-authored-by: cynthiajiang <cynthiajiang@google.com>
Co-authored-by: amaurice <amaurice@google.com>
Co-authored-by: Googler <noreply@google.com>
Co-authored-by: Jon Simantov <jsimantov@google.com>
Co-authored-by: amablue <amablue@google.com>
Co-authored-by: mcg <mcg@google.com>
Co-authored-by: chkuang <chkuang@google.com>
Co-authored-by: anonymous-akorn <66133366+anonymous-akorn@users.noreply.github.com>
Co-authored-by: chkuang-g <31869252+chkuang-g@users.noreply.github.com>
Co-authored-by: varconst <varconst@google.com>
Co-authored-by: Mou Sun <69009538+sunmou99@users.noreply.github.com>
@firebase firebase locked and limited conversation to collaborators Jan 4, 2021
@dconeybe
Copy link

The fix for this bug is included in today's Unity SDK 7.1.0 release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants