datatheorem / datatheorem/TrustKit
Performing I/O on the main thread can cause slow launches.
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Objective-C
- Stars
- 2.1k
- Forks
- 381
- PR merge metrics
- No merged PRs in 30d
Description
Xcode is producing many warnings re performance could be slow.
TSKBackgroundReporter.m
The else block below.
else {
// Get the vendor identifier
_appVendorId = identifier_for_vendor();
// We're not running unit tests - use a background session
// AppleDoc (currently 10.3) state that multiple background sessions with the same
// identifier should never be created, so ensure that cannot happen by creating
// a unique ID per instance.
NSString *backgroundSessionId = [NSString stringWithFormat:kTSKBackgroundSessionIdentifierFormat,
_appBundleId, [[NSUUID UUID] UUIDString]];
NSURLSessionConfiguration *backgroundConfiguration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:backgroundSessionId];
backgroundConfiguration.discretionary = YES;
backgroundConfiguration.sharedContainerIdentifier = sharedContainerIdentifier;
#if TARGET_OS_IPHONE
// iOS-only settings
// Do not wake up the App after completing the upload
backgroundConfiguration.sessionSendsLaunchEvents = NO;
#if !TARGET_OS_TV && !TARGET_OS_WATCH
// on iOS (but not tvOS or watchOS), enable multipath
backgroundConfiguration.multipathServiceType = NSURLSessionMultipathServiceTypeHandover;
#endif
#endif
// We have to use a delegate as background sessions can't use completion handlers
_backgroundSession = [NSURLSession sessionWithConfiguration:backgroundConfiguration
delegate:self
delegateQueue:nil];
}
This is the below 2 lines.
NSURLSessionConfiguration *backgroundConfiguration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:backgroundSessionId]_backgroundSession = [NSURLSession sessionWithConfiguration:backgroundConfiguration
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in TSKBackgroundReporter.m at the else block and inspect the two NSURLSession setup lines identified in the issue. Determine how their initialization can avoid main-thread I/O, then verify that Xcode no longer reports the launch-performance warning while background session setup remains functional.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, objective-c
- Domain
- mobile, performance
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100