datatheorem / datatheorem/TrustKit

Performing I/O on the main thread can cause slow launches.

Open
#340 2 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.