firebase / firebase-ios-sdk

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

RemoteConfig `-fetchAndActivateWithCompletionHandler:` reports `SuccessFetchedFromRemote` despite using cached data #11895

Open empowerMax opened 11 months ago

empowerMax commented 11 months ago

Description

When RemoteConfig's fetchAndActivate's activation succeeds, it only examine the activation error when considering if the fetch status was FIRRemoteConfigFetchAndActivateStatusSuccessUsingPreFetchedData or FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote.

This means whenever we call fetchAndActivate, regardless of the fetch result, we can't distinguish if the data actually from the remote or not.

Screenshot 2023-10-05 at 4 46 48 PM

Reproducing the issue

Hey sorry but I don't want to provide a full example (where I'd need to wire it up to a Firebase project). I guess it'd look something like:

FirebaseApp.configure()
let remoteConfig = RemoteConfig.remoteConfig()
// Set some long ish fetch time in seconds
let remoteConfigSettings = RemoteConfigSettings()
remoteConfigSettings.minimumFetchInterval = 1000
remoteConfig.configSettings = remoteConfigSettings
remoteConfig.fetchAndActivate { status, _ in
    print(status.rawValue)
    remoteConfig.fetchAndActivate { status, _ in
        print(status.rawValue)
    }
}

This prints 0 and then 0, whereas I'd expect 0 and then 1 Recall that:

    case successFetchedFromRemote = 0
    /// The fetch and activate succeeded from already fetched but yet unexpired config data. You can
    /// control this using minimumFetchInterval property in FIRRemoteConfigSettings.
    case successUsingPreFetchedData = 1

Perhaps I'm holding it wrong! Let me know :)

Firebase SDK Version

10.13.0

Xcode Version

15.0

Installation Method

Swift Package Manager

Firebase Product(s)

Remote Config

Targeted Platforms

iOS, tvOS, watchOS, macOS

Relevant Log Output

[Firebase/Crashlytics] Version 10.13.0
10.13.0 - [FirebaseCore][I-COR000001] Configuring the default app.
10.13.0 - [FirebaseCore][I-COR000033] Data Collection flag is not set.
10.13.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseSessions][I-SES000000] Version 10.13.0. Expecting subscriptions from: [Crashlytics, Performance]
10.13.0 - [FirebasePerformance][I-PRF100001] Firebase Performance Monitoring is successfully initialized! In a minute, visit the Firebase console to view your data: ****
10.13.0 - [FirebasePerformance][I-PRF100001] Registering Sessions SDK subscription for session data
10.13.0 - [FirebaseSessions][I-SES000000] Registering Sessions SDK subscriber with name: Performance, data collection enabled: true
10.13.0 - [FirebasePerformance][I-PRF900002] Session Id changed - ****
10.13.0 - [FirebaseCrashlytics][I-CLS000000] [Crashlytics] Running on iOS Simulator (iPhone), 17.0.0 (23A344)
10.13.0 - [FirebaseCrashlytics][I-CLS000000] Registering Sessions SDK subscription for session data
10.13.0 - [FirebaseSessions][I-SES000000] Registering Sessions SDK subscriber with name: Crashlytics, data collection enabled: true
10.13.0 - [FirebaseCrashlytics][I-CLS000000] Session ID changed: ****
10.13.0 - [FirebaseCrashlytics][I-CLS000000] Root: ***
10.13.0 - [FirebaseCrashlytics][I-CLS000000] [Crashlytics:Crash:Reports:Event] Registered Firebase Analytics event listener to receive breadcrumb logs
10.13.0 - [FirebaseCrashlytics][I-CLS000000] Automatic data collection is enabled.
10.13.0 - [FirebaseCrashlytics][I-CLS000000] Unsent reports will be uploaded at startup
10.13.0 - [FirebaseRemoteConfig][I-RCN000062] Loading database at path ****/Library/Application Support/Google/RemoteConfig/RemoteConfig.sqlite3
10.13.0 - [FirebasePerformance][I-PRF100009] Logging network request trace - *****
10.13.0 - [FirebaseRemoteConfig][I-RCN000067] Successfully set configSettings. Minimum Fetch Interval:1000.000000, Fetch timeout:60.000000
10.13.0 - [FirebasePerformance][I-PRF300005] URL length exceeds limits, truncating recorded URL - *****
10.13.0 - [FirebasePerformance][I-PRF300005] URL length exceeds limits, truncating recorded URL - *****
10.13.0 - [FirebasePerformance][I-PRF100009] Setting attribute traceParentId to 731d85e92d56b17f on trace *****
10.13.0 - [FirebaseAnalytics][I-ACS024000] Debug mode is on
10.13.0 - [FirebaseAnalytics][I-ACS023007] Analytics v.10.13.0 started
10.13.0 - [FirebaseAnalytics][I-ACS023008] To disable debug logging set the following application argument: -noFIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
10.13.0 - [FirebaseAnalytics][I-ACS023009] Debug logging enabled
10.13.0 - [FirebaseAnalytics][I-ACS023207] To enable verbose logging set the following application argument: -FIRAnalyticsVerboseLoggingEnabled (see http://goo.gl/RfcP7r)
10.13.0 - [FirebaseRemoteConfig][I-RCN000051] Returning cached data.
10.13.0 - [FirebasePerformance][I-PRF100009] Setting attribute traceParentId to 731d85e92d56b17f on trace remote_config_fetch_from_network
10.13.0 - [FirebaseAnalytics][I-ACS002002] APMExperimentAlarm scheduled to fire in approx. (s): 4432.630842924118
10.13.0 - [FirebaseAnalytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
10.13.0 - [FirebaseAnalytics][I-ACS029014] Successfully parsed a configuration. Version: 1692835047615698
10.13.0 - [FirebaseAnalytics][I-ACS023016] Analytics is ready to receive events
10.13.0 - [FirebaseRemoteConfig][I-RCN000069] Most recently fetched config is already activated.
Finished firebase fetch)
10.13.0 - [FirebasePerformance][I-PRF100009] Incrementing metric _fsapc to 0 on trace _fs
10.13.0 - [FirebasePerformance][I-PRF100009] Logging trace metric - _as 3639.7060ms. In a minute, visit the Firebase console to view your data: *****
10.13.0 - [FirebasePerformance][I-PRF300005] URL length exceeds limits, truncating recorded URL - ****
10.13.0 - [FirebasePerformance][I-PRF100009] Logging trace metric - remote_config_fetch_from_network 240.3780ms. In a minute, visit the Firebase console to view your data: ****
10.13.0 - [FirebasePerformance][I-PRF100009] Logging trace metric - _fs 150.6890ms. In a minute, visit the Firebase console to view your data: ****
10.13.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseSessions][I-SES000000] Data Collection is enabled for at least one Subscriber
10.13.0 - [FirebaseSessions][I-SES000000] [Settings] Cache is not expired, no fetch will be made.
10.13.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseAnalytics][I-ACS032014] AdServices framework is not linked. Search Ad Attribution Reporter is disabled.
10.13.0 - [FirebaseAnalytics][I-ACS002002] Measurement timer scheduled to fire in approx. (s): -495.5942499637604
10.13.0 - [FirebaseAnalytics][I-ACS002002] Engagement timer scheduled to fire in approx. (s): 3600
10.13.0 - [FirebaseAnalytics][I-ACS023012] Analytics collection enabled
10.13.0 - [FirebaseAnalytics][I-ACS023220] Analytics screen reporting is enabled. Call Analytics.logEvent(AnalyticsEventScreenView, parameters: [...]) to log a screen view event. To disable automatic screen reporting, set the flag FirebaseAutomaticScreenReportingEnabled to NO (boolean) in the Info.plist
10.13.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseSessions][I-SES000000] Logging events using fast QOS due to running on a simulator
10.13.0 - [FirebaseSessions][I-SES000000] Successfully logged Session Start event to GoogleDataTransport
10.13.0 - [FirebaseSessions][I-SES000000] Successfully logged Session Start event
10.13.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseAnalytics][I-ACS002001] Measurement timer fired
10.13.0 - [FirebaseAnalytics][I-ACS002003] Measurement timer canceled
10.13.0 - [FirebaseAnalytics][I-ACS023087] User property set. Name, value: lifetime_user_engagement (_lte), 1329151
10.13.0 - [FirebaseAnalytics][I-ACS023087] User property set. Name, value: session_user_engagement (_se), 440747
10.13.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseAnalytics][I-ACS012018] Saving bundle. size (bytes): 465
10.13.0 - [FirebaseAnalytics][I-ACS023116] Bundle added to the upload queue. BundleID, timestamp (ms): 60, 1696476706676
10.13.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseAnalytics][I-ACS012018] Saving bundle. size (bytes): 475
10.13.0 - [FirebaseAnalytics][I-ACS023116] Bundle added to the upload queue. BundleID, timestamp (ms): 61, 1696477202934
10.13.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseAnalytics][I-ACS023039] Measurement data sent to network. Timestamp (ms), data: 1696477204250, <APMPBMeasurementBatch: 0x600000025160>
10.13.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseAnalytics][I-ACS023044] Successful upload. Got network response. Code, size: 204, -1
10.13.0 - [FirebaseAnalytics][I-ACS002002] Measurement timer scheduled to fire in approx. (s): -0.9895179271697998
10.13.0 - [FirebaseAnalytics][I-ACS002003] Measurement timer canceled
10.13.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
10.13.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
```json ```

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
```yml Replace this line with the contents of your Podfile.lock! ```
google-oss-bot commented 11 months ago

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

adamsousa commented 7 months ago

Any updates on this? Encountering this issue as well.

mandeep-vestel commented 3 weeks ago

I am also facing this issue. Is there any update on this? Firebase version 10.29.0(SPM)