diff --git a/Firestore/CHANGELOG.md b/Firestore/CHANGELOG.md index 8d8374ed5b6..7476ff09061 100644 --- a/Firestore/CHANGELOG.md +++ b/Firestore/CHANGELOG.md @@ -1,5 +1,9 @@ # Unreleased +# v1.16.2 +- [fixed] Fixed a configuration issue where listeners were no longer being + called back on the main thread by default. + # v1.16.1 - [fixed] Removed a delay that may have prevented Firestore from immediately establishing a network connection if a connectivity change occurred while diff --git a/Firestore/Example/Tests/Integration/API/FIRDatabaseTests.mm b/Firestore/Example/Tests/Integration/API/FIRDatabaseTests.mm index 37986bd9fc8..2e17dca5851 100644 --- a/Firestore/Example/Tests/Integration/API/FIRDatabaseTests.mm +++ b/Firestore/Example/Tests/Integration/API/FIRDatabaseTests.mm @@ -1493,6 +1493,15 @@ - (void)testListenerCallbackBlocksRemove { // `ListenerRegistration::Remove()` and expect to be able to immediately delete that state. The // trouble is that there may be a callback in progress against that listener so the implementation // now blocks the remove call until the callback is complete. + // + // To make this work, user callbacks can't be on the main thread because the main thread is + // blocked waiting for the test to complete (that is, you can't await expectations on the main + // thread and then have the user callback additionally await expectations). + dispatch_queue_t userQueue = dispatch_queue_create("firestore.test.user", DISPATCH_QUEUE_SERIAL); + FIRFirestoreSettings *settings = self.db.settings; + settings.dispatchQueue = userQueue; + self.db.settings = settings; + XCTestExpectation *running = [self expectationWithDescription:@"listener running"]; XCTestExpectation *allowCompletion = [self expectationWithDescription:@"allow listener to complete"]; diff --git a/Firestore/Source/API/FIRFirestore.mm b/Firestore/Source/API/FIRFirestore.mm index fc30e95ff36..7bcb4f94781 100644 --- a/Firestore/Source/API/FIRFirestore.mm +++ b/Firestore/Source/API/FIRFirestore.mm @@ -42,6 +42,7 @@ #include "Firestore/core/src/core/transaction.h" #include "Firestore/core/src/model/database_id.h" #include "Firestore/core/src/util/async_queue.h" +#include "Firestore/core/src/util/config.h" #include "Firestore/core/src/util/empty.h" #include "Firestore/core/src/util/error_apple.h" #include "Firestore/core/src/util/exception.h"