Skip to content

Commit b074ba9

Browse files
authored
fix: Remove objc from session replay recording methods (#6211)
1 parent 86e4a25 commit b074ba9

File tree

5 files changed

+23
-31
lines changed

5 files changed

+23
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixes
66

77
- Fix potential app launch hang caused by the SentrySDK (#6181) Fixed by removing the call to `_dyld_get_image_header` on the main thread.
8+
- Fix dyanmic selector crash in SentryReplayRecording (#6211)
89

910
## 8.56.0
1011

Sentry.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,6 @@
11021102
FA90FAFD2E070A3B008CAAE8 /* SentryURLRequestFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA90FAFC2E070A3B008CAAE8 /* SentryURLRequestFactory.swift */; };
11031103
FA94E6912E6B92C100576666 /* SentryClientReport.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA94E68B2E6B92BE00576666 /* SentryClientReport.swift */; };
11041104
FA94E6B22E6D265800576666 /* SentryEnvelope.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA94E6B12E6D265500576666 /* SentryEnvelope.swift */; };
1105-
FA94E71C2E6F26C500576666 /* SentrySerialization+ReplayRecording.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA94E71B2E6F26BF00576666 /* SentrySerialization+ReplayRecording.swift */; };
11061105
FA94E7242E6F339400576666 /* SentryEnvelopeItemType.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA94E7232E6F32FA00576666 /* SentryEnvelopeItemType.swift */; };
11071106
FAAB29F12E3D252300ACD577 /* SentrySession.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAAB29F02E3D252000ACD577 /* SentrySession.swift */; };
11081107
FAAB2EE02E4BE97500FE8B7E /* TestSentryNSApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAAB2EDF2E4BE96F00FE8B7E /* TestSentryNSApplication.swift */; };
@@ -2449,7 +2448,6 @@
24492448
FA90FAFC2E070A3B008CAAE8 /* SentryURLRequestFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryURLRequestFactory.swift; sourceTree = "<group>"; };
24502449
FA94E68B2E6B92BE00576666 /* SentryClientReport.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryClientReport.swift; sourceTree = "<group>"; };
24512450
FA94E6B12E6D265500576666 /* SentryEnvelope.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryEnvelope.swift; sourceTree = "<group>"; };
2452-
FA94E71B2E6F26BF00576666 /* SentrySerialization+ReplayRecording.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentrySerialization+ReplayRecording.swift"; sourceTree = "<group>"; };
24532451
FA94E7232E6F32FA00576666 /* SentryEnvelopeItemType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryEnvelopeItemType.swift; sourceTree = "<group>"; };
24542452
FAAB29F02E3D252000ACD577 /* SentrySession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySession.swift; sourceTree = "<group>"; };
24552453
FAAB2EDF2E4BE96F00FE8B7E /* TestSentryNSApplication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSentryNSApplication.swift; sourceTree = "<group>"; };
@@ -2607,7 +2605,6 @@
26072605
children = (
26082606
62CB19242E77F8FD00AF5DA2 /* SentryDispatchSourceWrapper.swift */,
26092607
FAEEC04C2E75E55A00E79CA9 /* SentrySerializationSwift.swift */,
2610-
FA94E71B2E6F26BF00576666 /* SentrySerialization+ReplayRecording.swift */,
26112608
FA94E7232E6F32FA00576666 /* SentryEnvelopeItemType.swift */,
26122609
FA458CBD2E691A6E0061B13D /* SentryProcessInfo.swift */,
26132610
F4A930222E65FDAF006DA6EF /* SentryMobileProvisionParser.swift */,
@@ -5691,7 +5688,6 @@
56915688
63FE711D20DA4C1000CDBAE8 /* SentryCrashCPU_arm64.c in Sources */,
56925689
844EDC77294144DB00C86F34 /* SentrySystemWrapper.mm in Sources */,
56935690
D451ED5F2D92ECDE00C9BEA8 /* SentryReplayFrame.swift in Sources */,
5694-
FA94E71C2E6F26C500576666 /* SentrySerialization+ReplayRecording.swift in Sources */,
56955691
D49480D72DC23FE300A3B6E9 /* SentrySessionReplayDelegate.swift in Sources */,
56965692
FA67DCC12DDBD4C800896B02 /* SentrySDKLog+Configure.swift in Sources */,
56975693
6281C5722D3E4F12009D0978 /* DecodeArbitraryData.swift in Sources */,

Sources/Sentry/include/SentrySerialization.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#import "SentryDefines.h"
22

3-
@class SentryAppState;
43
@class SentryEnvelope;
5-
@class SentryReplayRecording;
64
@class SentrySession;
75

86
NS_ASSUME_NONNULL_BEGIN

Sources/Swift/Helper/SentrySerialization+ReplayRecording.swift

Lines changed: 0 additions & 20 deletions
This file was deleted.

Sources/Swift/Integrations/SessionReplay/SentryReplayRecording.swift

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
@_implementationOnly import _SentryPrivate
12
import Foundation
23

3-
@objcMembers
4-
@_spi(Private) public class SentryReplayRecording: NSObject {
4+
@objc @_spi(Private) public class SentryReplayRecording: NSObject {
55

66
static let SentryReplayEncoding = "h264"
77
static let SentryReplayContainer = "mp4"
@@ -13,7 +13,7 @@ import Foundation
1313
let height: Int
1414
let width: Int
1515

16-
public convenience init(segmentId: Int, video: SentryVideoInfo, extraEvents: [any SentryRRWebEventProtocol]) {
16+
@objc public convenience init(segmentId: Int, video: SentryVideoInfo, extraEvents: [any SentryRRWebEventProtocol]) {
1717
self.init(segmentId: segmentId, size: video.fileSize, start: video.start, duration: video.duration, frameCount: video.frameCount, frameRate: video.frameRate, height: video.height, width: video.width, extraEvents: extraEvents)
1818
}
1919

@@ -27,11 +27,28 @@ import Foundation
2727
self.events = [meta, video] + (extraEvents ?? [])
2828
}
2929

30-
public func headerForReplayRecording() -> [String: Any] {
30+
func headerForReplayRecording() -> [String: Any] {
3131
return ["segment_id": segmentId]
3232
}
3333

34-
public func serialize() -> [[String: Any]] {
34+
func serialize() -> [[String: Any]] {
3535
return events.map { $0.serialize() }
3636
}
37+
38+
func data() -> Data? {
39+
var recording = Data()
40+
guard let headerData = SentrySerialization.data(withJSONObject: headerForReplayRecording()) else {
41+
SentrySDKLog.error("Failed to serialize replay recording header.")
42+
return nil
43+
}
44+
recording.append(headerData)
45+
let newLineData = Data(bytes: "\n", count: 1)
46+
recording.append(newLineData)
47+
guard let replayData = SentrySerialization.data(withJSONObject: serialize()) else {
48+
SentrySDKLog.error("Failed to serialize replay recording data.")
49+
return nil
50+
}
51+
recording.append(replayData)
52+
return recording
53+
}
3754
}

0 commit comments

Comments
 (0)