Skip to content

Commit

Permalink
fix: Initialize Kits in Background Thread (#308)
Browse files Browse the repository at this point in the history
* refactor: Initialize Kits in Background Thread
  • Loading branch information
BrandonStalnaker committed Nov 4, 2024
1 parent 84a1275 commit 38d3ea7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion mParticle-Apple-SDK/Kits/MPKitContainer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,13 @@ - (void)startKitRegister:(nonnull id<MPExtensionKitProtocol>)kitRegister configu
}

if ([kitRegister.wrapperInstance respondsToSelector:@selector(didFinishLaunchingWithConfiguration:)]) {
[kitRegister.wrapperInstance didFinishLaunchingWithConfiguration:configuration];
if ([NSThread isMainThread]) {
[kitRegister.wrapperInstance didFinishLaunchingWithConfiguration:configuration];
} else {
dispatch_async(dispatch_get_main_queue(), ^{
[kitRegister.wrapperInstance didFinishLaunchingWithConfiguration:configuration];
});
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion mParticle-Apple-SDK/MPBackendController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,7 @@ - (void)startWithKey:(NSString *)apiKey secret:(NSString *)secret networkOptions
}

if (![MParticle sharedInstance].stateMachine.optOut) {
dispatch_async(dispatch_get_main_queue(), ^{
dispatch_async([MParticle messageQueue], ^{
[[MParticle sharedInstance].kitContainer initializeKits];
});
}
Expand Down

0 comments on commit 38d3ea7

Please sign in to comment.