flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

🐛 [cloud_firestore] iOS Crash with firestore on release Iphone 6

Open vgabler opened this issue 2 years ago • 12 comments

Bug report

The app crashes when trying to use data from Firebase Firestore. Maybe somewhat related to #11216, but I thought it would be better to create this issue with my findings.

Steps to reproduce

  1. create a new flutter project
  2. flutterfire configure
  3. use the sample code
  4. build and run on iPhone 6 ios 12.5.7

Expected behavior

Expected it not to crash, and the counter increases when the button is pressed.

Sample project

I've tried to keep the app to as minimal as possible. Apart from configuring firebase, this is the code:

Click To Expand
import "package:apreco/firebase_options.dart";
import "package:cloud_firestore/cloud_firestore.dart";
import "package:firebase_core/firebase_core.dart";
import "package:flutter/material.dart";

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Flutter Demo",
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: "Flutter Demo Home Page"),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final counterDoc =
      FirebaseFirestore.instance.collection("test").doc("testCounter");

  @override
  Widget build(BuildContext context) {
    return StreamBuilder(
      stream: counterDoc.snapshots(),
      builder: (context, snapshot) {
        final data = snapshot.data?.data() ?? <String, dynamic>{};
        final value = data["count"] ?? 0;

        return Scaffold(
          appBar: AppBar(
            backgroundColor: Theme.of(context).colorScheme.inversePrimary,
            title: Text(widget.title),
          ),
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                const Text(
                  "You have pushed the button this many times:",
                ),
                Text(
                  "$value",
                  style: Theme.of(context).textTheme.headlineMedium,
                ),
              ],
            ),
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: () {
              data["count"] = value + 1;
              counterDoc.set(data);
            },
            tooltip: "Increment",
            child: const Icon(Icons.add),
          ),
        );
      },
    );
  }
}

Flutter doctor

The build was actually made on CodeMagic, using flutter 3.13.8.

== Use Xcode 15 ==
> sudo xcode-select --switch /Applications/Xcode-15.0.app/Contents/Developer
Xcode 15.0.1
Build version 15A507

== Use default version of CocoaPods ==
> gem list '^cocoapods$' --no-verbose
cocoapods (1.13.0)

== Use Java version 11 ==
> java -version
openjdk version "11.0.20" 2023-07-18 LTS
OpenJDK Runtime Environment Zulu11.66+15-CA (build 11.0.20+8-LTS)
OpenJDK 64-Bit Server VM Zulu11.66+15-CA (build 11.0.20+8-LTS, mixed mode)

== Codemagic CLI tools ==
> codemagic-cli-tools version
codemagic-cli-tools 0.46.1

Flutter dependencies

Click To Expand
Dart SDK 3.1.4
Flutter SDK 3.13.8

dependencies:
- cloud_firestore 4.11.0 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta]
- cupertino_icons 1.0.6
- firebase_core 2.19.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math web sky_engine]

dev dependencies:
- 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]

transitive dependencies:
- _flutterfire_internals 1.3.9 [collection firebase_core firebase_core_platform_interface flutter meta]
- async 2.11.0 [collection meta]
- boolean_selector 2.1.1 [source_span string_scanner]
- characters 1.3.0
- clock 1.1.1
- cloud_firestore_platform_interface 6.0.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 3.8.1 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js]
- collection 1.17.2
- fake_async 1.3.1 [clock collection]
- firebase_core_platform_interface 5.0.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.8.1 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math web]
- js 0.6.7 [meta]
- lints 2.1.1
- matcher 0.12.16 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.5.0 [collection]
- meta 1.9.1
- path 1.8.3
- plugin_platform_interface 2.1.6 [meta]
- sky_engine 0.0.99
- source_span 1.10.0 [collection path term_glyph]
- stack_trace 1.11.0 [path]
- stream_channel 2.1.1 [async]
- string_scanner 1.2.0 [source_span]
- 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]
- vector_math 2.1.4
- web 0.1.4-beta

iOS Crash Log

Click To Expand

Date/Time: 2023-10-23 11:21:48.9552 -0300
Launch Time: 2023-10-23 11:21:45.1216 -0300
OS Version: iPhone OS 12.5.7 (16H81)
Baseband Version: 7.80.04
Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
VM Region Info: 0 is not in any region. Bytes before following region: 4302766080
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 0000000100770000-0000000100778000 [ 32K] r-x/r-x SM=COW ...[er.app/Runner](http://er.app/Runner)

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [641]
Triggered by Thread: 3

Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libsystem_kernel.dylib 0x00000001ba3040f4 0x1ba2ec000 + 98548
1 libsystem_kernel.dylib 0x00000001ba3035a0 0x1ba2ec000 + 95648
2 CoreFoundation 0x00000001ba704914 0x1ba65a000 + 698644
3 CoreFoundation 0x00000001ba6ff824 0x1ba65a000 + 677924
4 CoreFoundation 0x00000001ba6fefb4 0x1ba65a000 + 675764
5 GraphicsServices 0x00000001bc90179c 0x1bc8f7000 + 42908
6 UIKitCore 0x00000001e714bc38 0x1e688f000 + 9161784
7 Runner 0x0000000100778304 0x100770000 + 33540
8 libdyld.dylib 0x00000001ba1c28e0 0x1ba1c1000 + 6368

Thread 1:
0 libsystem_pthread.dylib 0x00000001ba394cd0 0x1ba386000 + 60624

Thread 2:
0 libsystem_pthread.dylib 0x00000001ba394cd0 0x1ba386000 + 60624

Thread 3 name: Dispatch queue: com.google.firebase.firestore
Thread 3 Crashed:
0 ??? 000000000000000000 0 + 0
1 grpc 0x0000000101252f94 0x101210000 + 274324
2 grpc 0x000000010129898c 0x101210000 + 559500
3 grpc 0x000000010129892c 0x101210000 + 559404
4 grpc 0x0000000101298d14 0x101210000 + 560404
5 grpc 0x0000000101260544 0x101210000 + 329028
6 grpcpp 0x0000000101a04f80 0x1019dc000 + 167808
7 grpcpp 0x0000000101a04ef4 0x1019dc000 + 167668
8 grpcpp 0x00000001019f67d8 0x1019dc000 + 108504
9 FirebaseFirestore 0x0000000100b3abac 0x100aa8000 + 601004
10 FirebaseFirestore 0x0000000100b3a944 0x100aa8000 + 600388
11 FirebaseFirestore 0x0000000100b3b088 0x100aa8000 + 602248
12 FirebaseFirestore 0x0000000100beadd4 0x100aa8000 + 1322452
13 FirebaseFirestore 0x0000000100bec544 0x100aa8000 + 1328452
14 FirebaseFirestore 0x0000000100aafacc 0x100aa8000 + 31436
15 FirebaseFirestore 0x0000000100bff9dc 0x100aa8000 + 1407452
16 libdispatch.dylib 0x00000001ba1b17d4 0x1ba151000 + 395220
17 libdispatch.dylib 0x00000001ba15a324 0x1ba151000 + 37668
18 libdispatch.dylib 0x00000001ba15ae40 0x1ba151000 + 40512
19 libdispatch.dylib 0x00000001ba1634ac 0x1ba151000 + 74924
20 libsystem_pthread.dylib 0x00000001ba392114 0x1ba386000 + 49428
21 libsystem_pthread.dylib 0x00000001ba394cd4 0x1ba386000 + 60628


Date/Time: 2023-10-23 11:21:48.9552 -0300
Launch Time: 2023-10-23 11:21:45.1216 -0300
OS Version: iPhone OS 12.5.7 (16H81)
Baseband Version: 7.80.04
Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
VM Region Info: 0 is not in any region. Bytes before following region: 4302766080
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 0000000100770000-0000000100778000 [ 32K] r-x/r-x SM=COW ...[er.app/Runner](http://er.app/Runner)

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [641]
Triggered by Thread: 3

Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libsystem_kernel.dylib 0x00000001ba3040f4 0x1ba2ec000 + 98548
1 libsystem_kernel.dylib 0x00000001ba3035a0 0x1ba2ec000 + 95648
2 CoreFoundation 0x00000001ba704914 0x1ba65a000 + 698644
3 CoreFoundation 0x00000001ba6ff824 0x1ba65a000 + 677924
4 CoreFoundation 0x00000001ba6fefb4 0x1ba65a000 + 675764
5 GraphicsServices 0x00000001bc90179c 0x1bc8f7000 + 42908
6 UIKitCore 0x00000001e714bc38 0x1e688f000 + 9161784
7 Runner 0x0000000100778304 0x100770000 + 33540
8 libdyld.dylib 0x00000001ba1c28e0 0x1ba1c1000 + 6368

Thread 1:
0 libsystem_pthread.dylib 0x00000001ba394cd0 0x1ba386000 + 60624

Thread 2:
0 libsystem_pthread.dylib 0x00000001ba394cd0 0x1ba386000 + 60624

Thread 3 name: Dispatch queue: com.google.firebase.firestore
Thread 3 Crashed:
0 ??? 000000000000000000 0 + 0
1 grpc 0x0000000101252f94 0x101210000 + 274324
2 grpc 0x000000010129898c 0x101210000 + 559500
3 grpc 0x000000010129892c 0x101210000 + 559404
4 grpc 0x0000000101298d14 0x101210000 + 560404
5 grpc 0x0000000101260544 0x101210000 + 329028
6 grpcpp 0x0000000101a04f80 0x1019dc000 + 167808
7 grpcpp 0x0000000101a04ef4 0x1019dc000 + 167668
8 grpcpp 0x00000001019f67d8 0x1019dc000 + 108504
9 FirebaseFirestore 0x0000000100b3abac 0x100aa8000 + 601004
10 FirebaseFirestore 0x0000000100b3a944 0x100aa8000 + 600388
11 FirebaseFirestore 0x0000000100b3b088 0x100aa8000 + 602248
12 FirebaseFirestore 0x0000000100beadd4 0x100aa8000 + 1322452
13 FirebaseFirestore 0x0000000100bec544 0x100aa8000 + 1328452
14 FirebaseFirestore 0x0000000100aafacc 0x100aa8000 + 31436
15 FirebaseFirestore 0x0000000100bff9dc 0x100aa8000 + 1407452
16 libdispatch.dylib 0x00000001ba1b17d4 0x1ba151000 + 395220
17 libdispatch.dylib 0x00000001ba15a324 0x1ba151000 + 37668
18 libdispatch.dylib 0x00000001ba15ae40 0x1ba151000 + 40512
19 libdispatch.dylib 0x00000001ba1634ac 0x1ba151000 + 74924
20 libsystem_pthread.dylib 0x00000001ba392114 0x1ba386000 + 49428
21 libsystem_pthread.dylib 0x00000001ba394cd4 0x1ba386000 + 60628

vgabler avatar Oct 24 '23 13:10 vgabler

Thanks for the report @vgabler I currently don't have iphone 6 device to verify this. Are you using the latest firebase ios sdk version ? https://github.com/firebase/flutterfire/issues/11216#issuecomment-1746746877

darshankawar avatar Oct 25 '23 10:10 darshankawar

I was using the latest version for both packages: cloud_firestore 4.11.0 firebase_core 2.19.0 I noticed an update was released increasing the SDK version, gonna try it now and update here

vgabler avatar Oct 25 '23 13:10 vgabler

Updating to latest version DID NOT solve it. The same error persists!

vgabler avatar Oct 25 '23 16:10 vgabler

Thanks for the update. I got hold of iphone 6 running on 15.3.1 on which it didn't crash upon running in release mode. Upon tapping FAB, the counter incremented properly and showed up in firebase console properly as below:

Screenshot 2023-10-26 at 5 19 24 PM

Maybe it is specific to OS version as well, as I see that your iphone 6 is running on 12.5.7 version which is quite old. Based on the report and crash triggered, keeping it open for team's attention and tracking.

darshankawar avatar Oct 26 '23 11:10 darshankawar

Screenshot 2023-10-26 at 14 35 41

it was fixed in the native implementation. Please upgrade to 4.12.0 and report back to see if it was fixed :)

Lyokone avatar Oct 26 '23 12:10 Lyokone

I've already tried out cloud_firestore 4.12.0; Just made another build with 4.12.1, the issue remains.. @darshankawar my iPhone is just plain 6. It won't update past iOS 12.5.7

Dart SDK 3.1.4
Flutter SDK 3.13.8

dependencies:
- cloud_firestore 4.12.1 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta]
- cupertino_icons 1.0.6
- firebase_core 2.20.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math web sky_engine]

dev dependencies:
- 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]

transitive dependencies:
- _flutterfire_internals 1.3.10 [collection firebase_core firebase_core_platform_interface flutter meta]
- async 2.11.0 [collection meta]
- boolean_selector 2.1.1 [source_span string_scanner]
- characters 1.3.0
- clock 1.1.1
- cloud_firestore_platform_interface 6.0.2 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 3.8.2 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js]
- collection 1.17.2
- fake_async 1.3.1 [clock collection]
- firebase_core_platform_interface 5.0.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.8.1 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math web]
- js 0.6.7 [meta]
- lints 2.1.1
- matcher 0.12.16 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.5.0 [collection]
- meta 1.9.1
- path 1.8.3
- plugin_platform_interface 2.1.6 [meta]
- sky_engine 0.0.99
- source_span 1.10.0 [collection path term_glyph]
- stack_trace 1.11.0 [path]
- stream_channel 2.1.1 [async]
- string_scanner 1.2.0 [source_span]
- 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]
- vector_math 2.1.4
- web 0.1.4-beta

vgabler avatar Oct 26 '23 14:10 vgabler

I have this issue with IOS 14 with iPhone 11

rahmanrezaee avatar Oct 29 '23 05:10 rahmanrezaee

Hello! Any updates on this issue? Just tested on an iPhone 7, iOS 15, everything works fine

vgabler avatar Nov 19 '23 10:11 vgabler

Same issue with my iPhone6 (v12.5.7) and iPhone11 with iOS 14. Only in release mode. Solved now using xCode 15.1

Fefe-88 avatar Dec 14 '23 09:12 Fefe-88

@vgabler - That stack trace is coming entirely from the Firebase iOS SDK. It is not coming from FlutterFire. Have you reproduced this on a physical device? Or just through code magic?

russellwheatley avatar Dec 21 '23 08:12 russellwheatley

Hey we have one particular user on ios 12.x and iPhone 6. I found this issue over on the iOS SDK. @fefecilly Can you confirm this is solved in 15.1 because I've used 15.2 to release the app and this is when the issue started for the user. Have you upgraded cloud_firestore at all or did it just disappear? We are on cloud_firestore ^4.9.3 @Lyokone should upgrading to 4.12 fix?

d9media avatar Jan 30 '24 14:01 d9media

@d9media, yes with xCode 15.1 my app is running on iphone 6 Ios 12.5.7;

Fefe-88 avatar Jan 30 '24 14:01 Fefe-88

@d9media, @vgabler Can you confirm if this issue still persists?

TarekkMA avatar Apr 23 '24 11:04 TarekkMA

Hey @vgabler. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar May 02 '24 01:05 google-oss-bot

Hi, sorry for the delay. I had some issues with my phone. I've updated the firebase packages, those are the new versions:

Dart SDK 3.3.3 Flutter SDK 3.19.5

dependencies:

  • cloud_firestore 4.16.1 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta]
  • firebase_core 2.29.0 [firebase_core_platform_interface firebase_core_web flutter meta]

The issue is gone!

vgabler avatar May 08 '24 13:05 vgabler