Closed kaidotarma closed 2 months ago
Might be related to https://github.com/GitLiveApp/firebase-kotlin-sdk/issues/551
Might be related to https://github.com/GitLiveApp/firebase-kotlin-sdk/issues/554
Do you add a failing test for this? Or a minimal reproducer to this issue?
@nbransby here is a minimal reproducer repo: https://bitbucket.org/kaidotarma/firestore_example/src/master/
The usage is here: https://bitbucket.org/kaidotarma/firestore_example/src/5f1bf79a42e34a4c706d4221350048a5ea282f9a/shared/src/commonMain/kotlin/App.kt#lines-32
Last commit has the crash enabled: https://bitbucket.org/kaidotarma/firestore_example/commits/5f1bf79a42e34a4c706d4221350048a5ea282f9a
Android works with both versions 1.12.0 and 1.13.0. iOS works with version 1.12.0, but crashes with 1.13.0 - when enableNetwork or disableNetwork is clicked.
Error:
Terminating app due to uncaught exception 'FIRIllegalStateException', reason: 'Firestore instance has already been started and its settings can no longer be changed. You can only set settings before calling any other methods on a Firestore instance.'
First throw call stack:
(
0 CoreFoundation 0x00007ff80049928d exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007ff800063894 objc_exception_throw + 48
2 My application 0x0000000107d74ffc _ZN8firebase9firestore4util16ObjcThrowHandlerENS1_13ExceptionTypeEPKcS4_iRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE + 106
3 My application 0x0000000107d74b0e _ZN8firebase9firestore4util5ThrowENS1_13ExceptionTypeEPKcS4_iRKNSt3112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE + 10
4 My application 0x0000000107d860dd ZN8firebase9firestore4util17ThrowIllegalStateIJEEEvPKcDpRKT + 47
5 My application 0x0000000107d86090 _ZN8firebase9firestore3api9Firestore12set_settingsERKNS1_8SettingsE + 166
6 My application 0x0000000107da7d1e -[FIRFirestore setSettings:] + 130
7 My application 0x000000010760c30a kfun:dev.gitlive.firebase.firestore.internal.NativeFirebaseFirestoreWrapper#
+1 Also seeing this error on iOS. But not on Android
Looks like the same issue happens with terminate() and clearPersistence(). Updated the sample project to include these functions.
PS: clearPersistence() is expected to fail (with another error) if we don't run terminate() before that - but currently receives the same error.
@nbransby Bump :)
@Daeda88 could this be to do with the changes made in https://github.com/GitLiveApp/firebase-kotlin-sdk/pull/450 ?
Could be, I'll have a look asap
@kaidotarma can you share a minimum reproducible code. Enablling/disabling the network works fine for me in a test case. The only reason I can see it not working is if you apply settings after changing the network state. This would probably not have crashed in 1.12 or lower, but that was actually hiding the settings not being applied at all.
@Daeda88 did you try running: https://bitbucket.org/kaidotarma/firestore_example/src/master/
Missed that, lets have a look
Okay, I understand the problem, trying to get a fix asap.
Looks like version 1.13.0 created a new issue where: Firebase.firestore.enableNetwork() or Firebase.firestore.disableNetwork() would cause an app to crash:
*** Terminating app due to uncaught exception 'FIRIllegalStateException', reason: 'Firestore instance has already been started and its settings can no longer be changed. You can only set settings before calling any other methods on a Firestore instance.'
The reason seems to be that firestoreSettings gets recreated when this function is called.
This was not an issue in version 1.12.0. The issue does not reproduce in Android app (1.13.0).