Firebase-ios-sdk: FIRESTORE INTERNAL ASSERTION FAILED: enterCheckedOperation may not be called when an operation is in progress

Created on 28 Mar 2018  路  22Comments  路  Source: firebase/firebase-ios-sdk

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

  • For issues or feature requests related to __the code in this repository__
    file a Github issue.

    • If this is a __feature request__ make sure the issue title starts with "FR:".

  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general Firebase discussion, use the firebase-talk
    google group.
  • For help troubleshooting your application that does not fall under one
    of the above categories, reach out to the personalized
    Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 9.2
  • Firebase SDK version: 4.11.0
  • Firebase Component: Firestore (Auth, Core, Database, Firestore, Messaging, Storage, etc)
  • Component version: 0.10.4

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

What happened? How can we make the problem occur?

*** Assertion failure in -[FSTDispatchQueue enterCheckedOperation:], third_party/firebase/ios/Source/Firestore/Source/Util/FSTDispatchQueue.mm:192
2018-03-28 10:03:30.389690+0700 BusinessEngine[16302:12429566] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'FIRESTORE INTERNAL ASSERTION FAILED: enterCheckedOperation may not be called when an operation is in progress'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010e5f612b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010d0daf41 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010e5fb2f2 +[NSException raise:format:arguments:] + 98
    3   Foundation                          0x000000010cb7bd69 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
    4   BusinessEngine                      0x0000000103b83460 -[FSTDispatchQueue enterCheckedOperation:] + 270
    5   libdispatch.dylib                   0x000000010f4c32f7 _dispatch_call_block_and_release + 12
    6   libdispatch.dylib                   0x000000010f4c433d _dispatch_client_callout + 8
    7   libdispatch.dylib                   0x000000010f4ca754 _dispatch_continuation_pop + 967
    8   libdispatch.dylib                   0x000000010f4c8b85 _dispatch_async_redirect_invoke + 780
    9   libdispatch.dylib                   0x000000010f4d0102 _dispatch_root_queue_drain + 772
    10  libdispatch.dylib                   0x000000010f4cfda0 _dispatch_worker_thread3 + 132
    11  libsystem_pthread.dylib             0x000000010f98f1ca _pthread_wqthread + 1387
    12  libsystem_pthread.dylib             0x000000010f98ec4d start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Relevant Code:

firestore bug

Most helpful comment

I'll create a minimal example project if it would help (?) or maybe I could provide my project which is affected by this.

All 22 comments

Can you tell us some more about how and when this happens? This stack trace doesn't really tell us anything because the assertion being made here should hold with a stack that's in this configuration. More context will help us understand.

Hi @wilhuff,
Full stack (pic 01)
image
Pic 02
image
Pic 04:
image
Thanks Gil.

Reverted back to 'Firebase/Firestore', '4.10.1', no issues. The issue only occurs with Firebase/Firestore 4.11.0.

Hi, I've been trying to reproduce this issue and haven't had any luck. The stack shows the standard flow to set up a connection wherein Firestore requests the token for the currently signed in user and then passes it on to gRPC to start up the connection. I'm able to sign in with a variety of accounts and Firestore is able to read data as expected.

Could you please give some more details:

  • What are you doing that triggers this issue?
  • Is there a sequence of steps required?
  • Does it happen every time?

Hi, I've got the same problem.

My setup looks the same as @businessengine. But I am setting custom dispatch queue for Firebase callbacks using this code in my AppDelegate

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    FirebaseApp.configure()

    let bgQueue = DispatchQueue.global(qos: .background)

    let settings = FirestoreSettings()
    settings.dispatchQueue = bgQueue
    Firestore.firestore().settings = settings

    Storage.storage().callbackQueue = bgQueue

    window = UIWindow(frame: UIScreen.main.bounds)
    window?.makeKeyAndVisible()
    appFlow.start()

    return true
}

With this setup my app crashes on _FIRESTORE INTERNAL ASSERTION FAILED: enterCheckedOperation may not be called when an operation is in progress_ assert as mentioned in this issue.

If I stick to the main thread it works fine.

Is there any more information I can provide? Or is there anything I'm doing wrong?

@mikelehen could this be caused by the new enterCheckedOperation changes if an FSTDispatchQueue is created with a concurrent queue like in the above example?

I'll create a minimal example project if it would help (?) or maybe I could provide my project which is affected by this.

@morganchen12 Almost certainly, but we're not sure how.

@olejnjak We looked into this before but weren't able to reproduce it or come up with a likely cause, so a minimal example would be extremely helpful. Thanks!

Here it is. It is not exactly minimal example as I am now busy. Just packed my project which contains almost nothing so it can be considered minimal.

CarManager.zip

I was trying with the latest release (4.12) but I am unable to install it using Carthage...

*** Downloading FirebaseStorageBinary.framework binary at "4.12.0"
A shell task (/usr/bin/env unzip -uo -qq -d /var/folders/83/2fpf32vn49n1pc6y8bbyv8c80000gn/T/carthage-archive.aNDxjo /Users/olejnjak/Library/Caches/org.carthage.CarthageKit/binaries/FirebaseFirestoreBinary/4.12.0/Firestore-87a804ab561d91db.zip) failed with exit code 9:
[/Users/olejnjak/Library/Caches/org.carthage.CarthageKit/binaries/FirebaseFirestoreBinary/4.12.0/Firestore-87a804ab561d91db.zip]
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of /Users/olejnjak/Library/Caches/org.carthage.CarthageKit/binaries/FirebaseFirestoreBinary/4.12.0/Firestore-87a804ab561d91db.zip or
        /Users/olejnjak/Library/Caches/org.carthage.CarthageKit/binaries/FirebaseFirestoreBinary/4.12.0/Firestore-87a804ab561d91db.zip.zip, and cannot find /Users/olejnjak/Library/Caches/org.carthage.CarthageKit/binaries/FirebaseFirestoreBinary/4.12.0/Firestore-87a804ab561d91db.zip.ZIP, period.

Deleting ~/Library/Caches/org.carthage.CarthageKit did not help

@olejnjak That really looks like a stale cache error. Are you able to download https://dl.google.com/dl/firebase/ios/carthage/4.12.0/Firestore-87a804ab561d91db.zip from a browser?

Yep, tried that that worked, cleared cache once again

But the problem persists

I'm not sure why the cache isn't updating. One workaround might be manually updating the zero lengthed ./FirebaseFirestoreBinary/4.12.0/Firestore-87a804ab561d91db.zip in the Cache with the one downloaded from a web url.

By the problem I mean the "FIRESTORE INTERNAL ASSERTION FAILED: enterCheckedOperation may not be called when an operation is in progress" exception :-)

@olejnjak Just wanted to let you know that I could reproduce the issue using the project you uploaded. I fixed a race condition which could be connected to the error, but haven't verified yet that it resolves the error you're seeing. I'll continue working on this issue and will follow up here.

Cool, so do we agree that it's an error inside Firestore and not the client code?

Based on our current line of investigation, yes that seems to be the case, but we haven't yet confirmed one way or the other.

@olejnjak To give a progress update, we've been able to identify the issue. It's triggered by configuring FirestoreSettings to use a concurrent queue, so for a quick workaround, you could change that to use a serial queue (which is the default). I'll continue working on fixing this and will post an update when I have it.

Nice, thanks :-)

Cool, we will use the default queue in the meantime.

Should be fixed as of release 5.1.0.

Was this page helpful?
0 / 5 - 0 ratings