firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.53k stars 1.44k forks source link

MemoryCacheSettings offering empty document on app start where `document.metadata.isFromCache == true` #11204

Closed sergiocampama closed 1 year ago

sergiocampama commented 1 year ago

Description

According to the new Firestore's cache settings API, I should be able to set it to MemoryCacheSettings and expect that on first launch I should get no documents with isFromCache set to true, given that the memory should be empty on app start. What I've found is that if there was local data available from a previous installation of an app, it seems to trigger the RaiseInitialEvent with the local data, completely disregarding the MemoryCache setting.

In fact, after running the app without any data in the simulator, on a second launch the first document will have isFromCache set to true. How can this be if the cache is supposed to be only in memory?

Reproducing the issue

You should be able to reproduce this by using the MemoryCacheSettings in firestore and reading data from a document in the simulator.

Firebase SDK Version

10.9.0

Xcode Version

14.3

Installation Method

CocoaPods

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 Replace this line with the contents of your Package.resolved. ```

If using CocoaPods, the project's Podfile.lock

PODS:

DEPENDENCIES:

SPEC REPOS: trunk:

EXTERNAL SOURCES: Branch: :branch: master :git: REDACTED Stripe: :branch: master :git: REDACTED StripeApplePay: :branch: master :git: REDACTED StripeCore: :branch: master :git: REDACTED StripeFinancialConnections: :branch: master :git: REDACTED StripePayments: :branch: master :git: REDACTED StripePaymentSheet: :branch: master :git: REDACTED StripePaymentsUI: :branch: master :git: REDACTED StripeUICore: :branch: master :git: REDACTED

CHECKOUT OPTIONS: Branch: :commit: REDACTED :git: REDACTED Stripe: :commit: REDACTED :git: REDACTED StripeApplePay: :commit: REDACTED :git: REDACTED StripeCore: :commit: REDACTED :git: REDACTED StripeFinancialConnections: :commit: REDACTED :git: REDACTED StripePayments: :commit: REDACTED :git: REDACTED StripePaymentSheet: :commit: REDACTED :git: REDACTED StripePaymentsUI: :commit: REDACTED :git: REDACTED StripeUICore: :commit: REDACTED :git: REDACTED

SPEC CHECKSUMS: abseil: ebe5b5529fb05d93a8bdb7951607be08b7fa71bc ASN1Swift: 73ba94f1d97c1c1d059d180708ad42845aeac4f9 BetterSegmentedControl: 09607b27861d49cbce48b7673b74f9150a3d371a BoringSSL-GRPC: 3175b25143e648463a56daeaaa499c6cb86dad33 Branch: 1fc81857f63403d4682305088b11270719dca8db CodableFirebase: 0bf201991eeec35eb9fcd987d271ea463cf34a80 DatadogSDK: 7bf8d43caa4a8b2ec633c261eb71155e71ed97d6 Erik: 660e6bc7fe68a0c17e0f50142ae2d8168426c22e FirebaseABTesting: 005b70969e2817e2a1e631e8dba29134a04c0622 FirebaseAnalytics: 5ea0db4893825e7b0149d575352cd838236313dc FirebaseAppCheckInterop: e69dde5cd51b88ee1b4339d6766b691272256f9b FirebaseAuth: 21d5e902fcea44d0d961540fc4742966ae6118cc FirebaseAuthInterop: e53c08e60a02de17d1ab77c5032db8ae22d3a799 FirebaseCore: b68d3616526ec02e4d155166bbafb8eca64af557 FirebaseCoreExtension: d3e9bba2930a8033042112397cd9f006a1bb203d FirebaseCoreInternal: d2b4acb827908e72eca47a9fd896767c3053921e FirebaseCrashlytics: b60329455285aff853e54139d8ddbfe1e5f2b9f9 FirebaseDynamicLinks: 8cb66c4f403aa6ddf86ff3bc3c383a652f344ce9 FirebaseFirestore: 584d0e1b0f7f1666c516c5157ff06e785bd8836f FirebaseFunctions: e8da9bbc42bd6e2089cb5f563dddf6501c68b6f0 FirebaseInstallations: c58489c9caacdbf27d1da60891a87318e20218e0 FirebaseMessaging: 6b7052cc3da7bc8e5f72bef871243e8f04a14eed FirebaseMessagingInterop: aa44064ab90ec4e51bc0fdf7918b6b093459e1d1 FirebaseRemoteConfig: 5ea5834e8c518f377bf1af2d97ebd611914ebf2d FirebaseSessions: 44a6782502eb279a214d4adca20891353278760c FirebaseSharedSwift: c707c543624c3fa6622af2180fa41192084c3914 FirebaseStorage: 075a0c10ec43f24193018c539d65e991db65d9ef FSCalendar: 2d1d0d9398f12d439f55c1fe0f01525b151b8260 Fuse: 48eaf66d0c407c7f8b0ddb168888dc4637e87f14 GoogleAppMeasurement: 373bcbead1bb6a85be7a64d5d8f96284b762ea9c GoogleDataTransport: 8378d1fa8ac49753ea6ce70d65a7cb70ce5f66e6 GoogleUtilities: 9aa0ad5a7bc171f8bae016300bfcfa3fb8425749 GRDB.swift: d2fe6ff28b6d8e5b43104186752d88e94ef0e290 "gRPC-C++": 9675f953ace2b3de7c506039d77be1f2e77a8db2 gRPC-Core: 943e491cb0d45598b0b0eb9e910c88080369290b GTMSessionFetcher: e8647203b65cee28c5f73d0f473d096653945e72 Intercom: 43bfacc55b1c93cce9ec569833696d3f15678430 Kanna: 01cfbddc127f5ff0963692f285fcbc8a9d62d234 KeychainAccess: c0c4f7f38f6fc7bbe58f5702e25f7bd2f65abf51 leveldb-library: f03246171cce0484482ec291f88b6d563699ee06 Libuv-gRPC: 55e51798e14ef436ad9bc45d12d43b77b49df378 nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431 Plaid: 7d340abeadb46c7aa1a91f896c5b22395a31fcf2 PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef PromisesSwift: cf9eb58666a43bbe007302226e510b16c1e10959 Resolver: 68984624572763018fd8ec7b8e3e8df0e3b6bba5 Stripe: cc895392856dc7f401119a612e31f020b97cb8d1 StripeApplePay: 7e43d6b4b9f18e922ba683e549f199a4f6db6fde StripeCore: 6da916796f87ab91f3dae1d78a93602465964cbc StripeFinancialConnections: 312fbe670871c7a3227dce0e092d7d5bf209f75e StripePayments: 7651a56a2a7fe320e5e8b1cb0c2e881536b75021 StripePaymentSheet: 8803a9debac99541649fc18df4f4f9bdb72354c5 StripePaymentsUI: 50270053a2e348308d13ba4bc5082df789cb9b64 StripeUICore: 7727bbfd146f5c4a8dca7f9be241e2d0cdb70310 TPInAppReceipt: 5f9eb3ebc7e13b9427a7f42aa9657c005ffaf34c UICountingLabel: faf890b505d96312e324a86718f031fafffb0ccb

PODFILE CHECKSUM: e3b0e62b33bfbbac90f6fc4d8d80606b8fd41c4b

COCOAPODS: 1.12.0

google-oss-bot commented 1 year ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

MarkDuckworth commented 1 year ago

@sergiocampama, I attempted to reproduce the issue based on what you described, but I was unable to do so. Can you provide code snippets and additional reproduction steps that will help us better understand how to reproduce this?

It's also not clear from your post, but if you are using snapshot listeners, are you possibly seeing a latency compensated snapshot (from cache) due to some other part of you app adding a doc?

google-oss-bot commented 1 year ago

Hey @sergiocampama. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 1 year ago

Since there haven't been any recent updates here, I am going to close this issue.

@sergiocampama if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.