|
3 | 3 | #if SENTRY_TARGET_REPLAY_SUPPORTED
|
4 | 4 |
|
5 | 5 | # import "SentryHub+Private.h"
|
| 6 | +# import "SentryInternalCDefines.h" |
6 | 7 | # import "SentryOptions+Private.h"
|
7 | 8 | # import "SentrySDK+Private.h"
|
8 | 9 | # import "SentrySessionReplayIntegration+Private.h"
|
@@ -37,21 +38,30 @@ - (void)resume
|
37 | 38 | [replayIntegration resume];
|
38 | 39 | }
|
39 | 40 |
|
40 |
| -- (void)start |
| 41 | +- (void)start SENTRY_DISABLE_THREAD_SANITIZER("double-checked lock produce false alarms") |
41 | 42 | {
|
42 | 43 | SentrySessionReplayIntegration *replayIntegration
|
43 | 44 | = (SentrySessionReplayIntegration *)[SentrySDK.currentHub
|
44 | 45 | getInstalledIntegration:SentrySessionReplayIntegration.class];
|
45 | 46 |
|
| 47 | + // Start could be misused and called multiple times, causing it to |
| 48 | + // be initialized more than once before being installed. |
| 49 | + // Synchronizing it will prevent this problem. |
46 | 50 | if (replayIntegration == nil) {
|
47 |
| - SentryOptions *currentOptions = SentrySDK.currentHub.client.options; |
48 |
| - replayIntegration = |
49 |
| - [[SentrySessionReplayIntegration alloc] initForManualUse:currentOptions]; |
| 51 | + @synchronized(self) { |
| 52 | + replayIntegration = (SentrySessionReplayIntegration *)[SentrySDK.currentHub |
| 53 | + getInstalledIntegration:SentrySessionReplayIntegration.class]; |
| 54 | + if (replayIntegration == nil) { |
| 55 | + SentryOptions *currentOptions = SentrySDK.currentHub.client.options; |
| 56 | + replayIntegration = |
| 57 | + [[SentrySessionReplayIntegration alloc] initForManualUse:currentOptions]; |
50 | 58 |
|
51 |
| - [SentrySDK.currentHub addInstalledIntegration:replayIntegration |
52 |
| - name:NSStringFromClass(SentrySessionReplay.class)]; |
| 59 | + [SentrySDK.currentHub |
| 60 | + addInstalledIntegration:replayIntegration |
| 61 | + name:NSStringFromClass(SentrySessionReplay.class)]; |
| 62 | + } |
| 63 | + } |
53 | 64 | }
|
54 |
| - |
55 | 65 | [replayIntegration start];
|
56 | 66 | }
|
57 | 67 |
|
|
0 commit comments