Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions FirebaseRemoteConfig/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Unreleased
- [fixed] Fix Data Race on gIsNewDatabase. (#14715)

# 12.6.0
- [fixed] Fixed a bug where Remote Config does not work after a restore
of a previous backup of the device. (#14459)
Expand Down
7 changes: 5 additions & 2 deletions FirebaseRemoteConfig/Sources/RCNConfigDBManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,15 @@ @interface RCNConfigDBManager () {

@implementation RCNConfigDBManager

+ (void)load {
gIsNewDatabaseQueue = dispatch_queue_create("com.google.FirebaseRemoteConfig.gIsNewDatabase",
DISPATCH_QUEUE_SERIAL);
}

+ (instancetype)sharedInstance {
static dispatch_once_t onceToken;
static RCNConfigDBManager *sharedInstance;
dispatch_once(&onceToken, ^{
gIsNewDatabaseQueue = dispatch_queue_create("com.google.FirebaseRemoteConfig.gIsNewDatabase",
DISPATCH_QUEUE_SERIAL);
sharedInstance = [[RCNConfigDBManager alloc] init];
});
return sharedInstance;
Expand Down
41 changes: 41 additions & 0 deletions FirebaseRemoteConfig/Tests/Unit/RCNConfigDBManagerTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import <XCTest/XCTest.h>
#import "FirebaseRemoteConfig/Sources/RCNConfigDBManager.h"

@interface RCNConfigDBManagerTests : XCTestCase
@end

@implementation RCNConfigDBManagerTests

- (void)testIsNewDatabaseThreadSafety {
RCNConfigDBManager *dbManager = [RCNConfigDBManager sharedInstance];
XCTestExpectation *expectation =
[self expectationWithDescription:@"Concurrent access to isNewDatabase"];
expectation.expectedFulfillmentCount = 100;

for (int i = 0; i < 100; i++) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[dbManager isNewDatabase];
[expectation fulfill];
});
}

[self waitForExpectationsWithTimeout:5.0 handler:nil];
}

@end
Loading