firebase / firebase/firebase-ios-sdk
Snapshots get not to be notified to snapshot listener for several seconds
- Dominant language
- C++
- Stars
- 6.7k
- Forks
- 1.8k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 72
Description
### Description
Snapshots get not to be notified to snapshot listener for several seconds.
In my code, I call addSnapshotListener on a firestore collection where 10 documents are added per second and listening for changes. However, after tens of minutes or hours, the snapshot gets not to be notified at all. Then, after a few tens of seconds, they will be notified again.
I use Wi-Fi and keep the app in the foreground while testing.
I believe this is an issue with the firestore iOS SDK, since the documents are increasing on the firestore console even while snapshots are not being notified.
Also, it was already closed, but I found the related issue: [#8935](https://github.com/firebase/firebase-ios-sdk/issues/8935)
The code is roughly as follows:
```swift
class ViewController: UIViewController {
let db = Firestore.firestore()
var listener: ListenerRegistration?
override func viewDidLoad() {
super.viewDidLoad()
listenChatMessages()
}
func listenChatMessages() {
listener = db.collection("my collection path")
.document("my document path")
.collection("my collection path")
.order(by: "id")
.limit(toLast: 50)
.addSnapshotListener { snapShot, error in
// do something
}
}
}
```
### Reproducing the issue
1. Launch the iOS app.
2. Add 10 documents per second to firestore collection. (by using other external script not the iOS app)
3. Wait a few minutes to a few hours with the app running.
Result :
Snapshot gets not to be notified on the listener at all and recovers after a few tens of seconds.
### Firebase SDK Version
10.3.0
### Xcode Version
14.1 (14B47b)
### 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 snippet
```json
{
"pins" : [
{
"identity" : "abseil-cpp-swiftpm",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/abseil-cpp-SwiftPM.git",
"state" : {
"revision" : "583de9bd60f66b40e78d08599cc92036c2e7e4e1",
"version" : "0.20220203.2"
}
},
{
"identity" : "boringssl-swiftpm",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/boringssl-SwiftPM.git",
"state" : {
"revision" : "dd3eda2b05a3f459fc3073695ad1b28659066eab",
"version" : "0.9.1"
}
},
{
"identity" : "firebase-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/firebase-ios-sdk.git",
"state" : {
"branch" : "master",
"revision" : "b109e01e2fa3439e178cbabaefb210f7ddba2a73"
}
},
{
"identity" : "googleappmeasurement",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleAppMeasurement.git",
"state" : {
"revision" : "71eb6700dd53a851473c48d392f00a3ab26699a6",
"version" : "10.1.0"
}
},
{
"identity" : "googledatatransport",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleDataTransport.git",
"state" : {
"revision" : "5056b15c5acbb90cd214fe4d6138bdf5a740e5a8",
"version" : "9.2.0"
}
},
{
"identity" : "googleutilities",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleUtilities.git",
"state" : {
"revision" : "6db6edb48bdd9943426562c7f042a5492de5ba3d",
"version" : "7.10.0"
}
},
{
"identity" : "grpc-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/grpc/grpc-ios.git",
"state" : {
"revision" : "8440b914756e0d26d4f4d054a1c1581daedfc5b6",
"version" : "1.44.3-grpc"
}
},
{
"identity" : "gtm-session-fetcher",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/gtm-session-fetcher.git",
"state" : {
"revision" : "efda500b6d9858d38a76dbfbfa396bd644692e4a",
"version" : "3.0.0"
}
},
{
"identity" : "leveldb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/leveldb.git",
"state" : {
"revision" : "0706abcc6b0bd9cedfbb015ba840e4a780b5159b",
"version" : "1.22.2"
}
},
{
"identity" : "nanopb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/nanopb.git",
"state" : {
"revision" : "819d0a2173aff699fb8c364b6fb906f7cdb1a692",
"version" : "2.30909.0"
}
},
{
"identity" : "promises",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/promises.git",
"state" : {
"revision" : "3e4e743631e86c8c70dbc6efdc7beaa6e90fd3bb",
"version" : "2.1.1"
}
},
{
"identity" : "swift-protobuf",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf.git",
"state" : {
"revision" : "ab3a58b7209a17d781c0d1dbb3e1ff3da306bae8",
"version" : "1.20.3"
}
}
],
"version" : 2
}
```
### If using CocoaPods, the project's Podfile.lock
Expand Podfile.lock snippet
```yml
Replace this line with the contents of your Podfile.lock!
```
Contributor guide
Assessment
This issue has not been assessed yet.