From 5a7fffc61ebdd249681f380ea70cf8e6041f8f72 Mon Sep 17 00:00:00 2001 From: Noah Martin Date: Fri, 19 Sep 2025 10:39:56 -0400 Subject: [PATCH] fix: Remove objc from session replay recording methods --- CHANGELOG.md | 1 + Sentry.xcodeproj/project.pbxproj | 4 --- Sources/Sentry/include/SentrySerialization.h | 2 -- .../SentrySerialization+ReplayRecording.swift | 20 -------------- .../SessionReplay/SentryReplayRecording.swift | 27 +++++++++++++++---- 5 files changed, 23 insertions(+), 31 deletions(-) delete mode 100644 Sources/Swift/Helper/SentrySerialization+ReplayRecording.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index 504f1b061e3..dd5a9e7cf79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixes - Fix potential app launch hang caused by the SentrySDK (#6181) Fixed by removing the call to `_dyld_get_image_header` on the main thread. +- Fix dyanmic selector crash in SentryReplayRecording (#6211) ## 8.56.0 diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index 968ab721ab9..77990b69fa3 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -1102,7 +1102,6 @@ FA90FAFD2E070A3B008CAAE8 /* SentryURLRequestFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA90FAFC2E070A3B008CAAE8 /* SentryURLRequestFactory.swift */; }; FA94E6912E6B92C100576666 /* SentryClientReport.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA94E68B2E6B92BE00576666 /* SentryClientReport.swift */; }; FA94E6B22E6D265800576666 /* SentryEnvelope.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA94E6B12E6D265500576666 /* SentryEnvelope.swift */; }; - FA94E71C2E6F26C500576666 /* SentrySerialization+ReplayRecording.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA94E71B2E6F26BF00576666 /* SentrySerialization+ReplayRecording.swift */; }; FA94E7242E6F339400576666 /* SentryEnvelopeItemType.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA94E7232E6F32FA00576666 /* SentryEnvelopeItemType.swift */; }; FAAB29F12E3D252300ACD577 /* SentrySession.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAAB29F02E3D252000ACD577 /* SentrySession.swift */; }; FAAB2EE02E4BE97500FE8B7E /* TestSentryNSApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAAB2EDF2E4BE96F00FE8B7E /* TestSentryNSApplication.swift */; }; @@ -2449,7 +2448,6 @@ FA90FAFC2E070A3B008CAAE8 /* SentryURLRequestFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryURLRequestFactory.swift; sourceTree = ""; }; FA94E68B2E6B92BE00576666 /* SentryClientReport.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryClientReport.swift; sourceTree = ""; }; FA94E6B12E6D265500576666 /* SentryEnvelope.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryEnvelope.swift; sourceTree = ""; }; - FA94E71B2E6F26BF00576666 /* SentrySerialization+ReplayRecording.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentrySerialization+ReplayRecording.swift"; sourceTree = ""; }; FA94E7232E6F32FA00576666 /* SentryEnvelopeItemType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryEnvelopeItemType.swift; sourceTree = ""; }; FAAB29F02E3D252000ACD577 /* SentrySession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySession.swift; sourceTree = ""; }; FAAB2EDF2E4BE96F00FE8B7E /* TestSentryNSApplication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSentryNSApplication.swift; sourceTree = ""; }; @@ -2607,7 +2605,6 @@ children = ( 62CB19242E77F8FD00AF5DA2 /* SentryDispatchSourceWrapper.swift */, FAEEC04C2E75E55A00E79CA9 /* SentrySerializationSwift.swift */, - FA94E71B2E6F26BF00576666 /* SentrySerialization+ReplayRecording.swift */, FA94E7232E6F32FA00576666 /* SentryEnvelopeItemType.swift */, FA458CBD2E691A6E0061B13D /* SentryProcessInfo.swift */, F4A930222E65FDAF006DA6EF /* SentryMobileProvisionParser.swift */, @@ -5691,7 +5688,6 @@ 63FE711D20DA4C1000CDBAE8 /* SentryCrashCPU_arm64.c in Sources */, 844EDC77294144DB00C86F34 /* SentrySystemWrapper.mm in Sources */, D451ED5F2D92ECDE00C9BEA8 /* SentryReplayFrame.swift in Sources */, - FA94E71C2E6F26C500576666 /* SentrySerialization+ReplayRecording.swift in Sources */, D49480D72DC23FE300A3B6E9 /* SentrySessionReplayDelegate.swift in Sources */, FA67DCC12DDBD4C800896B02 /* SentrySDKLog+Configure.swift in Sources */, 6281C5722D3E4F12009D0978 /* DecodeArbitraryData.swift in Sources */, diff --git a/Sources/Sentry/include/SentrySerialization.h b/Sources/Sentry/include/SentrySerialization.h index 7231dcf9334..6733e0c0ca7 100644 --- a/Sources/Sentry/include/SentrySerialization.h +++ b/Sources/Sentry/include/SentrySerialization.h @@ -1,8 +1,6 @@ #import "SentryDefines.h" -@class SentryAppState; @class SentryEnvelope; -@class SentryReplayRecording; @class SentrySession; NS_ASSUME_NONNULL_BEGIN diff --git a/Sources/Swift/Helper/SentrySerialization+ReplayRecording.swift b/Sources/Swift/Helper/SentrySerialization+ReplayRecording.swift deleted file mode 100644 index 5531445a981..00000000000 --- a/Sources/Swift/Helper/SentrySerialization+ReplayRecording.swift +++ /dev/null @@ -1,20 +0,0 @@ -@_implementationOnly import _SentryPrivate - -extension SentryReplayRecording { - @objc public func data() -> Data? { - var recording = Data() - guard let headerData = SentrySerialization.data(withJSONObject: headerForReplayRecording()) else { - SentrySDKLog.error("Failed to serialize replay recording header.") - return nil - } - recording.append(headerData) - let newLineData = Data(bytes: "\n", count: 1) - recording.append(newLineData) - guard let replayData = SentrySerialization.data(withJSONObject: serialize()) else { - SentrySDKLog.error("Failed to serialize replay recording data.") - return nil - } - recording.append(replayData) - return recording - } -} diff --git a/Sources/Swift/Integrations/SessionReplay/SentryReplayRecording.swift b/Sources/Swift/Integrations/SessionReplay/SentryReplayRecording.swift index 8aa542a8576..c2c9ccb8dc8 100644 --- a/Sources/Swift/Integrations/SessionReplay/SentryReplayRecording.swift +++ b/Sources/Swift/Integrations/SessionReplay/SentryReplayRecording.swift @@ -1,7 +1,7 @@ +@_implementationOnly import _SentryPrivate import Foundation -@objcMembers -@_spi(Private) public class SentryReplayRecording: NSObject { +@objc @_spi(Private) public class SentryReplayRecording: NSObject { static let SentryReplayEncoding = "h264" static let SentryReplayContainer = "mp4" @@ -13,7 +13,7 @@ import Foundation let height: Int let width: Int - public convenience init(segmentId: Int, video: SentryVideoInfo, extraEvents: [any SentryRRWebEventProtocol]) { + @objc public convenience init(segmentId: Int, video: SentryVideoInfo, extraEvents: [any SentryRRWebEventProtocol]) { 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) } @@ -27,11 +27,28 @@ import Foundation self.events = [meta, video] + (extraEvents ?? []) } - public func headerForReplayRecording() -> [String: Any] { + func headerForReplayRecording() -> [String: Any] { return ["segment_id": segmentId] } - public func serialize() -> [[String: Any]] { + func serialize() -> [[String: Any]] { return events.map { $0.serialize() } } + + func data() -> Data? { + var recording = Data() + guard let headerData = SentrySerialization.data(withJSONObject: headerForReplayRecording()) else { + SentrySDKLog.error("Failed to serialize replay recording header.") + return nil + } + recording.append(headerData) + let newLineData = Data(bytes: "\n", count: 1) + recording.append(newLineData) + guard let replayData = SentrySerialization.data(withJSONObject: serialize()) else { + SentrySDKLog.error("Failed to serialize replay recording data.") + return nil + } + recording.append(replayData) + return recording + } }