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

FIRESTORE INTERNAL ASSERTION FAILED: value.has_value() Fatal crash on App Start #9985

Closed
MauScheff opened this issue Jul 6, 2022 · 16 comments

Comments

@MauScheff
Copy link

Describe your environment

  • Xcode version: 13.4.1
  • Firebase SDK version: 9.2.0
  • Installation method: CocoaPods (via Flutter)
  • Firebase Component: Firestore
  • Target platform(s): iOS

Describe the problem

When the App gets into a certain state, it crashes on Start every time, even after App reinstall.

Steps to reproduce:

This is the error that Crashlytics reports.

Fatal Exception: NSInternalInconsistencyException
FIRESTORE INTERNAL ASSERTION FAILED: value.has_value()

Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x99d78 __exceptionPreprocess
1  libobjc.A.dylib                0x16734 objc_exception_throw
2  Foundation                     0x131358 -[NSMutableDictionary(NSMutableDictionary) initWithContentsOfFile:]
3  FirebaseFirestore              0x46828 (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b)
4  FirebaseFirestore              0x462d4 (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b)
5  FirebaseFirestore              0x956a0 (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b)
6  FirebaseFirestore              0x95730 (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b)
7  FirebaseFirestore              0xface0 (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b)
8  FirebaseFirestore              0xd36ac (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b)
9  FirebaseFirestore              0xd3e2c (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b)
10 FirebaseFirestore              0xde96c (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b)
11 FirebaseFirestore              0xc3e78 (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b)
12 FirebaseFirestore              0xd9e04 (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b)
13 FirebaseFirestore              0x137ea8 (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b)
14 FirebaseFirestore              0x120144 (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b)
15 FirebaseFirestore              0x15e958 (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b)
16 FirebaseFirestore              0x12f694 (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b)
17 FirebaseFirestore              0x88084 (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b)
18 FirebaseFirestore              0x587c (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b)
19 FirebaseFirestore              0x1422c8 (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b)
20 libdispatch.dylib              0x3a2c _dispatch_client_callout
21 libdispatch.dylib              0xb124 _dispatch_lane_serial_drain
22 libdispatch.dylib              0xbc80 _dispatch_lane_invoke
23 libdispatch.dylib              0x16500 _dispatch_workloop_worker_thread
24 libsystem_pthread.dylib        0x10bc _pthread_wqthread
25 libsystem_pthread.dylib        0xe5c start_wqthread
---
Crashed: com.google.firebase.crashlytics.ios.exception
SIGABRT ABORT 0x0000000208898b78

Crashed: com.google.firebase.crashlytics.ios.exception
0  FirebaseCrashlytics            0x222ec FIRCLSProcessRecordAllThreads + 184
1  FirebaseCrashlytics            0x226cc FIRCLSProcessRecordAllThreads + 1176
2  FirebaseCrashlytics            0x1869c FIRCLSHandler + 48
3  FirebaseCrashlytics            0x128c4 __FIRCLSExceptionRecord_block_invoke + 92
4  libdispatch.dylib              0x3a2c _dispatch_client_callout + 20
5  libdispatch.dylib              0x12c90 _dispatch_lane_barrier_sync_invoke_and_complete + 56
6  FirebaseCrashlytics            0x116a4 FIRCLSExceptionRecord + 204
7  FirebaseCrashlytics            0x1236c FIRCLSExceptionRecordNSException + 556
8  FirebaseCrashlytics            0x112a4 FIRCLSTerminateHandler() + 404
9  libc++abi.dylib                0x10f18 std::__terminate(void (*)()) + 20
10 libc++abi.dylib                0x10eb4 std::terminate() + 64
11 libobjc.A.dylib                0x2d268 objc::DenseMapBase<objc::DenseMap<objc_class*, PendingInitialize*, objc::DenseMapValueInfo<PendingInitialize*>, objc::DenseMapInfo<objc_class*>, objc::detail::DenseMapPair<objc_class*, PendingInitialize*> >, objc_class*, PendingInitialize*, objc::DenseMapValueInfo<PendingInitialize*>, objc::DenseMapInfo<objc_class*>, objc::detail::DenseMapPair<objc_class*, PendingInitialize*> >::FatalCorruptHashTables(objc::detail::DenseMapPair<objc_class*, PendingInitialize*> const*, unsigned int) const + 14
12 libdispatch.dylib              0x3a40 _dispatch_client_callout + 40
13 libdispatch.dylib              0xb124 _dispatch_lane_serial_drain + 668
14 libdispatch.dylib              0xbc80 _dispatch_lane_invoke + 392
15 libdispatch.dylib              0x16500 _dispatch_workloop_worker_thread + 648
16 libsystem_pthread.dylib        0x10bc _pthread_wqthread + 288
17 libsystem_pthread.dylib        0xe5c start_wqthread + 8
---

com.apple.main-thread
0  libsystem_kernel.dylib         0x14e0 mach_msg_trap + 8
1  libsystem_kernel.dylib         0x1b24 mach_msg + 76
2  CoreFoundation                 0x7820 __CFRunLoopServiceMachPort + 372
3  CoreFoundation                 0xbcac __CFRunLoopRun + 1180
4  CoreFoundation                 0x1f6b8 CFRunLoopRunSpecific + 600
5  GraphicsServices               0x1374 GSEventRunModal + 164
6  UIKitCore                      0x513e88 -[UIApplication _run] + 1100
7  UIKitCore                      0x2955ec UIApplicationMain + 364
8  Runner                         0x89e8 main + 9 (AppDelegate.swift:9)
9  ???                            0x100ff1ce4 (Missing)
---

com.google.firebase.firestore.rpc
0  libsystem_kernel.dylib         0x4be4 poll + 8
1  grpc                           0x84578 pollset_work(grpc_pollset*, grpc_pollset_worker**, long long) + 1184
2  grpc                           0x863f0 pollset_work(grpc_pollset*, grpc_pollset_worker**, long long) + 72
3  grpc                           0x69780 cq_next(grpc_completion_queue*, gpr_timespec, void*) + 320
4  grpcpp                         0x1a33c grpc::CompletionQueue::AsyncNextInternal(void**, bool*, gpr_timespec) + 60
5  FirebaseFirestore              0x2a444 firebase::firestore::remote::Datastore::PollGrpcQueue() + 104
6  FirebaseFirestore              0x1422c8 firebase::firestore::util::Task::ExecuteAndRelease() + 184
7  libdispatch.dylib              0x3a2c _dispatch_client_callout + 20
8  libdispatch.dylib              0xb124 _dispatch_lane_serial_drain + 668
9  libdispatch.dylib              0xbc80 _dispatch_lane_invoke + 392
10 libdispatch.dylib              0x16500 _dispatch_workloop_worker_thread + 648
11 libsystem_pthread.dylib        0x10bc _pthread_wqthread + 288
12 libsystem_pthread.dylib        0xe5c start_wqthread + 8

---
(+ 30 more)

Debug Console Log:

*** Assertion failure in static absl::optional<Mutation> firebase::firestore::model::Mutation::CalculateOverlayMutation(const firebase::firestore::model::MutableDocument &, const absl::optional<FieldMask> &)(), /Users/mau/Development/goalbook/ios/Pods/FirebaseFirestore/Firestore/core/src/model/mutation.cc:202
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'FIRESTORE INTERNAL ASSERTION FAILED: value.has_value()'
*** First throw call stack:
(0x1d0f29d78 0x1e9b8e734 0x1d27af358 0x1033e8500 0x1033e7a08 0x10352f798 0x10352f848 0x103700388 0x1036183c0 0x103618a64 0x10365bf38 0x10365bdf4 0x10365bd9c 0x10365bd54 0x10365bd2c 0x10365a8c0 0x1032ed77c 0x1032ea87c 0x1035d34d0 0x10363ebc4 0x10363eb04 0x1037e4b9c 0x10379356c 0x1038928dc 0x1037cddb8 0x103513d48 0x10351c42c 0x10351c3d4 0x10351c384 0x10351c330 0x10351ae98 0x103523d08 0x103523b84 0x103523a7c 0x1035239f4 0x103523994 0x10352392c 0x103522454 0x1034f0570 0x1034f04d8 0x1034f0458 0x1034f03f0 0x1034f03a8 0x1034f0380 0x1034eeee0 0x1032ed77c 0x1032ea87c 0x1032ea83c 0x1032eff38 0x1032efef8 0x1032efeb0 0x1032efe88 0x1032ee9dc 0x1032ed77c 0x1032ea87c 0x10382e290 0x1033e91ec 0x1d0b90a2c 0x1d0b98124 0x1d0b98c80 0x1d0ba3500 0x241eae0bc 0x241eade5c)
libc++abi: terminating with uncaught exception of type NSException
* thread #2, queue = 'com.google.firebase.firestore', stop reason = signal SIGABRT
    frame #0: 0x0000000208898b78 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
->  0x208898b78 <+8>:  b.lo   0x208898b98               ; <+40>
    0x208898b7c <+12>: pacibsp
    0x208898b80 <+16>: stp    x29, x30, [sp, #-0x10]!
    0x208898b84 <+20>: mov    x29, sp
Target 0: (Runner) stopped.
Lost connection to device.
Exited
@MauScheff
Copy link
Author

MauScheff commented Jul 6, 2022

Note: It seems as if there are operations pending that Firebase executes internally every time it opens (because I see the writes being done remotely), the error log also registered 100 errors from 1 person (me) in a short amount of this. I believe this can be related to a write operation that was repeatedly called inside a timer (this corrupting the internal state).

@dconeybe
Copy link
Contributor

dconeybe commented Jul 6, 2022

Drive-by comment: It would be very helpful if you could symbolicate the stack trace. All of the (Missing UUID b1c971767c493d6baaca5c69dfe3fc5b) entries in the stack trace make it nearly impossible to diagnose.

That being said, the assertion message is luckily a bit helpful. The assertion check for value.has_value() is failing in Mutation::CalculateOverlayMutation():

HARD_ASSERT(value.has_value());

Tagging @wu-hui who may have some insights.

@wu-hui
Copy link
Contributor

wu-hui commented Jul 7, 2022

@MauScheff

Thanks for the report.

This is likely a bug from a recent change. It looks like your app does not patch mutations on documents, there is a new change to try to squash those mutations, and somehow it ended up in a situation our code think is impossible to happen.

Are you able to reproduce this locally? If not, can you try to examine your App's patch mutation usage, and see if you can create a local reproduction?

@Theunodb
Copy link

Theunodb commented Jul 9, 2022

Also experiencing this. It happened with i updated a document. The documented updated fine on firebase.

When i run the app through xcode i get this, hopefully it mean more to you:

2022-07-09 04:49:44.532523+0200 Runner[17244:1477755] *** Assertion failure in static absl::optional<Mutation> firebase::firestore::model::Mutation::CalculateOverlayMutation(const firebase::firestore::model::MutableDocument &, const absl::optional<FieldMask> &)(), /.../ios/Pods/FirebaseFirestore/Firestore/core/src/model/mutation.cc:202
2022-07-09 04:49:44.545093+0200 Runner[17244:1477755] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'FIRESTORE INTERNAL ASSERTION FAILED: value.has_value()'
*** First throw call stack:
(
	0   CoreFoundation                      0x00000001199d1604 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x000000011678da45 objc_exception_throw + 48
	2   Foundation                          0x00000001147a9a19 -[NSMutableDictionary(NSMutableDictionary) classForCoder] + 0
	3   FirebaseFirestore                   0x00000001135cb91a _ZN8firebase9firestore4util16ObjcThrowHandlerENS1_13ExceptionTypeEPKcS4_iRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE + 368
	4   FirebaseFirestore                   0x00000001135cb38c _ZN8firebase9firestore4util5ThrowENS1_13ExceptionTypeEPKcS4_iRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE + 10
	5   FirebaseFirestore                   0x0000000113617418 _ZN8firebase9firestore4util8internal13FailAssertionEPKcS4_iRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEES4_ + 0
	6   FirebaseFirestore                   0x00000001136174a4 _ZN8firebase9firestore4util8internal13FailAssertionEPKcS4_iRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEES4_ + 140
	7   FirebaseFirestore                   0x00000001136899e7 _ZN8firebase9firestore5model8Mutation24CalculateOverlayMutationERKNS1_15MutableDocumentERKN4absl12lts_202111028optionalINS1_9FieldMaskEEE + 1373
	8   FirebaseFirestore                   0x000000011365e1cb _ZN8firebase9firestore5local18LocalDocumentsView26RecalculateAndSaveOverlaysEONSt3__113unordered_mapINS0_5model11DocumentKeyEPNS5_15MutableDocumentENS5_15DocumentKeyHashENS3_8equal_toIS6_EENS3_9allocatorINS3_4pairIKS6_S8_EEEEEE + 1291
	9   FirebaseFirestore                   0x000000011365e9ed _ZN8firebase9firestore5local18LocalDocumentsView26RecalculateAndSaveOverlaysERKNS0_9immutable9SortedSetINS0_5model11DocumentKeyENS0_4util10ComparatorIS6_EEEE + 271
	10  FirebaseFirestore                   0x000000011366be5b _ZNSt3__110__function6__funcIZN8firebase9firestore5local11Persistence3RunIZNS4_10LocalStore16AcknowledgeBatchERKNS3_5model19MutationBatchResultEE3$_4EENS_9enable_ifIXntsr3std7is_sameIvDTclfp0_EEEE5valueESE_E4typeEN4absl12lts_2021110211string_viewET_EUlvE_NS_9allocatorISL_EEFvvEEclEv + 327
	11  FirebaseFirestore                   0x000000011364d362 _ZN8firebase9firestore5local18LevelDbPersistence11RunInternalEN4absl12lts_2021110211string_viewENSt3__18functionIFvvEEE + 148
	12  FirebaseFirestore                   0x0000000113666867 _ZN8firebase9firestore5local10LocalStore16AcknowledgeBatchERKNS0_5model19MutationBatchResultE + 129
	13  FirebaseFirestore                   0x00000001136caa1a _ZN8firebase9firestore4core10SyncEngine21HandleSuccessfulWriteENS0_5model19MutationBatchResultE + 120
	14  FirebaseFirestore                   0x00000001136b25af _ZN8firebase9firestore6remote11RemoteStore27OnWriteStreamMutationResultENS0_5model15SnapshotVersionENSt3__16vectorINS3_14MutationResultENS5_9allocatorIS7_EEEE + 817
	15  FirebaseFirestore                   0x00000001136f4794 _ZN8firebase9firestore6remote11WriteStream20NotifyStreamResponseERKN4grpc10ByteBufferE + 496
	16  FirebaseFirestore                   0x00000001136c1b29 _ZN8firebase9firestore6remote6Stream12OnStreamReadERKN4grpc10ByteBufferE + 229
	17  FirebaseFirestore                   0x000000011360a379 _ZNSt3__110__function6__funcIZN8firebase9firestore6remote14GrpcCompletion8CompleteEbE3$_0NS_9allocatorIS6_EEFvvEEclEv + 43
	18  FirebaseFirestore                   0x0000000113599759 _ZN8firebase9firestore4util10AsyncQueue15ExecuteBlockingERKNSt3__18functionIFvvEEE + 49
	19  FirebaseFirestore                   0x00000001136d63a5 _ZN8firebase9firestore4util4Task17ExecuteAndReleaseEv + 181
	20  libdispatch.dylib                   0x00000001186a9a5b _dispatch_client_callout + 8
	21  libdispatch.dylib                   0x00000001186b03bd _dispatch_lane_serial_drain + 855
	22  libdispatch.dylib                   0x00000001186b10ed _dispatch_lane_invoke + 436
	23  libdispatch.dylib                   0x00000001186bd601 _dispatch_workloop_worker_thread + 907
	24  libsystem_pthread.dylib             0x00007fff701c7fd0 _pthread_wqthread + 326
	25  libsystem_pthread.dylib             0x00007fff701c6f57 start_wqthread + 15
)
libc++abi: terminating with uncaught exception of type NSException
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/theunodebruin/Library/Developer/Xcode/DerivedData/Runner-giesssbwzizocedrulocbayyrnqc/Build/Products/Debug-production-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMTLCapture.dylib DYLD_FRAMEWORK_PATH=/Users/theunodebruin/Library/Developer/Xcode/DerivedData/Runner-giesssbwzizocedrulocbayyrnqc/Build/Products/Debug-production-iphonesimulator
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'FIRESTORE INTERNAL ASSERTION FAILED: value.has_value()'
terminating with uncaught exception of type NSException
CoreSimulator 802.6.1 - Device: iPhone 13 Pro Max (1D32C134-5ED7-4358-9D46-FD06E6E6DC7F) - Runtime: iOS 15.5 (19F70) - DeviceType: iPhone 13 Pro Max
(lldb) 

@wu-hui
Copy link
Contributor

wu-hui commented Jul 9, 2022

Hi @Theunodb

It seems like you were able to reproduce this locally (your log seems to be from a simulator). Is it possible to share a minimum version of it, that is still able to reproduce this?

@akospwc
Copy link

akospwc commented Jul 13, 2022

I also started receiving reports about this after updating to the cloud_firestore 3.3.0 flutter package, which now contains Firebase iOS SDK to 9.2.0.

Unfortunately, I am unable to reproduce this myself. Crash report from Xcode:

Incident Identifier: 39DC7C4B-663F-4F16-A764-2029217834F0
Hardware Model:      iPhone12,8
Process:             Runner [409]
Path:                /private/var/containers/Bundle/Application/79AF13D4-5E10-4809-BD93-0890F3F87007/Runner.app/Runner
Identifier:          ***
Version:             ***
AppStoreTools:       13F100
AppVariant:          1:iPhone12,8:15
Beta:                YES
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           ***

Date/Time:           2022-07-13 09:41:12.7962 -0700
Launch Time:         2022-07-13 09:41:11.5561 -0700
OS Version:          iPhone OS 15.4 (19E241)
Release Type:        User
Baseband Version:    3.02.01
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  18

Last Exception Backtrace:
0   CoreFoundation                	0x1e2850d78 __exceptionPreprocess + 220 (NSException.m:200)
1   libobjc.A.dylib               	0x1fb4b5734 objc_exception_throw + 60 (objc-exception.mm:565)
2   Foundation                    	0x1e40d6358 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 188 (NSException.m:251)
3   FirebaseFirestore             	0x1034cacd8 firebase::firestore::util::ObjcThrowHandler(firebase::firestore::util::ExceptionType, char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<ch... + 328 (exception_apple.mm:59)
4   FirebaseFirestore             	0x1034ca784 firebase::firestore::util::Throw(firebase::firestore::util::ExceptionType, char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 20 (exception.cc:93)
5   FirebaseFirestore             	0x103519b50 firebase::firestore::util::internal::FailAssertion(char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 32 (hard_assert.cc:35)
6   FirebaseFirestore             	0x103519be0 firebase::firestore::util::internal::FailAssertion(char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const*) + 144 (hard_assert.cc:49)
7   FirebaseFirestore             	0x10357f190 firebase::firestore::model::Mutation::CalculateOverlayMutation(firebase::firestore::model::MutableDocument const&, absl::lts_20211102::optional<firebase::firestore::model::FieldMask> const&) + 1144 (mutation.cc:202)
8   FirebaseFirestore             	0x103557b5c firebase::firestore::local::LocalDocumentsView::RecalculateAndSaveOverlays(std::__1::unordered_map<firebase::firestore::model::DocumentKey, firebase::firestore::model::MutableDocument*, firebase::f... + 1148 (local_documents_view.cc:310)
9   FirebaseFirestore             	0x1035582dc firebase::firestore::local::LocalDocumentsView::RecalculateAndSaveOverlays(firebase::firestore::immutable::SortedSet<firebase::firestore::model::DocumentKey, firebase::firestore::util::Comparator<f... + 268 (local_documents_view.cc:257)
10  FirebaseFirestore             	0x103562e1c firebase::firestore::local::LocalStore::AcknowledgeBatch(firebase::firestore::model::MutationBatchResult const&)::$_4::operator()() const + 256 (local_store.cc:251)
11  FirebaseFirestore             	0x103562e1c std::__1::enable_if<!(std::is_same<void, decltype(fp0())>::value), decltype(fp0())>::type firebase::firestore::local::Persistence::Run<firebase::firestore::local::LocalStore::AcknowledgeBatch(fireb... + 264 (persistence.h:188)
12  FirebaseFirestore             	0x103562e1c decltype(static_cast<firebase::firestore::local::LocalStore::AcknowledgeBatch(firebase::firestore::model::MutationBatchResult const&)::$_4>(fp)()) std::__1::__invoke<std::__1::enable_if<!(std::is_s... + 264 (type_traits:3918)
13  FirebaseFirestore             	0x103562e1c void std::__1::__invoke_void_return_wrapper<void, true>::__call<std::__1::enable_if<!(std::is_same<void, decltype(fp0())>::value), decltype(fp0())>::type firebase::firestore::local::Persistence::Ru... + 264 (invoke.h:61)
14  FirebaseFirestore             	0x103562e1c std::__1::__function::__alloc_func<std::__1::enable_if<!(std::is_same<void, decltype(fp0())>::value), decltype(fp0())>::type firebase::firestore::local::Persistence::Run<firebase::firestore::local:... + 264 (function.h:178)
15  FirebaseFirestore             	0x103562e1c std::__1::__function::__func<std::__1::enable_if<!(std::is_same<void, decltype(fp0())>::value), decltype(fp0())>::type firebase::firestore::local::Persistence::Run<firebase::firestore::local::Local... + 316 (function.h:352)
16  FirebaseFirestore             	0x103548328 std::__1::__function::__value_func<void ()>::operator()() const + 20 (function.h:505)
17  FirebaseFirestore             	0x103548328 std::__1::function<void ()>::operator()() const + 20 (function.h:1182)
18  FirebaseFirestore             	0x103548328 firebase::firestore::local::LevelDbPersistence::RunInternal(absl::lts_20211102::string_view, std::__1::function<void ()>) + 136 (leveldb_persistence.cc:318)
19  FirebaseFirestore             	0x10355e2b4 std::__1::enable_if<!(std::is_same<void, decltype(fp0())>::value), decltype(fp0())>::type firebase::firestore::local::Persistence::Run<firebase::firestore::local::LocalStore::AcknowledgeBatch(fireb... + 72 (persistence.h:188)
20  FirebaseFirestore             	0x10355e2b4 firebase::firestore::local::LocalStore::AcknowledgeBatch(firebase::firestore::model::MutationBatchResult const&) + 124 (local_store.cc:243)
21  FirebaseFirestore             	0x1035bc358 firebase::firestore::core::SyncEngine::HandleSuccessfulWrite(firebase::firestore::model::MutationBatchResult) + 120 (sync_engine.cc:362)
22  FirebaseFirestore             	0x1035a45f4 firebase::firestore::remote::RemoteStore::OnWriteStreamMutationResult(firebase::firestore::model::SnapshotVersion, std::__1::vector<firebase::firestore::model::MutationResult, std::__1::allocator<f... + 688 (remote_store.cc:445)
23  FirebaseFirestore             	0x1035e2e08 firebase::firestore::remote::WriteStream::NotifyStreamResponse(grpc::ByteBuffer const&) + 460 (write_stream.cc:159)
24  FirebaseFirestore             	0x1035b3b44 firebase::firestore::remote::Stream::OnStreamRead(grpc::ByteBuffer const&) + 240 (stream.cc:261)
25  FirebaseFirestore             	0x10350c534 std::__1::__function::__value_func<void (bool, std::__1::shared_ptr<firebase::firestore::remote::GrpcCompletion> const&)>::operator()(bool&&, std::__1::shared_ptr<firebase::firestore::remote::GrpcC... + 16 (function.h:505)
26  FirebaseFirestore             	0x10350c534 std::__1::function<void (bool, std::__1::shared_ptr<firebase::firestore::remote::GrpcCompletion> const&)>::operator()(bool, std::__1::shared_ptr<firebase::firestore::remote::GrpcCompletion> const&)... + 16 (function.h:1182)
27  FirebaseFirestore             	0x10350c534 firebase::firestore::remote::GrpcCompletion::Complete(bool)::$_0::operator()() const + 40 (grpc_completion.cc:95)
28  FirebaseFirestore             	0x10350c534 decltype(static_cast<firebase::firestore::remote::GrpcCompletion::Complete(bool)::$_0&>(fp)()) std::__1::__invoke<firebase::firestore::remote::GrpcCompletion::Complete(bool)::$_0&>(firebase::firest... + 40 (type_traits:3918)
29  FirebaseFirestore             	0x10350c534 void std::__1::__invoke_void_return_wrapper<void, true>::__call<firebase::firestore::remote::GrpcCompletion::Complete(bool)::$_0&>(firebase::firestore::remote::GrpcCompletion::Complete(bool)::$_0&) + 40 (invoke.h:61)
30  FirebaseFirestore             	0x10350c534 std::__1::__function::__alloc_func<firebase::firestore::remote::GrpcCompletion::Complete(bool)::$_0, std::__1::allocator<firebase::firestore::remote::GrpcCompletion::Complete(bool)::$_0>, void ()>:... + 40 (function.h:178)
31  FirebaseFirestore             	0x10350c534 std::__1::__function::__func<firebase::firestore::remote::GrpcCompletion::Complete(bool)::$_0, std::__1::allocator<firebase::firestore::remote::GrpcCompletion::Complete(bool)::$_0>, void ()>::opera... + 56 (function.h:352)
32  FirebaseFirestore             	0x103489d2c std::__1::__function::__value_func<void ()>::operator()() const + 20 (function.h:505)
33  FirebaseFirestore             	0x103489d2c std::__1::function<void ()>::operator()() const + 20 (function.h:1182)
34  FirebaseFirestore             	0x103489d2c firebase::firestore::util::AsyncQueue::ExecuteBlocking(std::__1::function<void ()> const&) + 68 (async_queue.cc:89)
35  FirebaseFirestore             	0x1035c6778 std::__1::__function::__value_func<void ()>::operator()() const + 20 (function.h:505)
36  FirebaseFirestore             	0x1035c6778 std::__1::function<void ()>::operator()() const + 20 (function.h:1182)
37  FirebaseFirestore             	0x1035c6778 firebase::firestore::util::Task::ExecuteAndRelease() + 184 (task.cc:102)
38  libdispatch.dylib             	0x1e24b7a2c _dispatch_client_callout + 20 (object.m:560)
39  libdispatch.dylib             	0x1e24bf124 _dispatch_lane_serial_drain + 668 (inline_internal.h:2622)
40  libdispatch.dylib             	0x1e24bfc80 _dispatch_lane_invoke + 392 (queue.c:3944)
41  libdispatch.dylib             	0x1e24ca500 _dispatch_workloop_worker_thread + 648 (queue.c:6732)
42  libsystem_pthread.dylib       	0x25385a0bc _pthread_wqthread + 288 (pthread.c:2599)
43  libsystem_pthread.dylib       	0x253859e5c start_wqthread + 8 (:-1)

@Theunodb
Copy link

Theunodb commented Jul 13, 2022

Hi @Theunodb

It seems like you were able to reproduce this locally (your log seems to be from a simulator). Is it possible to share a minimum version of it, that is still able to reproduce this?

I don’t have a minimum version. But from what I can see is that i can read any document fine, and SET most of the documents fine. Only some SET puts the app in the broken state.

I have to revert to a previous version on TestFlight on a real device, or clear the simulator completely to get the app running again. Otherwise it just crashes on startup.

I can’t confirm 100% but it looks like whenever i set a document with merge = true, and i omit fields that had values in a previous SET, it crashes.

Ex

  1. doc(x).set({b:1,c:2,d:3}, SetOption(merge:true)) works fine, i can do this multiple times

Then in the same session i update the doc again, but this time like this:

  1. doc(x).set({b:5}, SetOption(merge:true)) goes through to firebase but causes the app to crash, and puts it in the crash state until i reset or downgrade.

I can’t reproduce this on android, its still happening on ios after today’s package updates

@wu-hui
Copy link
Contributor

wu-hui commented Jul 14, 2022

Thanks @Theunodb

I have tried what you suggested, and I still cannot reproduce it unfortunately.

It seems like you are pretty close to a reproduction, do you mind helping us to try to isolate and reproduce this? We would appreciate your effort greatly!

In the meanwhile, I'll keep trying to reproduce from my end.

@dconeybe
Copy link
Contributor

As another data point, note that another customer has reported this crash: #9874 (comment). However, they only saw the crash once and haven't seen it since.

@igorvoytovich
Copy link

igorvoytovich commented Jul 14, 2022

In my case, this happened after I moved the app to a background (Home button/Swipe up) for a short time, ~10 seconds maybe, and then opened it and immediately caught this crash. After restarting the application, everything was normal, that is, the app does not crash endlessly on start.

@jonjon1123
Copy link

I am also seeing a large number of my users reporting this issue. Only on iOS and with no pattern. I have tried so many things and cannot for the life of me reproduce it locally. The only work around I have found is to have them completely uninstall & reinstall my app. It then seems to go away for a while but eventually comes back.

@wu-hui
Copy link
Contributor

wu-hui commented Jul 15, 2022

Hey folks, I have identified a potential fix: #10016

I am fairly confident this would fix the issues (maybe except igorvoytovich's issue, which seems to be a different one).

Apologies for the troubles it caused, and thanks for all of you trying to reproduce it!

@igorvoytovich

I am not sure this will fix your problem, because it looks different. Please file a different issue if the fix does not help you.

@igorvoytovich
Copy link

Hello @wu-hui ,

Thanks for the update.

This fix will be included in 9.4.0 right? If so, could you please tell when approximately it should be released?

@jonjon1123
Copy link

@wu-hui Any word on when this fix will be released? It seems like a pretty impacting issue as there isn't much of a work around. Can it get fast tracked to get pushed out quickly somehow?

@wu-hui
Copy link
Contributor

wu-hui commented Jul 19, 2022

9.4.0 is scheduled to release around Aug 2.

The fix is in master already, so if you need it urgently, you can try to build your app from there.

@carlhung
Copy link

carlhung commented Aug 1, 2022

I also got the same issue on ver 7.1.0 of Firebase SDK.
So, should I update to the latest version as well?

@firebase firebase locked and limited conversation to collaborators Aug 26, 2022
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