Skip to content

ConnectivityMonitorApple::OnReachabilityChanged callbacks on the wrong queue #3661

Closed
@ghost

Description

[READ] Step 1: Are you in the right place?

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 10.3
  • Firebase SDK version: 6.7.0
  • Firebase Component: Firestore
  • Component version: 1.4.4

[REQUIRED] Step 3: Describe the problem

Firestore crashes when trying to write data

Steps to reproduce:

Don't have exact steps. Stack trace:

Fatal Exception: NSInternalInconsistencyException
FIRESTORE INTERNAL ASSERTION FAILED: Expected to be called by the executor associated with this queue (expected executor: 'com.google.firebase.firestore', actual executor: 'com.apple.main-thread') (expected executor_->IsCurrentExecutor())

Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x18763e98c __exceptionPreprocess
1  libobjc.A.dylib                0x1868179f8 objc_exception_throw
2  CoreFoundation                 0x187558098 +[_CFXNotificationTokenRegistration keyCallbacks]
3  Foundation                     0x188068de8 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:]
4  Smart Home                     0x103830750 firebase::firestore::util::internal::Fail(char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
5  Smart Home                     0x103830868 firebase::firestore::util::internal::Fail(char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const*)
6  Smart Home                     0x103789040 firebase::firestore::util::AsyncQueue::VerifyIsCurrentExecutor() const
7  Smart Home                     0x1037891b0 firebase::firestore::util::AsyncQueue::ExecuteBlocking(std::__1::function<void ()> const&)
8  Smart Home                     0x10378fad4 firebase::firestore::remote::ConnectivityMonitorApple::OnReachabilityChanged(unsigned int)
9  SystemConfiguration            0x1883b0118 reachPerformAndUnlock
10 libdispatch.dylib              0x18707ca38 _dispatch_call_block_and_release
11 libdispatch.dylib              0x18707d7d4 _dispatch_client_callout
12 libdispatch.dylib              0x18705d9e4 _dispatch_main_queue_callback_4CF$VARIANT$armv81
13 CoreFoundation                 0x1875d032c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
14 CoreFoundation                 0x1875cb264 __CFRunLoopRun
15 CoreFoundation                 0x1875ca7c0 CFRunLoopRunSpecific
16 GraphicsServices               0x1897cb79c GSEventRunModal
17 UIKitCore                      0x1b3f87c38 UIApplicationMain
18 Smart Home                     0x102f8b6c0 main (<compiler-generated>)
19 libdyld.dylib                  0x18708e8e0 start

Relevant Code:

My Firestore database initialization is going on a dedicated dispatch queue and my write requests also run in the same queue. So, for the Firestore I always use one exact dispatch queue.

// very simplified version of my firestore app usage

let dispatchQueue =  DispatchQueue(label: "my label", qos: .userInitiated)

dispatchQueue.async {
// then lazy property initialize Firestore on this queu
  
private lazy var db: Firestore = {
        let db = Firestore.firestore()
        db.settings.dispatchQueue = self.dispatchQueue
        return db
    }()

// then on this queue I'm creating document references and trying to write data

let document = db.collection("some").document("some")
document.setData([id: json],
                                 merge: true)
            }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions