Skip to content

Commit

Permalink
Update SentryReplayApi.m
Browse files Browse the repository at this point in the history
  • Loading branch information
brustolin committed Oct 17, 2024
1 parent b695b61 commit d705969
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions Sources/Sentry/SentryReplayApi.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,25 @@ - (void)resume

- (void)start
{
SentrySessionReplayIntegration *replayIntegration
// Start could be misused and called multiple times, causing it to
// be initialized more than once before being installed.
// Synchronizing it will prevent this problem.
@synchronized (self) {
SentrySessionReplayIntegration *replayIntegration
= (SentrySessionReplayIntegration *)[SentrySDK.currentHub
getInstalledIntegration:SentrySessionReplayIntegration.class];

if (replayIntegration == nil) {
SentryOptions *currentOptions = SentrySDK.currentHub.client.options;
replayIntegration =
getInstalledIntegration:SentrySessionReplayIntegration.class];
if (replayIntegration == nil) {
SentryOptions *currentOptions = SentrySDK.currentHub.client.options;
replayIntegration =
[[SentrySessionReplayIntegration alloc] initForManualUse:currentOptions];

[SentrySDK.currentHub addInstalledIntegration:replayIntegration
name:NSStringFromClass(SentrySessionReplay.class)];

[SentrySDK.currentHub addInstalledIntegration:replayIntegration
name:NSStringFromClass(SentrySessionReplay.class)];
}

[replayIntegration start];
}

[replayIntegration start];
}

- (void)stop
Expand Down

0 comments on commit d705969

Please sign in to comment.