I'm trying to run on iOS a Flutter app that works perfectly on Android, but it crashes as soon as it arribes to any get(). It does not return any Flutter error, just crashes the app.
The exact line that is causing the issue is:
await Firestore.instance.collection('users')
.document(user_id).get();
(I have a print just before and after this line, so even I have no error reports from Flutter I know it's this line).
If I run the same code on Xcode directly it throws this error:
Thread 32: EXC_BAD_ACCESS (code=1, address=0xffffffffffffffc0)
which, by itself, says nothing to me...
The device system.log also says nothing interesting, just outputs this line when the app crashes and closes: Service exited due to SIGKILL
Other Firebase services like Phone Auth are working, so I don't think is something related to the configuration steps.
The whole output from Xcode is the following:
2020-07-03 19:26:33.610523+0200 Runner[61136:291072] Configuring the default Firebase app...
2020-07-03 19:26:33.610722+0200 Runner[61136:291275] 6.27.0 - [Firebase/Core][I-COR000004] App with name __FIRAPP_DEFAULT does not exist.
2020-07-03 19:26:33.636671+0200 Runner[61136:291322] flutter: Observatory listening on http://127.0.0.1:56092/G_cDDDyHZOo=/
2020-07-03 19:26:33.648575+0200 Runner[61136:291284] 6.27.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60601000 started
2020-07-03 19:26:33.649030+0200 Runner[61136:291284] 6.27.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2020-07-03 19:26:33.658414+0200 Runner[61136:291072] [Crashlytics] Version 3.14.0 (144)
2020-07-03 19:26:33.667028+0200 Runner[61136:291072] Configured the default Firebase app __FIRAPP_DEFAULT.
2020-07-03 19:26:33.668469+0200 Runner[61136:291072] [Fabric] [Fabric +with] called multiple times. Only the first call is honored, please pass all kits you wish to initialize
[INFO] ThreadPoolTaskScheduler - Starting thread 'OLPSDKPOOL_1'
[INFO] ThreadPoolTaskScheduler - Starting thread 'OLPSDKPOOL_0'
2020-07-03 19:26:33.823331+0200 Runner[61136:291334] 6.27.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2020-07-03 19:26:33.829694+0200 Runner[61136:291288] 6.27.0 - [Firebase/Analytics][I-ACS031025] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2020-07-03 19:26:33.838478+0200 Runner[61136:291334] 6.27.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled
2020-07-03 19:26:33.862359+0200 Runner[61136:291334] [Fabric] failed to download settings Error Domain=FABNetworkError Code=-5 "(null)" UserInfo={status_code=403, type=2, request_id=, content_type=application/json; charset=utf-8}
2020-07-03 19:26:33.992921+0200 Runner[61136:291072] WF: === Starting WebFilter logging for process Runner
2020-07-03 19:26:33.993100+0200 Runner[61136:291072] WF: _userSettingsForUser : (null)
2020-07-03 19:26:33.993241+0200 Runner[61136:291072] WF: _WebFilterIsActive returning: NO
[DEBUG] OLPHttpTask - Run task, request_id=1, task_id=1, http_method=GET, url=https://account.api.here.com/timestamp)
[DEBUG] OLPHttpTask - Task is completed, request_id=1, url=https://account.api.here.com/timestamp, task_id=1, error=0
[DEBUG] OLPHttpTask - Run task, request_id=2, task_id=2, http_method=POST, url=https://account.api.here.com/oauth2/token)
[DEBUG] OLPHttpTask - Task is completed, request_id=2, url=https://account.api.here.com/oauth2/token, task_id=2, error=0
[DEBUG] OLPHttpTask - Run task, request_id=3, task_id=3, http_method=GET, url=https://account.api.here.com/app/me)
[DEBUG] OLPHttpTask - Task is completed, request_id=3, url=https://account.api.here.com/app/me, task_id=3, error=0
2020-07-03 19:26:36.277526+0200 Runner[61136:291308] flutter: Retrieve from firecloud started on user
2020-07-03 19:26:36.283023+0200 Runner[61136:291308] flutter: Current user get on user U1a8**************aWx1
I thought it could have something to do with line 2, but adding the line Firebase.configure() to AppDelegate solves this line but the crash persists. I simply removed the line because I haven't read about it on official documentation.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The app does not crash and I get everything working as it works on Android :)
Additional context
I'm using Firebase Auth with phone auth, I've configured everything necessary to make it work with phone auth and it's working fine.
I'm trying to run this app on an iPhone 11 simulator as I don't have a physical iPhone yet.
I've tried the always recommended flutter clean command, deleting Podfile and Podfile.lock so flutter recreates it, redownloading GoogleService-Info.plist, etc...
Flutter doctor
[✓] Flutter (Channel stable, v1.17.5, on Mac OS X 10.15.5 19F101, locale es-ES)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
[✓] Android Studio (version 4.0)
[✓] Connected device (1 available)
• No issues found!
I would gladly give you all any additional info required to make this work. It's been a week trying to solve this and nothing seem to work.
Thank you!
Hi @sajunt4
Please execute following from root of your ios folder and alsoe make sure you've firebase in your. AppDelegate
pod init
pod install
pod update
and try again
If the problem perisist, your flutter run --verbose and a complete reproducible minimal code sample,
Thank you
Hello again!
I've tried what you said @TahaTesser but still nothing moving in the right direction.
Running flutter run --verbose gives us no useful info. Everything goes well during the build and as soon as we arribe to the line told on first post, and the app closes suddenly.
Today I've tested it in a physical iPhone and running it though Xcode gave us some more info about the moment the app breaks:
Runner[752:107548] *** Assertion failure in void firebase::firestore::core::FirestoreClient::Initialize(const firebase::firestore::auth::User &, const firebase::firestore::api::Settings &)(), /Users/taco/StudioProjects/TACO/ios/Pods/FirebaseFirestore/Firestore/core/src/core/firestore_client.cc:180
FIRESTORE INTERNAL ASSERTION FAILED: Failed to open DB: Internal: Failed to open LevelDB database at : LevelDB error: IO error: /LOCK @ /Users/bldadmin/.jenkins/workspace/iot-sdk/release/release-ios-pipe/external/leveldb/util/env_posix.cc:445 virtual leveldb::Status leveldb::(anonymous namespace)::PosixEnv::LockFile(const std::string &, leveldb::FileLock **): Operation not permitted (expected created.ok())
(
0 CoreFoundation 0x000000018cef0314 AF42303F-57B6-3C11-8F18-8E80ABF7D886 + 1254164
1 libobjc.A.dylib 0x000000018cc04c1c objc_exception_throw + 60
2 CoreFoundation 0x000000018cded1f8 AF42303F-57B6-3C11-8F18-8E80ABF7D886 + 193016
3 Foundation 0x000000018d2835c4 19FAB59F-6527-3245-85BB-905FD4255CDE + 902596
4 Runner 0x0000000104788fb8 _ZN8firebase9firestore4util16ObjcThrowHandlerENS1_13ExceptionTypeEPKcS4_iRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE + 300
5 Runner 0x0000000104788854 _ZN8firebase9firestore4util5ThrowENS1_13ExceptionTypeEPKcS4_iRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE + 64
6 Runner 0x00000001048feff0 _ZN8firebase9firestore4util8internal13FailAssertionEPKcS4_iRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEES4_ + 0
7 Runner 0x00000001048ff0a0 _ZN8firebase9firestore4util8internal13FailAssertionEPKcS4_iRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEES4_ + 176
8 Runner 0x000000010480952c _ZN8firebase9firestore4core15FirestoreClient10InitializeERKNS0_4auth4UserERKNS0_3api8SettingsE + 448
9 Runner 0x0000000104814cb0 _ZZZN8firebase9firestore4core15FirestoreClient6CreateERKNS1_12DatabaseInfoERKNS0_3api8SettingsENSt3__110shared_ptrINS0_4auth19CredentialsProviderEEENSB_INS0_4util8ExecutorEEENSB_INSF_10AsyncQueueEEEEN3$_2clENSC_4UserEENKUlvE_clEv + 48
10 Runner 0x0000000104814c60 _ZNSt3__1L8__invokeIRZZN8firebase9firestore4core15FirestoreClient6CreateERKNS3_12DatabaseInfoERKNS2_3api8SettingsENS_10shared_ptrINS2_4auth19CredentialsProviderEEENSC_INS2_4util8ExecutorEEENSC_INSG_10AsyncQueueEEEEN3$_2clENSD_4UserEEUlvE_JEEEDTclclsr3std3__1E7forwardIT_Efp_Espclsr3std3__1E7forwardIT0_Efp0_EEEOSP_DpOSQ_ + 28
11 Runner 0x0000000104814c10 _ZNSt3__128__invoke_void_return_wrapperIvE6__callIJRZZN8firebase9firestore4core15FirestoreClient6CreateERKNS5_12DatabaseInfoERKNS4_3api8SettingsENS_10shared_ptrINS4_4auth19CredentialsProviderEEENSE_INS4_4util8ExecutorEEENSE_INSI_10AsyncQueueEEEEN3$_2clENSF_4UserEEUlvE_EEEvDpOT_ + 28
12 Runner 0x0000000104814be8 _ZNSt3__110__function12__alloc_funcIZZN8firebase9firestore4core15FirestoreClient6CreateERKNS4_12DatabaseInfoERKNS3_3api8SettingsENS_10shared_ptrINS3_4auth19CredentialsProviderEEENSD_INS3_4util8ExecutorEEENSD_INSH_10AsyncQueueEEEEN3$_2clENSE_4UserEEUlvE_NS_9allocatorISO_EEFvvEEclEv + 28
13 Runner 0x0000000104813354 _ZNSt3__110__function6__funcIZZN8firebase9firestore4core15FirestoreClient6CreateERKNS4_12DatabaseInfoERKNS3_3api8SettingsENS_10shared_ptrINS3_4auth19CredentialsProviderEEENSD_INS3_4util8ExecutorEEENSD_INSH_10AsyncQueueEEEEN3$_2clENSE_4UserEEUlvE_NS_9allocatorISO_EEFvvEEclEv + 28
14 Runner 0x0000000104701cc8 _ZNKSt3__110__function12__value_funcIFvvEEclEv + 60
15 Runner 0x00000001046feed0 _ZNKSt3__18functionIFvvEEclEv + 24
16 Runner 0x00000001046fee90 _ZN8firebase9firestore4util10AsyncQueue15ExecuteBlockingERKNSt3__18functionIFvvEEE + 180
17 Runner 0x0000000104704704 _ZZN8firebase9firestore4util10AsyncQueue4WrapERKNSt3__18functionIFvvEEEENK3$_0clEv + 32
18 Runner 0x00000001047046c4 _ZNSt3__1L8__invokeIRZN8firebase9firestore4util10AsyncQueue4WrapERKNS_8functionIFvvEEEE3$_0JEEEDTclclsr3std3__1E7forwardIT_Efp_Espclsr3std3__1E7forwardIT0_Efp0_EEEOSC_DpOSD_ + 28
19 Runner 0x0000000104704674 _ZNSt3__128__invoke_void_return_wrapperIvE6__callIJRZN8firebase9firestore4util10AsyncQueue4WrapERKNS_8functionIFvvEEEE3$_0EEEvDpOT_ + 28
20 Runner 0x000000010470464c _ZNSt3__110__function12__alloc_funcIZN8firebase9firestore4util10AsyncQueue4WrapERKNS_8functionIFvvEEEE3$_0NS_9allocatorISB_EES7_EclEv + 28
21 Runner 0x0000000104702f0c _ZNSt3__110__function6__funcIZN8firebase9firestore4util10AsyncQueue4WrapERKNS_8functionIFvvEEEE3$_0NS_9allocatorISB_EES7_EclEv + 28
22 Runner 0x0000000104701cc8 _ZNKSt3__110__function12__value_funcIFvvEEclEv + 60
23 Runner 0x00000001046feed0 _ZNKSt3__18functionIFvvEEclEv + 24
24 Runner 0x0000000104b63e48 _ZN8firebase9firestore4util4Task17ExecuteAndReleaseEv + 184
25 Runner 0x000000010478a070 _ZN8firebase9firestore4util19ExecutorLibdispatch11InvokeAsyncEPv + 32
26 libdispatch.dylib 0x00000001183f318c _dispatch_client_callout + 20
27 libdispatch.dylib 0x00000001183fa968 _dispatch_lane_serial_drain + 724
28 libdispatch.dylib 0x00000001183fb580 _dispatch_lane_invoke + 440
29 libdispatch.dylib 0x00000001184070f0 _dispatch_workloop_worker_thread + 1344
30 libsystem_pthread.dylib 0x000000018cbf7714 _pthread_wqthread + 276
31 libsystem_pthread.dylib 0x000000018cbfd9c8 start_wqthread + 8
So... The error has something to do with opening a database... But is a local file? Nothing to do with my Firestore db?
Some permission error? I'm not near an expert in iOS to guess what's happening.
Any help would be appreciated.
Thank you!
Hey, as part of our on-going work for #2582 we managed to repro this issue and it has been resolved in our Firebase Firestore rework (#2913) - which has now been merged into master. We'll look at publishing some prereleases in the next few days. Thank you