firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.67k stars 3.97k forks source link

🐛 [FirebaseFirestore] App crash occur when sub collection document query in iPhone13 simulator #7451

Closed neatnoin closed 2 years ago

neatnoin commented 2 years ago

Bug report

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x112ba4 (누락)
1  libobjc.A.dylib                0x1fbe7 objc_exception_throw
2  CoreFoundation                 0x121821 (누락)
3  CoreFoundation                 0x1170bc (누락)
4  CoreFoundation                 0x1191e8 (누락)
5  Runner                         0xc02a3 -[FLTFirebaseFirestorePlugin queryGet:withMethodCallResult:] + 463 (FLTFirebaseFirestorePlugin.m:463)
6  Runner                         0xbd35b -[FLTFirebaseFirestorePlugin handleMethodCall:result:] + 205 (FLTFirebaseFirestorePlugin.m:205)
7  Flutter                        0x583e65 (누락)
8  Flutter                        0x35d29 (누락)
9  Flutter                        0x3b011 (누락)
10 Flutter                        0x3e0817 (누락)
11 Flutter                        0x369f02 (누락)
12 Flutter                        0x36f3fc (누락)
13 CoreFoundation                 0x816c6 (누락)
14 CoreFoundation                 0x811c2 (누락)
15 CoreFoundation                 0x80781 (누락)
16 CoreFoundation                 0x7adc0 (누락)
17 CoreFoundation                 0x7a103 (누락)
18 GraphicsServices               0x3cd3 (누락)
19 UIKitCore                      0xcc7e63 (누락)
20 UIKitCore                      0xccca53 (누락)
21 Runner                         0x509f main + 6 (AppDelegate.swift:6)
22 ???                            0x106b77e1e (누락)
23 ???                            0x1124574fe (누락)

Steps to reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. '...'
  3. See error or incorrect behavior

Expected behavior

A clear and concise description of what you expected to happen.

Sample project

Providing a minimal example project which demonstrates the bug in isolation from your main App greatly enhances the chance of a timely fix. Please link to the public repository URL.


Additional context

Add any other context about the problem here.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand [✓] Flutter (Channel stable, 2.5.2, on macOS 12.0.1 21A559 darwin-x64, locale ko-KR) • Flutter version 2.5.2 at /Users/nis/Documents/Developer/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 3595343e20 (9 weeks ago), 2021-09-30 12:58:18 -0700 • Engine revision 6ac856380f • Dart version 2.14.3 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/nis/Library/Android/sdk • Platform android-30, build-tools 30.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 13.1, Build version 13A1030d • CocoaPods version 1.10.1 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 4.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) [✓] VS Code (version 1.54.1) • VS Code at /Users/nis/Downloads/Visual Studio Code.app/Contents • Flutter extension can be installed from: 🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [✓] Connected device (2 available) • iPhone 13 (mobile) • 069ECD14-A9A9-4EDF-ADAC-AE3C80F877DB • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator) • Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.55

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand get: ^4.3.8 provider: ^6.0.1 path_provider: ^2.0.5 path: ^1.8.0 font_awesome_flutter: ^9.1.0 rxdart: ^0.27.2 firebase_core: ^1.10.0 firebase_auth: ^3.2.0 cloud_firestore: ^3.1.0 cloud_functions: ^3.1.1 firebase_storage: ^10.1.0 image_picker: ^0.8.4+2 image_cropper: ^1.4.1 cached_network_image: ^3.1.0 permission_handler: ^8.2.2 app_settings: ^4.1.1 pin_code_fields: ^7.3.0 equatable: ^2.0.3 contacts_service: ^0.6.3

darshankawar commented 2 years ago

@neatnoin There's not enough details provided except the logs. Are there any more logs that you can provide ? Is there any description or entry in the log that says something like NSNULL - ? Are there any steps to replicate or reproducible code sample you can provide involving sub collection document query?

neatnoin commented 2 years ago

If it happened first, app can't build because of same crash. And I'm using query statement like this

    QuerySnapshot<Map<String, dynamic>> userQuery = await FirebaseFirestore
        .instance
        .collection(COLLECTION_USERS)
        .limit(1)
        .where(KEY_STATUS, isEqualTo: 'DONE')
        .where(KEY_GENDER,
            isEqualTo: currentUser.gender == '여자' ? '남자' : '여자')
        .orderBy(KEY_INDEX)
        .where(KEY_INDEX,
            whereNotIn:
                matchedUserListIndex.toList())
        .where(KEY_INDEX, isGreaterThanOrEqualTo: randomNumber)
        .get();

Only one document is matched with this condition There's error message in Xcode

Xcode log ``` 2021-12-06 21:14:26.134744+0900 Runner[8371:40266] Metal API Validation Enabled 2021-12-06 21:14:26.239147+0900 Runner[8371:40266] Writing analzed variants. 2021-12-06 21:14:26.355959+0900 Runner[8371:40266] [Firebase/Crashlytics] Version 8.9.0 2021-12-06 21:14:26.407856+0900 Runner[8371:40930] 8.9.0 - [Firebase/Analytics][I-ACS023007] Analytics v.8.9.0 started 2021-12-06 21:14:26.457417+0900 Runner[8371:40930] 8.9.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r) 2021-12-06 21:14:26.547782+0900 Runner[8371:40989] flutter: Observatory listening on http://127.0.0.1:50674/ZRULfqZgBcc=/ 2021-12-06 21:14:26.638721+0900 Runner[8371:40939] [boringssl] boringssl_metrics_log_metric_block_invoke(144) Failed to log metrics 2021-12-06 21:14:26.672322+0900 Runner[8371:40992] [boringssl] boringssl_metrics_log_metric_block_invoke(144) Failed to log metrics 2021-12-06 21:14:27.223071+0900 Runner[8371:40992] 8.9.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement 2021-12-06 21:14:27.276492+0900 Runner[8371:40931] 8.9.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled 2021-12-06 21:14:27.276691+0900 Runner[8371:40931] 8.9.0 - [Firebase/Analytics][I-ACS023220] Analytics screen reporting is enabled. Call +[FIRAnalytics logEventWithName:FIREventScreenView parameters:] to log a screen view event. To disable automatic screen reporting, set the flag FirebaseAutomaticScreenReportingEnabled to NO (boolean) in the Info.plist 2021-12-06 21:14:27.630876+0900 Runner[8371:40931] [boringssl] boringssl_metrics_log_metric_block_invoke(144) Failed to log metrics 2021-12-06 21:14:27.868304+0900 Runner[8371:40938] [boringssl] boringssl_metrics_log_metric_block_invoke(144) Failed to log metrics 2021-12-06 21:14:28.097535+0900 Runner[8371:40963] flutter: smiSxj4mqqSMXmpGaIJiW9Hm8MK2 2021-12-06 21:14:28.228081+0900 Runner[8371:40940] [boringssl] boringssl_metrics_log_metric_block_invoke(144) Failed to log metrics 2021-12-06 21:14:29.154758+0900 Runner[8371:40266] An error occurred while parsing query arguments, this is most likely an error with this SDK. ( 0 CoreFoundation 0x00007fff203fbbb4 __exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007fff2019ebe7 objc_exception_throw + 48 2 FirebaseFirestore 0x00000001037e5134 _ZN8firebase9firestore4util16ObjcThrowHandlerENS1_13ExceptionTypeEPKcS4_iRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE + 660 3 FirebaseFirestore 0x00000001037e44d5 _ZN8firebase9firestore4util5ThrowENS1_13ExceptionTypeEPKcS4_iRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE + 53 4 FirebaseFirestore 0x0000000103804012 _ZN8firebase9firestore4util20ThrowInvalidArgumentIJEEEvPKcDpRKT_ + 50 5 FirebaseFirestore 0x0000000103a8755c _ZNK8firebase9firestore3api5Query27ParseExpectedReferenceValueERKNS0_26_google_firestore_v1_ValueERKNSt3__18functionIFNS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEvEEE + 124 6 FirebaseFirestore 0x0000000103a90464 _ZZNK8firebase9firestore3api5Query6FilterERKNS0_5model9FieldPathENS0_4core6Filter8OperatorENS0_6nanopb13SharedMessageINS0_26_google_firestore_v1_ValueEEERKNSt3__18functionIFNSE_12basic_stringIcNSE_11char_traitsIcEENSE_9allocatorIcEEEEvEEEENK3$_0clERKSC_ + 52 7 FirebaseFirestore 0x0000000103a9034f _ZN8firebase9firestore6nanopb16SetRepeatedFieldINS0_26_google_firestore_v1_ValueEPS3_ZNKS0_3api5Query6FilterERKNS0_5model9FieldPathENS0_4core6Filter8OperatorENS1_13SharedMessageIS3_EERKNSt3__18functionIFNSG_12basic_stringIcNSG_11char_traitsIcEENSG_9allocatorIcEEEEvEEEE3$_0EEvPPT_PjT0_SX_RKT1_ + 351 8 FirebaseFirestore 0x0000000103a87466 _ZN8firebase9firestore6nanopb16SetRepeatedFieldINS0_26_google_firestore_v1_ValueEN4absl14lts_2020_02_254SpanIS3_EEZNKS0_3api5Query6FilterERKNS0_5model9FieldPathENS0_4core6Filter8OperatorENS1_13SharedMessageIS3_EERKNSt3__18functionIFNSJ_12basic_stringIcNSJ_11char_traitsIcEENSJ_9allocatorIcEEEEvEEEE3$_0EEvPPT_PjRKT0_RKT1_ + 86 9 FirebaseFirestore 0x0000000103a86e63 _ZNK8firebase9firestore3api5Query6FilterERKNS0_5model9FieldPathENS0_4core6Filter8OperatorENS0_6nanopb13SharedMessageINS0_26_google_firestore_v1_ValueEEERKNSt3__18functionIFNSE_12basic_stringIcNSE_11char_traitsIcEENSE_9allocatorIcEEEEvEEE + 563 10 FirebaseFirestore 0x00000001038afec8 -[FIRQuery queryWithFilterOperator:path:value:] + 376 11 FirebaseFirestore 0x00000001038acaa1 -[FIRQuery queryWhereFieldPath:in:] + 145 12 Runner 0x0000000100e0a460 -[FLTFirebaseFirestoreReader FIRQuery] + 2624 13 Runner 0x0000000100e0936b -[FLTFirebaseFirestoreReader readValueOfType:] + 1483 14 Flutter 0x0000000108a15057 -[FlutterStandardReader readValueOfType:] + 680 15 Runner 0x0000000100e09457 -[FLTFirebaseFirestoreReader readValueOfType:] + 1719 16 Flutter 0x0000000108a138b3 -[FlutterStandardMethodCodec decodeMethodCall:] + 76 17 Flutter 0x0000000108a11e22 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 37 18 Flutter 0x00000001084c3d29 _ZNK7flutter21PlatformMessageRouter21HandlePlatformMessageENSt3__110unique_ptrINS_15PlatformMessageENS1_14default_deleteIS3_EEEE + 193 19 Flutter 0x00000001084c9011 _ZN7flutter15PlatformViewIOS21HandlePlatformMessageENSt3__110unique_ptrINS_15PlatformMessageENS1_14default_deleteIS3_EEEE + 35 20 Flutter 0x000000010886e817 _ZNSt3__110__function6__funcIN3fml8internal14CopyableLambdaIZN7flutter5Shell29OnEngineHandlePlatformMessageENS_10unique_ptrINS5_15PlatformMessageENS_14default_deleteIS8_EEEEE4$_16EENS_9allocatorISD_EEFvvEEclEv + 81 21 Flutter 0x00000001087f7f02 _ZN3fml15MessageLoopImpl10FlushTasksENS_9FlushTypeE + 164 22 Flutter 0x00000001087fd3fc _ZN3fml17MessageLoopDarwin11OnTimerFireEP16__CFRunLoopTimerPS0_ + 26 23 CoreFoundation 0x00007fff2036a6c6 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20 24 CoreFoundation 0x00007fff2036a1c2 __CFRunLoopDoTimer + 923 25 CoreFoundation 0x00007fff20369781 __CFRunLoopDoTimers + 265 26 CoreFoundation 0x00007fff20363dc0 __CFRunLoopRun + 2010 27 CoreFoundation 0x00007fff20363103 CFRunLoopRunSpecific + 567 28 GraphicsServices 0x00007fff2c851cd3 GSEventRunModal + 139 29 UIKitCore 0x00007fff24ffbe63 -[UIApplication _run] + 928 30 UIKitCore 0x00007fff25000a53 UIApplicationMain + 101 31 Runner 0x0000000100d4ad6f main + 63 32 dyld 0x0000000101141e1e start_sim + 10 33 ??? 0x000000010d09e4fe 0x0 + 4513719550 ) 2021-12-06 21:14:29.167849+0900 Runner[8371:40266] -[NSNull getDocumentsWithSource:completion:]: unrecognized selector sent to instance 0x7fff8a349fb0 2021-12-06 21:14:29.172344+0900 Runner[8371:40266] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull getDocumentsWithSource:completion:]: unrecognized selector sent to instance 0x7fff8a349fb0' *** First throw call stack: ( 0 CoreFoundation 0x00007fff203fbbb4 __exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007fff2019ebe7 objc_exception_throw + 48 2 CoreFoundation 0x00007fff2040a821 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0 3 CoreFoundation 0x00007fff204000bc ___forwarding___ + 1433 4 CoreFoundation 0x00007fff204021e8 _CF_forwarding_prep_0 + 120 5 Runner 0x0000000100e07c23 -[FLTFirebaseFirestorePlugin queryGet:withMethodCallResult:] + 355 6 Runner 0x0000000100e04cdb -[FLTFirebaseFirestorePlugin handleMethodCall:result:] + 1835 7 Flutter 0x0000000108a11e65 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 104 8 Flutter 0x00000001084c3d29 _ZNK7flutter21PlatformMessageRouter21HandlePlatformMessageENSt3__110unique_ptrINS_15PlatformMessageENS1_14default_deleteIS3_EEEE + 193 9 Flutter 0x00000001084c9011 _ZN7flutter15PlatformViewIOS21HandlePlatformMessageENSt3__110unique_ptrINS_15PlatformMessageENS1_14default_deleteIS3_EEEE + 35 10 Flutter 0x000000010886e817 _ZNSt3__110__function6__funcIN3fml8internal14CopyableLambdaIZN7flutter5Shell29OnEngineHandlePlatformMessageENS_10unique_ptrINS5_15PlatformMessageENS_14default_deleteIS8_EEEEE4$_16EENS_9allocatorISD_EEFvvEEclEv + 81 11 Flutter 0x00000001087f7f02 _ZN3fml15MessageLoopImpl10FlushTasksENS_9FlushTypeE + 164 12 Flutter 0x00000001087fd3fc _ZN3fml17MessageLoopDarwin11OnTimerFireEP16__CFRunLoopTimerPS0_ + 26 13 CoreFoundation 0x00007fff2036a6c6 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20 14 CoreFoundation 0x00007fff2036a1c2 __CFRunLoopDoTimer + 923 15 CoreFoundation 0x00007fff20369781 __CFRunLoopDoTimers + 265 16 CoreFoundation 0x00007fff20363dc0 __CFRunLoopRun + 2010 17 CoreFoundation 0x00007fff20363103 CFRunLoopRunSpecific + 567 18 GraphicsServices 0x00007fff2c851cd3 GSEventRunModal + 139 19 UIKitCore 0x00007fff24ffbe63 -[UIApplication _run] + 928 20 UIKitCore 0x00007fff25000a53 UIApplicationMain + 101 21 Runner 0x0000000100d4ad6f main + 63 22 dyld 0x0000000101141e1e start_sim + 10 23 ??? 0x000000010d09e4fe 0x0 + 4513719550 ) 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/nis/Library/Developer/Xcode/DerivedData/Runner-aqzweiwzgufoxjchlmhanawnpytp/Build/Products/Debug-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 DYLD_FRAMEWORK_PATH=/Users/nis/Library/Developer/Xcode/DerivedData/Runner-aqzweiwzgufoxjchlmhanawnpytp/Build/Products/Debug-iphonesimulator *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull getDocumentsWithSource:completion:]: unrecognized selector sent to instance 0x7fff8a349fb0' terminating with uncaught exception of type NSException CoreSimulator 776.4 - Device: iPhone 13 (069ECD14-A9A9-4EDF-ADAC-AE3C80F877DB) - Runtime: iOS 15.0 (19A339) - DeviceType: iPhone 13 (lldb) ```
darshankawar commented 2 years ago

@neatnoin Check this issue comment and see if it helps.

neatnoin commented 2 years ago

I fixed this issue. It was an error cause by using FieldValue.arrayUnion() at not growable FieldValue List.

FirebaseFirestore.instance .collection(COLLECTIONUSERS) .doc(currentUser.userKey) .collection('MATCHING') .doc('${currentDate.year}-${currentDate.month}-${currentDate.day}') .update({ 'userKey': FieldValue.arrayUnion(matchedList), ...Map.fromIterable(matchedList, key: (v) => v, value: () => ['', '']) });

Thanks a lot.

darshankawar commented 2 years ago

Closing this as resolved.