diff --git a/FirebaseRemoteConfig/CHANGELOG.md b/FirebaseRemoteConfig/CHANGELOG.md index f1b25939183..36ced2c9a19 100644 --- a/FirebaseRemoteConfig/CHANGELOG.md +++ b/FirebaseRemoteConfig/CHANGELOG.md @@ -1,3 +1,7 @@ +# 12.2.0 +- [fixed] Fixed a race condition that could lead to a crash during network + session recreation. (#15087) + # 12.0.0 - [added] Improved how the SDK handles real-time requests when a Firebase project has exceeded its available quota for real-time services. diff --git a/FirebaseRemoteConfig/Sources/FIRRemoteConfig.m b/FirebaseRemoteConfig/Sources/FIRRemoteConfig.m index 443265800b2..258eb362fe7 100644 --- a/FirebaseRemoteConfig/Sources/FIRRemoteConfig.m +++ b/FirebaseRemoteConfig/Sources/FIRRemoteConfig.m @@ -700,6 +700,8 @@ - (FIRRemoteConfigSettings *)configSettings { dispatch_sync(_queue, ^{ minimumFetchInterval = self->_settings.minimumFetchInterval; fetchTimeout = self->_settings.fetchTimeout; + // The NSURLSession needs to be recreated whenever the fetch timeout may be updated. + [_configFetch recreateNetworkSession]; }); FIRLogDebug(kFIRLoggerRemoteConfig, @"I-RCN000066", @"Successfully read configSettings. Minimum Fetch Interval:%f, " @@ -708,8 +710,6 @@ - (FIRRemoteConfigSettings *)configSettings { FIRRemoteConfigSettings *settings = [[FIRRemoteConfigSettings alloc] init]; settings.minimumFetchInterval = minimumFetchInterval; settings.fetchTimeout = fetchTimeout; - /// The NSURLSession needs to be recreated whenever the fetch timeout may be updated. - [_configFetch recreateNetworkSession]; return settings; } @@ -721,7 +721,7 @@ - (void)setConfigSettings:(FIRRemoteConfigSettings *)configSettings { self->_settings.minimumFetchInterval = configSettings.minimumFetchInterval; self->_settings.fetchTimeout = configSettings.fetchTimeout; - /// The NSURLSession needs to be recreated whenever the fetch timeout may be updated. + // The NSURLSession needs to be recreated whenever the fetch timeout may be updated. [self->_configFetch recreateNetworkSession]; FIRLogDebug(kFIRLoggerRemoteConfig, @"I-RCN000067", @"Successfully set configSettings. Minimum Fetch Interval:%f, " diff --git a/FirebaseRemoteConfig/Sources/RCNConfigFetch.m b/FirebaseRemoteConfig/Sources/RCNConfigFetch.m index 85e86f85e36..1df80385972 100644 --- a/FirebaseRemoteConfig/Sources/RCNConfigFetch.m +++ b/FirebaseRemoteConfig/Sources/RCNConfigFetch.m @@ -113,6 +113,7 @@ - (instancetype)initWithContent:(RCNConfigContent *)content } /// Force a new NSURLSession creation for updated config. +/// - Warning: This API is **not** thread-safe. - (void)recreateNetworkSession { if (_fetchSession) { [_fetchSession invalidateAndCancel];