Skip to content

Conversation

Crebs
Copy link
Contributor

@Crebs Crebs commented Aug 26, 2025

Addresses potential data races and thread safety issues in the Salesforce Mobile SDK Core and Analytics modules. The changes ensure that shared mutable state is accessed in a thread-safe manner and that account management operations are properly synchronized.

SApp Change: https://git.soma.salesforce.com/iOS/SalesforceMobileSDK-iOS/pull/921

@Crebs Crebs closed this Aug 26, 2025
@Crebs Crebs reopened this Aug 26, 2025
Copy link

codecov bot commented Aug 26, 2025

Codecov Report

❌ Patch coverage is 80.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.17%. Comparing base (aa1bbeb) to head (2690c1a).
⚠️ Report is 4 commits behind head on dev.

Files with missing lines Patch % Lines
...SDKCore/Classes/UserAccount/SFUserAccountManager.m 63.63% 4 Missing ⚠️

❌ Your patch check has failed because the patch coverage (63.63%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #3905      +/-   ##
==========================================
+ Coverage   63.09%   63.17%   +0.07%     
==========================================
  Files         250      250              
  Lines       22488    22517      +29     
==========================================
+ Hits        14189    14225      +36     
+ Misses       8299     8292       -7     
Components Coverage Δ
Analytics 71.01% <100.00%> (+0.22%) ⬆️
Common 70.49% <ø> (ø)
Core 53.45% <19.51%> (+0.13%) ⬆️
SmartStore 73.66% <ø> (ø)
MobileSync 87.66% <ø> (ø)
Files with missing lines Coverage Δ
...ceAnalytics/Classes/Store/SFSDKEventStoreManager.m 84.67% <100.00%> (+0.51%) ⬆️
...SDKCore/Classes/UserAccount/SFUserAccountManager.m 36.51% <63.63%> (-0.11%) ⬇️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:self.storeDirectory error:nil];
if (files) {
self.numStoredEvents = files.count;
@synchronized (self.eventCountMutex) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You just created the object you synchronize on at line 71, so how will it keep other threads out?
Should you do @synchronized ([self class]) instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or use a static member:

static NSObject *initMutex;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
    initMutex = [[NSObject alloc] init];
});

@synchronized (initMutex) {
    // initialization code
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah. Good point. Let me look at what the SApp did again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants