-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EXC_BAD_ACCESS crash when decoding data from Firestore #12620
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
here's the data's representation on firestore, which is empty as expected. Querying the same document on android will result in no issues though. My app has both ios and android. After some experiments, I can confirm that as long as the Data contains some bytes, this crash will not happen. Interestingly it seems like these "some bytes" cannot be empty bytes like Data(count: 1), which still causes the crash |
Thank you for the report. I will look into this as soon as possible. |
Thanks @tom-andersen. May I know if there is any update on this? Our current workaround is to add a check everywhere we use Data to make sure it's not empty when written to Firestore, however, this is lots of unnecessary code to maintain and also error-prone for us, so I'd greatly appreciate it if this issue could be looked into as soon as possible. Thank you in advance. |
Hi @fanwgwg! I took the time to repro the bug. With your good observations and explanation this was quite easy. Thank you! I am working on a fix, but I also want to be sure there aren't any unforeseen consequences. |
Fix will be part of next release. |
@tom-andersen Thank you for the fix! |
Description
Sometimes when decoding data from Firestore, I'd encounter this EXC_BAD_ACCESS crash.
Reproducing the issue
The issue occurs sporadically during data decoding from Firestore. Notably, the data contains a blob/Data field that can occasionally be empty, though not nil. This blob field stores protobuf data. Typically, data assignment to
firestoreModel.data
is performed asprotoBufMessage.serializedData()
. When all values in the protobuf match their default, the serialized data is Data() with 0 bytes.Furthermore, crashes seem to manifest only when decoding documents with
hasPendingWrites = true
within snapshot listeners, indicating local writes. However, once a document has been successfully written to the server, subsequent decoding operations on the same document succeed consistently, whether from snapshot listeners or direct queries.I'm also seeing similar crash reports at
e.g.,
Firebase SDK Version
10.23.0
Xcode Version
15.2
Installation Method
Swift Package Manager
Firebase Product(s)
Firestore
Targeted Platforms
iOS
Relevant Log Output
No response
If using Swift Package Manager, the project's Package.resolved
Expand
Package.resolved
snippetReplace this line with the contents of your Package.resolved.
If using CocoaPods, the project's Podfile.lock
Expand
Podfile.lock
snippetReplace this line with the contents of your Podfile.lock!
The text was updated successfully, but these errors were encountered: