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.63k stars 3.95k forks source link

🐛 [cloud_firestore] Crash Subscribing to Data at Startup #11528

Closed harry-dickson closed 1 year ago

harry-dickson commented 1 year ago

Bug report

Null Dereference Crash Pretty much first data access in the app. Subscribing to a query snapshot - which of course returns the query results initially. This subscription happens in response to Firebase authentication.

Breaks in FSTUserDataWriter.convertedValue()

Steps to reproduce

Start the App. Happens every time - but only with recent builds, so something changed. Actually it varies, but crashes readily at time of writing. Not necessarily at Startup. I'm having a hard time getting a handle on this.

Any debugging tips welcome, because I am floundering here

Tried rolling back to cloud_firestore 4.8.5 but still breaking.

Expected behavior

No crash.

Sample project

Hoping this is a known issue so I don't have to do this.

11216 ?

10715 ?


Additional context

I have performed a fairly deep clean on project.

I'm not competent with XCode/Objective-C at all, but these are the first few items on the Thread 1 stack, not all of which are disassembly [click to expand]:

0x0000000102ce4070 in - [FSTUserDataWriter convertedValue:] () ``` Runner`-[FSTUserDataWriter convertedValue:]: 0x102ce3f68 <+0>: sub sp, sp, #0x30 0x102ce3f6c <+4>: stp x20, x19, [sp, #0x10] 0x102ce3f70 <+8>: stp x29, x30, [sp, #0x20] 0x102ce3f74 <+12>: add x29, sp, #0x20 0x102ce3f78 <+16>: mov x19, x2 0x102ce3f7c <+20>: mov x20, x0 0x102ce3f80 <+24>: mov x0, x2 0x102ce3f84 <+28>: bl 0x102dc1b6c ; firebase::firestore::model::GetTypeOrder(firebase::firestore::_google_firestore_v1_Value const&) 0x102ce3f88 <+32>: cmp w0, #0xa 0x102ce3f8c <+36>: b.hi 0x102ce411c ; <+436> 0x102ce3f90 <+40>: mov w8, w0 0x102ce3f94 <+44>: adrp x9, 7707 0x102ce3f98 <+48>: add x9, x9, #0x5a2 ; typeinfo name for std::__1::__shared_ptr_emplace > + 187 0x102ce3f9c <+52>: adr x10, #0x10 ; <+68> 0x102ce3fa0 <+56>: ldrb w11, [x9, x8] 0x102ce3fa4 <+60>: add x10, x10, x11, lsl #2 0x102ce3fa8 <+64>: br x10 0x102ce3fac <+68>: adrp x8, 10059 0x102ce3fb0 <+72>: ldr x0, [x8, #0xef8] 0x102ce3fb4 <+76>: adrp x8, 10056 0x102ce3fb8 <+80>: ldr x1, [x8, #0x670] 0x102ce3fbc <+84>: bl 0x104ab6788 ; symbol stub for: objc_msgSend 0x102ce3fc0 <+88>: mov x29, x29 0x102ce3fc4 <+92>: b 0x102ce40e0 ; <+376> 0x102ce3fc8 <+96>: ldrb w8, [x19, #0x8] 0x102ce3fcc <+100>: adrp x9, 10059 0x102ce3fd0 <+104>: ldr x0, [x9, #0xd90] 0x102ce3fd4 <+108>: adrp x9, 10056 0x102ce3fd8 <+112>: ldr x1, [x9, #0x6a8] 0x102ce3fdc <+116>: cbz w8, 0x102ce410c ; <+420> 0x102ce3fe0 <+120>: mov w2, #0x1 0x102ce3fe4 <+124>: b 0x102ce4110 ; <+424> 0x102ce3fe8 <+128>: ldr w8, [x19] 0x102ce3fec <+132>: adrp x9, 10059 0x102ce3ff0 <+136>: ldr x0, [x9, #0xd90] 0x102ce3ff4 <+140>: cmp w8, #0x2 0x102ce3ff8 <+144>: b.ne 0x102ce40f4 ; <+396> 0x102ce3ffc <+148>: ldr x2, [x19, #0x8] 0x102ce4000 <+152>: adrp x8, 10055 0x102ce4004 <+156>: ldr x1, [x8, #0x6d8] 0x102ce4008 <+160>: b 0x102ce40d8 ; <+368> 0x102ce400c <+164>: add x2, x19, #0x8 0x102ce4010 <+168>: adrp x8, 10052 0x102ce4014 <+172>: ldr x1, [x8, #0xc88] 0x102ce4018 <+176>: b 0x102ce40d4 ; <+364> 0x102ce401c <+180>: adrp x8, 10052 0x102ce4020 <+184>: ldr x1, [x8, #0xc80] 0x102ce4024 <+188>: b 0x102ce4090 ; <+296> 0x102ce4028 <+192>: ldr x0, [x19, #0x8] 0x102ce402c <+196>: bl 0x102d61d34 ; firebase::firestore::nanopb::MakeStringView(pb_bytes_array_s const*) 0x102ce4030 <+200>: mov x19, x0 0x102ce4034 <+204>: mov x20, x1 0x102ce4038 <+208>: adrp x8, 10058 0x102ce403c <+212>: ldr x0, [x8, #0xe20] 0x102ce4040 <+216>: bl 0x104ab6668 ; symbol stub for: objc_alloc 0x102ce4044 <+220>: adrp x8, 10054 0x102ce4048 <+224>: ldr x1, [x8, #0x1c0] 0x102ce404c <+228>: mov x2, x19 0x102ce4050 <+232>: mov x3, x20 0x102ce4054 <+236>: mov w4, #0x4 0x102ce4058 <+240>: bl 0x104ab6788 ; symbol stub for: objc_msgSend 0x102ce405c <+244>: b 0x102ce40e4 ; <+380> 0x102ce4060 <+248>: ldr x19, [x19, #0x8] 0x102ce4064 <+252>: adrp x8, 10058 0x102ce4068 <+256>: ldr x0, [x8, #0xf08] 0x102ce406c <+260>: bl 0x104ab6668 ; symbol stub for: objc_alloc -> 0x102ce4070 <+264>: ldr w3, [x19], #0x4 ```
0x0000000102ca07ec in -[FIRDocumentSnapshot dataWithServerTimestampBehavior:] () ``` Runner`-[FIRDocumentSnapshot dataWithServerTimestampBehavior:]: 0x102ca0714 <+0>: sub sp, sp, #0x60 0x102ca0718 <+4>: stp x22, x21, [sp, #0x30] 0x102ca071c <+8>: stp x20, x19, [sp, #0x40] 0x102ca0720 <+12>: stp x29, x30, [sp, #0x50] 0x102ca0724 <+16>: add x29, sp, #0x50 0x102ca0728 <+20>: mov x19, x2 0x102ca072c <+24>: mov x20, x0 0x102ca0730 <+28>: add x21, x0, #0x8 0x102ca0734 <+32>: bl 0x102c97700 ; firebase::firestore::model::FieldPath::EmptyPath() 0x102ca0738 <+36>: mov x1, x0 0x102ca073c <+40>: add x8, sp, #0x10 0x102ca0740 <+44>: mov x0, x21 0x102ca0744 <+48>: bl 0x102c8effc ; firebase::firestore::api::DocumentSnapshot::GetValue(firebase::firestore::model::FieldPath const&) const 0x102ca0748 <+52>: ldrb w8, [sp, #0x10] 0x102ca074c <+56>: cbz w8, 0x102ca0804 ; <+240> 0x102ca0750 <+60>: adrp x8, 10126 0x102ca0754 <+64>: ldr x0, [x8, #0xd48] 0x102ca0758 <+68>: bl 0x104ab6668 ; symbol stub for: objc_alloc 0x102ca075c <+72>: ldp x9, x8, [x20, #0x8] 0x102ca0760 <+76>: stp x9, x8, [sp] 0x102ca0764 <+80>: cbz x8, 0x102ca077c ; <+104> 0x102ca0768 <+84>: add x8, x8, #0x8 0x102ca076c <+88>: ldxr x9, [x8] 0x102ca0770 <+92>: add x9, x9, #0x1 0x102ca0774 <+96>: stxr w10, x9, [x8] 0x102ca0778 <+100>: cbnz w10, 0x102ca076c ; <+88> 0x102ca077c <+104>: adrp x8, 10122 0x102ca0780 <+108>: ldr x1, [x8, #0x388] 0x102ca0784 <+112>: mov x2, sp 0x102ca0788 <+116>: mov x3, x19 0x102ca078c <+120>: bl 0x104ab6788 ; symbol stub for: objc_msgSend 0x102ca0790 <+124>: mov x19, x0 0x102ca0794 <+128>: ldr x20, [sp, #0x8] 0x102ca0798 <+132>: cbz x20, 0x102ca07cc ; <+184> 0x102ca079c <+136>: add x8, x20, #0x8 0x102ca07a0 <+140>: ldaxr x9, [x8] 0x102ca07a4 <+144>: sub x10, x9, #0x1 0x102ca07a8 <+148>: stlxr w11, x10, [x8] 0x102ca07ac <+152>: cbnz w11, 0x102ca07a0 ; <+140> 0x102ca07b0 <+156>: cbnz x9, 0x102ca07cc ; <+184> 0x102ca07b4 <+160>: ldr x8, [x20] 0x102ca07b8 <+164>: ldr x8, [x8, #0x10] 0x102ca07bc <+168>: mov x0, x20 0x102ca07c0 <+172>: blr x8 0x102ca07c4 <+176>: mov x0, x20 0x102ca07c8 <+180>: bl 0x104ab5660 ; symbol stub for: std::__1::__shared_weak_count::__release_weak() 0x102ca07cc <+184>: ldrb w8, [sp, #0x10] 0x102ca07d0 <+188>: cbz w8, 0x102ca0820 ; <+268> 0x102ca07d4 <+192>: add x8, sp, #0x10 0x102ca07d8 <+196>: add x2, x8, #0x8 0x102ca07dc <+200>: adrp x8, 10120 0x102ca07e0 <+204>: ldr x1, [x8, #0xc90] 0x102ca07e4 <+208>: mov x0, x19 0x102ca07e8 <+212>: bl 0x104ab6788 ; symbol stub for: objc_msgSend -> 0x102ca07ec <+216>: mov x29, x29 ```
0x00000001047374ec in -[FLTFirebaseFirestoreWriter FIRDocumentSnapshot:] at /Users/harry/.pub-cache/hosted/pub.dev/cloud_firestore-4.9.0/ios/Classes/FLTFirebaseFirestoreWriter.m:178 ```obj-c @implementation FLTFirebaseFirestoreWriter : FlutterStandardWriter ... - (NSDictionary *)FIRDocumentSnapshot:(FIRDocumentSnapshot *)documentSnapshot { if (documentSnapshot == nil) { NSLog(@"Error: documentSnapshot is nil"); return nil; } NSNumber *documentSnapshotHash = @([documentSnapshot hash]); NSString *timestampBehaviorString = FLTFirebaseFirestorePlugin.serverTimestampMap[documentSnapshotHash]; FIRServerTimestampBehavior serverTimestampBehavior = [self toServerTimestampBehavior:timestampBehaviorString]; if (FLTFirebaseFirestorePlugin.serverTimestampMap[documentSnapshotHash] != nil) { [FLTFirebaseFirestorePlugin.serverTimestampMap removeObjectForKey:documentSnapshotHash]; } return @{ @"path" : documentSnapshot.reference.path, @"data" : documentSnapshot.exists ? (id)[documentSnapshot dataWithServerTimestampBehavior:serverTimestampBehavior] // <<<====== CRASH HERE : [NSNull null], @"metadata" : documentSnapshot.metadata, }; } ``` `timestampBehaviorString` is nil `serverTimestampBehavior` is FIRServerTimestampBehaviorNone `documentSnapshot.reference.path` seems okay and I can view the data in firebase console `documentSnapshot.exists` is YES `documentSnapshot.cachedMetadata` is (id)0x0 `FLTFirebaseFirestorePlugin.serverTimestampMap` is (__NSDictionaryM *)0x0000000282a7d800 (0 key/value pairs), an empty dictionary ``` self = (FLTFirebaseFirestoreWriter*)0x0000000282876f10 > FlutterStandardWriter FlutterStandardWriter > NSObject isa = (Class)FLTFirebaseFirestoreWriter 0x000021a103412b55 > _data = (NSConcreteMutableData*)0x000000028248e190 > NSMutableData _length = (unsigned long long)1 _capacity = (unsigned long long)40 _bytes = (void*)0x000000028248e1c0 ```
0x0000000104734fe4 in -[FLTFirebaseFirestoreWriter writeValue:] at /Users/harry/.pub-cache/hosted/pub.dev/cloud_firestore-4.9.0/ios/Classes/FLTFirebaseFirestoreWriter.m:50 ```obj-c @implementation FLTFirebaseFirestoreWriter : FlutterStandardWriter - (void)writeValue:(id)value { if ([value isKindOfClass:[NSDate class]]) { [self writeByte:FirestoreDataTypeDateTime]; NSDate *date = value; NSTimeInterval time = date.timeIntervalSince1970; SInt64 ms = (SInt64)(time * 1000.0); [self writeBytes:&ms length:8]; } else if ([value isKindOfClass:[FIRTimestamp class]]) { FIRTimestamp *timestamp = value; SInt64 seconds = timestamp.seconds; int nanoseconds = timestamp.nanoseconds; [self writeByte:FirestoreDataTypeTimestamp]; [self writeBytes:(UInt8 *)&seconds length:8]; [self writeBytes:(UInt8 *)&nanoseconds length:4]; } else if ([value isKindOfClass:[FIRGeoPoint class]]) { FIRGeoPoint *geoPoint = value; Float64 latitude = geoPoint.latitude; Float64 longitude = geoPoint.longitude; [self writeByte:FirestoreDataTypeGeoPoint]; [self writeAlignment:8]; [self writeBytes:(UInt8 *)&latitude length:8]; [self writeBytes:(UInt8 *)&longitude length:8]; } else if ([value isKindOfClass:[FIRDocumentReference class]]) { FIRDocumentReference *document = value; NSString *documentPath = [document path]; NSString *appName = [FLTFirebasePlugin firebaseAppNameFromIosName:document.firestore.app.name]; [self writeByte:FirestoreDataTypeDocumentReference]; [self writeValue:appName]; [self writeValue:documentPath]; } else if ([value isKindOfClass:[FIRDocumentSnapshot class]]) { [super writeValue:[self FIRDocumentSnapshot:value]]; // <<<============================ HERE } ... ```

Flutter doctor

Click To Expand ``` Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.13.1, on macOS 12.6.7 21G651 darwin-x64, locale en-GB) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [✓] Xcode - develop for iOS and macOS (Xcode 14.2) [✓] Android Studio (version 2022.3) [✓] Android Studio (version 4.0) [✓] Android Studio (version 4.0) [✓] VS Code (version 1.81.1) [✓] Connected device (2 available) [✓] Network resources • No issues found! ```

Flutter dependencies

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

Click To Expand ``` Dart SDK 3.1.0 Flutter SDK 3.13.1 mycrate 1.0.10+110 dependencies: - atlassian_apis 0.15.0 [http path] - cloud_firestore 4.9.0 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - cloud_functions 4.4.0 [cloud_functions_platform_interface cloud_functions_web firebase_core firebase_core_platform_interface flutter] - crate_base 1.0.1 [flutter firebase_core firebase_auth firebase_dynamic_links firebase_messaging firebase_storage cloud_firestore cloud_functions bubble camera collection connectivity_plus contacts_service cross_file crypto cupertino_icons device_info_plus emoji_picker_flutter extended_image fast_contacts file_picker flex_color_picker flutter_bloc flutter_email_sender flutter_exif_rotation flutter_hooks flutter_isolate flutter_markdown flutter_secure_storage flutter_slidable flutter_speed_dial flutter_svg get_it google_mlkit_text_recognition hive http http_parser image image_cropper intl just_audio logger mime open_filex package_info_plus path path_provider pdfx permission_handler photo_view provider purchases_flutter rxdart share_handler share_plus sqflite stream_transform url_launcher uuid vector_math video_player yaml] - feedback 2.6.0 [flutter flutter_localizations] - firebase_app_check 0.1.5+2 [firebase_app_check_platform_interface firebase_app_check_web firebase_core firebase_core_platform_interface flutter] - firebase_auth 4.8.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.15.1 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 3.3.5 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_messaging 14.6.7 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - firebase_storage 11.2.6 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - flex_color_scheme 7.3.1 [flex_seed_scheme flutter meta] - flutter 0.0.0 [characters collection material_color_utilities meta vector_math web sky_engine] - flutter_bloc 8.1.3 [bloc flutter provider] - flutter_hooks 0.20.1 [flutter] - flutter_native_splash 2.3.2 [args flutter flutter_web_plugins js html image meta path universal_io xml yaml] - flutter_speed_dial 7.0.0 [flutter] - flutter_svg 2.0.7 [flutter vector_graphics vector_graphics_codec vector_graphics_compiler] - font_awesome_flutter 10.5.0 [flutter] - get_it 7.6.0 [async collection] - google_sign_in 6.1.5 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web] - hive_flutter 1.1.0 [flutter hive path_provider path] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - logger 2.0.1 - mime 1.0.4 - package_info_plus 4.1.0 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface win32] - path 1.8.3 - path_provider 2.1.0 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows] - provider 6.0.5 [collection flutter nested] - purchases_flutter 5.6.2 [flutter freezed_annotation json_annotation] - rxdart 0.27.7 - store_checker 1.4.0 [flutter] - url_launcher 6.1.12 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] dev dependencies: - build_runner 2.4.6 [analyzer args async build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http_multi_server io js logging meta mime package_config path pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml] - dependency_validator 3.2.2 [args build_config checked_yaml glob io json_annotation logging package_config path pub_semver pubspec_parse yaml] - fake_cloud_firestore 2.2.0 [flutter cloud_firestore cloud_firestore_platform_interface collection plugin_platform_interface quiver rxdart mock_exceptions] - firebase_auth_mocks 0.12.0 [flutter firebase_auth firebase_core meta equatable dart_jsonwebtoken uuid firebase_auth_platform_interface mock_exceptions] - firebase_storage_mocks 0.6.1 [flutter firebase_storage] - flutter_gherkin 3.0.0-rc.17 [flutter flutter_test integration_test flutter_driver analyzer collection gherkin source_gen build glob] - flutter_lints 2.0.3 [lints] - flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math async boolean_selector characters collection material_color_utilities meta source_span stream_channel string_scanner term_glyph web] - gherkin 3.1.0 [path collection uuid matcher] - integration_test 0.0.0 [flutter flutter_driver flutter_test path vm_service async boolean_selector characters clock collection fake_async file matcher material_color_utilities meta source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api vector_math web webdriver] dependency overrides: - device_info_plus 9.0.3 [device_info_plus_platform_interface ffi file flutter flutter_web_plugins meta win32 win32_registry] - http 1.1.0 [async http_parser meta] transitive dependencies: - _fe_analyzer_shared 47.0.0 [meta] - _flutterfire_internals 1.3.5 [collection firebase_core firebase_core_platform_interface flutter meta] - adaptive_number 1.0.0 [fixnum] - analyzer 4.7.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - archive 3.3.7 [crypto path pointycastle] - args 2.4.2 - async 2.11.0 [collection meta] - audio_session 0.1.16 [flutter flutter_web_plugins rxdart meta] - bloc 8.1.2 [meta] - boolean_selector 2.1.1 [source_span string_scanner] - bubble 1.2.1 [flutter] - build 2.4.1 [analyzer async convert crypto glob logging meta package_config path] - build_config 1.1.1 [checked_yaml json_annotation path pubspec_parse yaml] - build_daemon 4.0.0 [built_collection built_value http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 2.0.10 [analyzer async build crypto graphs logging path package_config pool pub_semver stream_transform yaml] - build_runner_core 7.2.10 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta package_config path pool timing watcher yaml] - built_collection 5.1.1 - built_value 8.6.2 [built_collection collection fixnum meta] - camera 0.10.5+4 [camera_android camera_avfoundation camera_platform_interface camera_web flutter flutter_plugin_android_lifecycle quiver] - camera_android 0.10.8+8 [camera_platform_interface flutter flutter_plugin_android_lifecycle stream_transform] - camera_avfoundation 0.9.13+4 [camera_platform_interface flutter stream_transform] - camera_platform_interface 2.5.2 [cross_file flutter plugin_platform_interface stream_transform] - camera_web 0.3.2+2 [camera_platform_interface flutter flutter_web_plugins stream_transform] - characters 1.3.0 - checked_yaml 2.0.3 [json_annotation source_span yaml] - clock 1.1.1 - cloud_firestore_platform_interface 5.16.0 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 3.7.0 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - cloud_functions_platform_interface 5.5.0 [firebase_core flutter meta plugin_platform_interface] - cloud_functions_web 4.6.0 [cloud_functions_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - code_builder 4.6.0 [built_collection built_value collection matcher meta] - collection 1.17.2 - connectivity_plus 4.0.2 [flutter flutter_web_plugins connectivity_plus_platform_interface js meta nm] - connectivity_plus_platform_interface 1.2.4 [flutter meta plugin_platform_interface] - contacts_service 0.6.3 [flutter collection quiver] - convert 3.1.1 [typed_data] - cross_file 0.3.3+5 [js meta] - crypto 3.0.3 [typed_data] - csslib 1.0.0 [source_span] - cupertino_icons 1.0.5 - dart_jsonwebtoken 2.11.0 [crypto pointycastle convert collection ed25519_edwards] - dart_style 2.2.4 [analyzer args path pub_semver source_span] - dbus 0.7.8 [args ffi meta xml] - device_info_plus_platform_interface 7.0.0 [flutter meta plugin_platform_interface] - ed25519_edwards 0.3.1 [collection crypto convert adaptive_number] - emoji_picker_flutter 1.6.1 [flutter flutter_web_plugins plugin_platform_interface shared_preferences] - equatable 2.0.5 [collection meta] - extended_image 8.1.0 [extended_image_library flutter meta] - extended_image_library 3.6.0 [crypto flutter http_client_helper js path path_provider] - extension 0.6.0 [meta] - fake_async 1.3.1 [clock collection] - fast_contacts 3.0.3 [flutter] - ffi 2.1.0 - file 6.1.4 [meta path] - file_picker 5.3.4 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface ffi path win32] - firebase_app_check_platform_interface 0.0.9+2 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_app_check_web 0.0.11+2 [_flutterfire_internals firebase_app_check_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_auth_platform_interface 6.17.0 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.7.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser js meta] - firebase_core_platform_interface 4.8.0 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.7.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.6.5 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_dynamic_links 5.3.5 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface] - firebase_dynamic_links_platform_interface 0.2.6+5 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 4.5.6 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 3.5.6 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - firebase_storage_platform_interface 4.4.5 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.6.6 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - fixnum 1.1.0 - flex_color_picker 3.3.0 [flex_seed_scheme flutter] - flex_seed_scheme 1.4.0 [collection flutter meta] - flutter_driver 0.0.0 [file flutter flutter_test fuchsia_remote_debug_protocol path meta vm_service webdriver async boolean_selector characters clock collection matcher material_color_utilities platform process source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api vector_math web] - flutter_email_sender 6.0.1 [flutter] - flutter_exif_rotation 0.5.1 [flutter] - flutter_isolate 2.0.4 [flutter uuid] - flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math web] - flutter_markdown 0.6.17+2 [flutter markdown meta path] - flutter_plugin_android_lifecycle 2.0.16 [flutter] - flutter_secure_storage 8.1.0 [flutter flutter_secure_storage_linux flutter_secure_storage_macos flutter_secure_storage_platform_interface flutter_secure_storage_web flutter_secure_storage_windows meta] - flutter_secure_storage_linux 1.2.0 [flutter flutter_secure_storage_platform_interface] - flutter_secure_storage_macos 3.0.1 [flutter flutter_secure_storage_platform_interface] - flutter_secure_storage_platform_interface 1.0.2 [flutter plugin_platform_interface] - flutter_secure_storage_web 1.1.2 [flutter flutter_secure_storage_platform_interface flutter_web_plugins js] - flutter_secure_storage_windows 2.1.1 [flutter flutter_secure_storage_platform_interface] - flutter_slidable 3.0.0 [flutter] - flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math web] - freezed_annotation 2.4.1 [collection json_annotation meta] - frontend_server_client 3.2.0 [async path] - fuchsia_remote_debug_protocol 0.0.0 [process vm_service file meta path platform] - glob 2.1.2 [async collection file path string_scanner] - google_identity_services_web 0.2.1+1 [js meta] - google_mlkit_commons 0.5.0 [flutter] - google_mlkit_text_recognition 0.10.0 [flutter google_mlkit_commons] - google_sign_in_android 6.1.19 [flutter google_sign_in_platform_interface] - google_sign_in_ios 5.6.3 [flutter google_sign_in_platform_interface] - google_sign_in_platform_interface 2.4.2 [flutter plugin_platform_interface quiver] - google_sign_in_web 0.12.0+4 [flutter flutter_web_plugins google_identity_services_web google_sign_in_platform_interface http js] - graphs 2.3.1 [collection] - hive 2.2.3 [meta crypto] - html 0.15.4 [csslib source_span] - http_client_helper 3.0.0 [http] - http_multi_server 3.2.1 [async] - image 4.0.17 [archive meta xml] - image_cropper 5.0.0 [flutter image_cropper_platform_interface image_cropper_for_web] - image_cropper_for_web 3.0.0 [flutter flutter_web_plugins image_cropper_platform_interface js] - image_cropper_platform_interface 5.0.0 [flutter plugin_platform_interface http] - intl 0.18.1 [clock meta path] - io 1.0.4 [meta path string_scanner] - js 0.6.7 [meta] - json_annotation 4.8.1 [meta] - just_audio 0.9.34 [just_audio_platform_interface just_audio_web audio_session rxdart path path_provider async uuid crypto meta flutter] - just_audio_platform_interface 4.2.1 [flutter plugin_platform_interface] - just_audio_web 0.4.8 [just_audio_platform_interface flutter flutter_web_plugins] - lints 2.1.1 - logging 1.2.0 - markdown 7.1.1 [args meta] - matcher 0.12.16 [async meta stack_trace term_glyph test_api] - material_color_utilities 0.5.0 [collection] - meta 1.9.1 - mock_exceptions 0.8.2 [matcher] - nested 1.0.0 [flutter] - nm 0.5.0 [dbus] - open_filex 4.3.2 [flutter ffi] - package_config 2.1.0 [path] - package_info_plus_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - path_parsing 1.0.1 [vector_math meta] - path_provider_android 2.1.0 [flutter path_provider_platform_interface] - path_provider_foundation 2.3.0 [flutter path_provider_platform_interface] - path_provider_linux 2.2.0 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_platform_interface 2.1.0 [flutter platform plugin_platform_interface] - path_provider_windows 2.2.0 [ffi flutter path path_provider_platform_interface win32] - pdfx 2.4.0 [flutter flutter_web_plugins plugin_platform_interface js device_info_plus uuid meta extension synchronized universal_platform photo_view vector_math] - permission_handler 10.4.3 [flutter meta permission_handler_android permission_handler_apple permission_handler_windows permission_handler_platform_interface] - permission_handler_android 10.3.4 [flutter permission_handler_platform_interface] - permission_handler_apple 9.1.4 [flutter permission_handler_platform_interface] - permission_handler_platform_interface 3.11.3 [flutter meta plugin_platform_interface] - permission_handler_windows 0.1.3 [flutter permission_handler_platform_interface] - petitparser 5.4.0 [meta] - photo_view 0.14.0 [flutter] - platform 3.1.0 - plugin_platform_interface 2.1.5 [meta] - pointycastle 3.7.3 [collection convert js] - pool 1.5.1 [async stack_trace] - process 4.2.4 [file path platform] - pub_semver 2.1.4 [collection meta] - pubspec_parse 1.2.3 [checked_yaml collection json_annotation pub_semver yaml] - quiver 3.2.1 [matcher] - share_handler 0.0.17 [flutter share_handler_android share_handler_ios share_handler_platform_interface] - share_handler_android 0.0.7 [flutter share_handler_platform_interface] - share_handler_ios 0.0.10 [flutter share_handler_platform_interface] - share_handler_platform_interface 0.0.6 [flutter plugin_platform_interface] - share_plus 7.1.0 [cross_file meta mime flutter flutter_web_plugins share_plus_platform_interface file url_launcher_web url_launcher_windows url_launcher_linux url_launcher_platform_interface ffi win32] - share_plus_platform_interface 3.3.0 [cross_file flutter meta mime plugin_platform_interface path_provider uuid] - shared_preferences 2.2.0 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] - shared_preferences_android 2.2.0 [flutter shared_preferences_platform_interface] - shared_preferences_foundation 2.3.3 [flutter shared_preferences_platform_interface] - shared_preferences_linux 2.3.0 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface] - shared_preferences_platform_interface 2.3.0 [flutter plugin_platform_interface] - shared_preferences_web 2.2.0 [flutter flutter_web_plugins shared_preferences_platform_interface] - shared_preferences_windows 2.3.0 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - shelf 1.4.1 [async collection http_parser path stack_trace stream_channel] - shelf_web_socket 1.0.4 [shelf stream_channel web_socket_channel] - sky_engine 0.0.99 - source_gen 1.2.6 [analyzer async build dart_style glob meta path source_span yaml] - source_span 1.10.0 [collection path term_glyph] - sqflite 2.3.0 [flutter sqflite_common path] - sqflite_common 2.5.0 [synchronized path meta] - stack_trace 1.11.0 [path] - stream_channel 2.1.1 [async] - stream_transform 2.1.0 - string_scanner 1.2.0 [source_span] - sync_http 0.3.1 - synchronized 3.1.0 - term_glyph 1.2.1 - test_api 0.6.0 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph] - timing 1.0.1 [json_annotation] - typed_data 1.3.2 [collection] - universal_io 2.2.2 [collection meta typed_data] - universal_platform 1.0.0+1 - url_launcher_android 6.0.38 [flutter url_launcher_platform_interface] - url_launcher_ios 6.1.4 [flutter url_launcher_platform_interface] - url_launcher_linux 3.0.5 [flutter url_launcher_platform_interface] - url_launcher_macos 3.0.6 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.1.3 [flutter plugin_platform_interface] - url_launcher_web 2.0.18 [flutter flutter_web_plugins url_launcher_platform_interface] - url_launcher_windows 3.0.7 [flutter url_launcher_platform_interface] - uuid 3.0.7 [crypto] - vector_graphics 1.1.7 [flutter vector_graphics_codec] - vector_graphics_codec 1.1.7 - vector_graphics_compiler 1.1.7 [args meta path_parsing xml vector_graphics_codec] - vector_math 2.1.4 - video_player 2.7.0 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web] - video_player_android 2.4.9 [flutter video_player_platform_interface] - video_player_avfoundation 2.4.9 [flutter video_player_platform_interface] - video_player_platform_interface 6.2.0 [flutter plugin_platform_interface] - video_player_web 2.0.16 [flutter flutter_web_plugins video_player_platform_interface] - vm_service 11.7.1 - watcher 1.1.0 [async path] - web 0.1.4-beta - web_socket_channel 2.4.0 [async crypto stream_channel] - webdriver 3.0.2 [matcher path stack_trace sync_http] - win32 5.0.7 [ffi] - win32_registry 1.1.1 [ffi win32] - xdg_directories 1.0.2 [meta path] - xml 6.3.0 [collection meta petitparser] - yaml 3.1.2 [collection source_span string_scanner] ```

harry-dickson commented 1 year ago

Cannot reproduce - after it crashing every time, all day today. What happened?

harry-dickson commented 1 year ago

Blowing up in my face again. Makes me nostalgic for my old, crappy C-code - I thought we were past this stuff.

- (id)convertedValue:(const google_firestore_v1_Value &)value {
  switch (GetTypeOrder(value)) {
    case TypeOrder::kMap:
      return [self convertedObject:value.map_value];
    case TypeOrder::kArray:
      return [self convertedArray:value.array_value];
    case TypeOrder::kReference:
      return [self convertedReference:value];
    case TypeOrder::kTimestamp:
      return [self convertedTimestamp:value.timestamp_value];
    case TypeOrder::kServerTimestamp:
      return [self convertedServerTimestamp:value];
    case TypeOrder::kNull:
      return [NSNull null];
    case TypeOrder::kBoolean:
      return value.boolean_value ? @YES : @NO;
    case TypeOrder::kNumber:
      return value.which_value_type == google_firestore_v1_Value_integer_value_tag
                 ? @(value.integer_value)
                 : @(value.double_value);
    case TypeOrder::kString:
      return MakeNSString(MakeStringView(value.string_value));  // <<======= here, I guess from stack trace
    case TypeOrder::kBlob:
      return MakeNSData(value.bytes_value);
    case TypeOrder::kGeoPoint:
      return MakeFIRGeoPoint(
          GeoPoint(value.geo_point_value.latitude, value.geo_point_value.longitude));
    case TypeOrder::kMaxValue:
      // It is not possible for users to construct a kMaxValue manually.
      break;
  }

  UNREACHABLE();
}

This is in the same general region of code as this issue #11096 - why am I being tortured by this stuff?

harry-dickson commented 1 year ago

Is this a https://github.com/invertase/firestore-ios-sdk-frameworks mismatch problem I wonder? Stranger things have happened...

harry-dickson commented 1 year ago

So this is a crash if you have a Blob field that is null.

In nanopb_util.h:

inline NSData* _Nonnull MakeNSData(const pb_bytes_array_t* _Nullable data) {
  return [[NSData alloc] initWithBytes:data->bytes length:data->size];
}

The data is declared as being nullable and then dereferenced without any attempt to check it. The return type is not nullable, making reasonable behavior difficult.

I had a quick rummage around the source and I am guessing null Blob fields have never worked.

Think I will close this and make a fresh issue.