Skip to content

Commit c7ae11d

Browse files
committed
fix(config): Address race condition from concurrent network session recreation
Fixes #15087
1 parent e176f01 commit c7ae11d

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

FirebaseRemoteConfig/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 12.2.0
2+
- [fixed] Fixed a race condition that could lead to a crash during network
3+
session recreation. (#15087)
4+
15
# 12.0.0
26
- [added] Improved how the SDK handles real-time requests when a Firebase
37
project has exceeded its available quota for real-time services.

FirebaseRemoteConfig/Sources/FIRRemoteConfig.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,8 @@ - (FIRRemoteConfigSettings *)configSettings {
700700
dispatch_sync(_queue, ^{
701701
minimumFetchInterval = self->_settings.minimumFetchInterval;
702702
fetchTimeout = self->_settings.fetchTimeout;
703+
// The NSURLSession needs to be recreated whenever the fetch timeout may be updated.
704+
[_configFetch recreateNetworkSession];
703705
});
704706
FIRLogDebug(kFIRLoggerRemoteConfig, @"I-RCN000066",
705707
@"Successfully read configSettings. Minimum Fetch Interval:%f, "
@@ -708,8 +710,6 @@ - (FIRRemoteConfigSettings *)configSettings {
708710
FIRRemoteConfigSettings *settings = [[FIRRemoteConfigSettings alloc] init];
709711
settings.minimumFetchInterval = minimumFetchInterval;
710712
settings.fetchTimeout = fetchTimeout;
711-
/// The NSURLSession needs to be recreated whenever the fetch timeout may be updated.
712-
[_configFetch recreateNetworkSession];
713713
return settings;
714714
}
715715

@@ -721,7 +721,7 @@ - (void)setConfigSettings:(FIRRemoteConfigSettings *)configSettings {
721721

722722
self->_settings.minimumFetchInterval = configSettings.minimumFetchInterval;
723723
self->_settings.fetchTimeout = configSettings.fetchTimeout;
724-
/// The NSURLSession needs to be recreated whenever the fetch timeout may be updated.
724+
// The NSURLSession needs to be recreated whenever the fetch timeout may be updated.
725725
[self->_configFetch recreateNetworkSession];
726726
FIRLogDebug(kFIRLoggerRemoteConfig, @"I-RCN000067",
727727
@"Successfully set configSettings. Minimum Fetch Interval:%f, "

FirebaseRemoteConfig/Sources/RCNConfigFetch.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ - (instancetype)initWithContent:(RCNConfigContent *)content
113113
}
114114

115115
/// Force a new NSURLSession creation for updated config.
116+
/// - Warning: This API is **not** thread-safe.
116117
- (void)recreateNetworkSession {
117118
if (_fetchSession) {
118119
[_fetchSession invalidateAndCancel];

0 commit comments

Comments
 (0)