在 iOS 上注销和登录 firebase 身份验证后,Firestore 调用 setData 将不会进入完成块
Firestore call setData will not enter completion block after signOut and signIn firebase auth on iOS
在 iOS (swift) 中使用 Firebase SDK
使用 Firebase (4.10.0)
使用 FirebaseAuth (4.4.4)
使用 FirebaseCore (4.0.16)
使用 FirebaseFirestore (0.10.2)
时出现问题
- 登录(匿名或凭据)
- 退出
- 登录
- 调用FIRDocumentReference.setData然后setData的完成块将永远不会被调用
如果
就不会出现问题
- 退出
- 终止应用程序
- 登录
- 调用FIRDocumentReference.setData一切正常
import UIKit
import Firebase
class ViewController: UIViewController {
let mEmail = "tester@xxxxx.com"
let mPassword = "xxxxx"
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func clickSignIn(_ sender: Any) {
print("clickSignIn")
Auth.auth().signIn(withEmail: mEmail, password: mPassword) { (user, error) in
print("user:", user ?? "no user")
print("error:", error ?? "no error")
}
}
@IBAction func clickSignOut(_ sender: Any) {
print("clickSignOut")
do {
try Auth.auth().signOut()
} catch {
print("can't signOut")
}
print(Auth.auth().currentUser ?? "no user")
}
@IBAction func clickSetData(_ sender: Any) {
print("clickSetData")
let ref = Firestore.firestore().document("tests/test_1")
let data = ["text": "xxxxx"]
ref.setData(data, options: SetOptions.merge()) { (e) in
if (e == nil) {
print("setData complete")
} else {
print("setData error:", e ?? "no error")
}
}
}
}
有时它也会导致崩溃
*** Assertion failure in -[FSTLevelDBMutationQueue removeMutationBatches:group:], third_party/firebase/ios/Source/Firestore/Source/Local/FSTLevelDBMutationQueue.mm:536
2018-03-08 03:56:22.364597+0700 setdata-bug[30957:9502011] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'FIRESTORE INTERNAL ASSERTION FAILED: Mutation batch [mutation: userID=\^X8I\^G\^A batchID=5] not found; found [mutation: userID=P¸P››\^? batchID=0]'
*** First throw call stack:
(
0 CoreFoundation 0x000000010a05c12b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001096f0f41 objc_exception_throw + 48
2 CoreFoundation 0x000000010a0612f2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000109191d69 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 setdata-bug 0x0000000107333229 -[FSTLevelDBMutationQueue removeMutationBatches:group:] + 1967
5 setdata-bug 0x000000010733fc8e -[FSTLocalStore removeMutationBatches:group:] + 885
6 setdata-bug 0x000000010733f753 -[FSTLocalStore releaseBatchResults:group:remoteDocuments:] + 537
7 setdata-bug 0x000000010733c4f7 -[FSTLocalStore acknowledgeBatchWithResult:] + 571
8 setdata-bug 0x0000000107321e36 -[FSTSyncEngine applySuccessfulWriteWithResult:] + 166
9 setdata-bug 0x0000000107363325 -[FSTRemoteStore writeStreamDidReceiveResponseWithVersion:mutationResults:] + 300
10 setdata-bug 0x0000000107373069 -[FSTWriteStream handleStreamMessage:] + 847
11 setdata-bug 0x00000001073712da -[FSTStream writeValue:] + 477
12 setdata-bug 0x000000010736ee73 -[FSTCallbackFilter writeValue:] + 84
13 RxLibrary 0x00000001086065d6 __57-[GRXConcurrentWriteable enqueueValue:completionHandler:]_block_invoke + 86
14 libdispatch.dylib 0x000000010b0cd2f7 _dispatch_call_block_and_release + 12
15 libdispatch.dylib 0x000000010b0ce33d _dispatch_client_callout + 8
16 libdispatch.dylib 0x000000010b0d6855 _dispatch_queue_serial_drain + 1162
17 libdispatch.dylib 0x000000010b0d71ea _dispatch_queue_invoke + 336
18 libdispatch.dylib 0x000000010b0d2f7c _dispatch_queue_override_invoke + 733
19 libdispatch.dylib 0x000000010b0da102 _dispatch_root_queue_drain + 772
20 libdispatch.dylib 0x000000010b0d9da0 _dispatch_worker_thread3 + 132
21 libsystem_pthread.dylib 0x000000010d8051ca _pthread_wqthread + 1387
22 libsystem_pthread.dylib 0x000000010d804c4d start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
经 google 工程师确认,我发现的问题是最新 iOS SDK 版本 (4.10.0) 中的一个已知错误。好消息是,它已经在以下拉取请求中得到修复:890、893。在修复程序公开发布之前,Google 建议我们暂时降级到 4.9.0 版本。目前无法分享任何细节或时间表,因此请密切关注我们的发行说明以了解任何更新。
在 iOS (swift) 中使用 Firebase SDK
使用 Firebase (4.10.0)
使用 FirebaseAuth (4.4.4)
使用 FirebaseCore (4.0.16)
使用 FirebaseFirestore (0.10.2)
时出现问题
- 登录(匿名或凭据)
- 退出
- 登录
- 调用FIRDocumentReference.setData然后setData的完成块将永远不会被调用
如果
就不会出现问题- 退出
- 终止应用程序
- 登录
- 调用FIRDocumentReference.setData一切正常
import UIKit
import Firebase
class ViewController: UIViewController {
let mEmail = "tester@xxxxx.com"
let mPassword = "xxxxx"
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func clickSignIn(_ sender: Any) {
print("clickSignIn")
Auth.auth().signIn(withEmail: mEmail, password: mPassword) { (user, error) in
print("user:", user ?? "no user")
print("error:", error ?? "no error")
}
}
@IBAction func clickSignOut(_ sender: Any) {
print("clickSignOut")
do {
try Auth.auth().signOut()
} catch {
print("can't signOut")
}
print(Auth.auth().currentUser ?? "no user")
}
@IBAction func clickSetData(_ sender: Any) {
print("clickSetData")
let ref = Firestore.firestore().document("tests/test_1")
let data = ["text": "xxxxx"]
ref.setData(data, options: SetOptions.merge()) { (e) in
if (e == nil) {
print("setData complete")
} else {
print("setData error:", e ?? "no error")
}
}
}
}
有时它也会导致崩溃
*** Assertion failure in -[FSTLevelDBMutationQueue removeMutationBatches:group:], third_party/firebase/ios/Source/Firestore/Source/Local/FSTLevelDBMutationQueue.mm:536
2018-03-08 03:56:22.364597+0700 setdata-bug[30957:9502011] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'FIRESTORE INTERNAL ASSERTION FAILED: Mutation batch [mutation: userID=\^X8I\^G\^A batchID=5] not found; found [mutation: userID=P¸P››\^? batchID=0]'
*** First throw call stack:
(
0 CoreFoundation 0x000000010a05c12b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001096f0f41 objc_exception_throw + 48
2 CoreFoundation 0x000000010a0612f2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000109191d69 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 setdata-bug 0x0000000107333229 -[FSTLevelDBMutationQueue removeMutationBatches:group:] + 1967
5 setdata-bug 0x000000010733fc8e -[FSTLocalStore removeMutationBatches:group:] + 885
6 setdata-bug 0x000000010733f753 -[FSTLocalStore releaseBatchResults:group:remoteDocuments:] + 537
7 setdata-bug 0x000000010733c4f7 -[FSTLocalStore acknowledgeBatchWithResult:] + 571
8 setdata-bug 0x0000000107321e36 -[FSTSyncEngine applySuccessfulWriteWithResult:] + 166
9 setdata-bug 0x0000000107363325 -[FSTRemoteStore writeStreamDidReceiveResponseWithVersion:mutationResults:] + 300
10 setdata-bug 0x0000000107373069 -[FSTWriteStream handleStreamMessage:] + 847
11 setdata-bug 0x00000001073712da -[FSTStream writeValue:] + 477
12 setdata-bug 0x000000010736ee73 -[FSTCallbackFilter writeValue:] + 84
13 RxLibrary 0x00000001086065d6 __57-[GRXConcurrentWriteable enqueueValue:completionHandler:]_block_invoke + 86
14 libdispatch.dylib 0x000000010b0cd2f7 _dispatch_call_block_and_release + 12
15 libdispatch.dylib 0x000000010b0ce33d _dispatch_client_callout + 8
16 libdispatch.dylib 0x000000010b0d6855 _dispatch_queue_serial_drain + 1162
17 libdispatch.dylib 0x000000010b0d71ea _dispatch_queue_invoke + 336
18 libdispatch.dylib 0x000000010b0d2f7c _dispatch_queue_override_invoke + 733
19 libdispatch.dylib 0x000000010b0da102 _dispatch_root_queue_drain + 772
20 libdispatch.dylib 0x000000010b0d9da0 _dispatch_worker_thread3 + 132
21 libsystem_pthread.dylib 0x000000010d8051ca _pthread_wqthread + 1387
22 libsystem_pthread.dylib 0x000000010d804c4d start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
经 google 工程师确认,我发现的问题是最新 iOS SDK 版本 (4.10.0) 中的一个已知错误。好消息是,它已经在以下拉取请求中得到修复:890、893。在修复程序公开发布之前,Google 建议我们暂时降级到 4.9.0 版本。目前无法分享任何细节或时间表,因此请密切关注我们的发行说明以了解任何更新。