From d6f1f9cff6d3557da71f3244254e25a6c94d06ed Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Wed, 30 Apr 2025 11:57:56 +0200 Subject: [PATCH 1/3] fix(session-replay): revert max key-frame interval to once per video segment --- Samples/iOS-Swift/iOS-Swift/SentrySDKWrapper.swift | 2 +- .../SessionReplay/SentryOnDemandReplay.swift | 11 ++++++----- .../SessionReplay/SentryOnDemandReplayTests.swift | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Samples/iOS-Swift/iOS-Swift/SentrySDKWrapper.swift b/Samples/iOS-Swift/iOS-Swift/SentrySDKWrapper.swift index 4695f86e2d4..c4aba0df64e 100644 --- a/Samples/iOS-Swift/iOS-Swift/SentrySDKWrapper.swift +++ b/Samples/iOS-Swift/iOS-Swift/SentrySDKWrapper.swift @@ -29,7 +29,7 @@ struct SentrySDKWrapper { if #available(iOS 16.0, *), !SentrySDKOverrides.Other.disableSessionReplay.boolValue { options.sessionReplay = SentryReplayOptions( - sessionSampleRate: 0, + sessionSampleRate: 1, onErrorSampleRate: 1, maskAllText: true, maskAllImages: true diff --git a/Sources/Swift/Integrations/SessionReplay/SentryOnDemandReplay.swift b/Sources/Swift/Integrations/SessionReplay/SentryOnDemandReplay.swift index e3195440e8c..4fdbfe8558f 100644 --- a/Sources/Swift/Integrations/SessionReplay/SentryOnDemandReplay.swift +++ b/Sources/Swift/Integrations/SessionReplay/SentryOnDemandReplay.swift @@ -325,11 +325,12 @@ class SentryOnDemandReplay: NSObject, SentryReplayVideoMaker { // where each frame is independent and must be decodable on its own. AVVideoAllowFrameReorderingKey: false, - // Ensures that every frame is a keyframe (also called an I-frame). - // This is crucial in a 1 FPS timelapse context because: - // 1. It guarantees that every frame can be displayed without relying on previous frames. - // 2. It enables precise seeking and smooth scrubbing across all video players. - AVVideoMaxKeyFrameIntervalKey: frameRate // e.g., 1 for 1 FPS + // Sets keyframe interval to one I-frame per video segment. + // This significantly reduces file size (e.g. from 19KB to 9KB) while maintaining + // acceptable seeking granularity. With our 1 FPS recording, this means a keyframe + // will be inserted once every 6 seconds of recorded content, but our video segments + // will never be longer than 5 seconds, resulting in a maximum of 1 I-frame per video. + AVVideoMaxKeyFrameIntervalKey: 6 // 5 + 1 interval for optimal compression ] as [String: Any], // Explicitly sets the video color space to ITU-R BT.709 (the standard for HD video). diff --git a/Tests/SentryTests/Integrations/SessionReplay/SentryOnDemandReplayTests.swift b/Tests/SentryTests/Integrations/SessionReplay/SentryOnDemandReplayTests.swift index 60e3aacc18e..0f92e4e209a 100644 --- a/Tests/SentryTests/Integrations/SessionReplay/SentryOnDemandReplayTests.swift +++ b/Tests/SentryTests/Integrations/SessionReplay/SentryOnDemandReplayTests.swift @@ -324,7 +324,7 @@ class SentryOnDemandReplayTests: XCTestCase { XCTAssertEqual(compressionProperties[AVVideoAverageBitRateKey] as? Int, sut.bitRate) XCTAssertEqual(compressionProperties[AVVideoProfileLevelKey] as? String, AVVideoProfileLevelH264MainAutoLevel) XCTAssertEqual(compressionProperties[AVVideoAllowFrameReorderingKey] as? Bool, false) - XCTAssertEqual(compressionProperties[AVVideoMaxKeyFrameIntervalKey] as? Int, sut.frameRate) + XCTAssertEqual(compressionProperties[AVVideoMaxKeyFrameIntervalKey] as? Int, 6) let colorProperties = try XCTUnwrap(settings[AVVideoColorPropertiesKey] as? [String: Any], "Color properties not found") @@ -353,7 +353,7 @@ class SentryOnDemandReplayTests: XCTestCase { XCTAssertEqual(compressionProperties[AVVideoAverageBitRateKey] as? Int, sut.bitRate) XCTAssertEqual(compressionProperties[AVVideoProfileLevelKey] as? String, AVVideoProfileLevelH264MainAutoLevel) XCTAssertEqual(compressionProperties[AVVideoAllowFrameReorderingKey] as? Bool, false) - XCTAssertEqual(compressionProperties[AVVideoMaxKeyFrameIntervalKey] as? Int, sut.frameRate) + XCTAssertEqual(compressionProperties[AVVideoMaxKeyFrameIntervalKey] as? Int, 6) let colorProperties = try XCTUnwrap(settings[AVVideoColorPropertiesKey] as? [String: Any], "Color properties not found") From 80c14da4e60e51329b0fd9c3b4678c0fe77ca9f8 Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Wed, 30 Apr 2025 12:04:04 +0200 Subject: [PATCH 2/3] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8789d52d47..cc0056bbae5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - Improve session replay frame presentation timing calculations (#5133) - Use wider compatible video encoding options for Session Replay (#5134) - GA of better session replay view renderer V2 (#5054) +- Revert max key-frame interval to once per session replayvideo segment (#5156) ## 8.49.1 From 08dfa4f02e83eb9f2cc56d04c2d0610db23a5925 Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Wed, 30 Apr 2025 12:04:33 +0200 Subject: [PATCH 3/3] revert test change --- Samples/iOS-Swift/iOS-Swift/SentrySDKWrapper.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Samples/iOS-Swift/iOS-Swift/SentrySDKWrapper.swift b/Samples/iOS-Swift/iOS-Swift/SentrySDKWrapper.swift index c4aba0df64e..4695f86e2d4 100644 --- a/Samples/iOS-Swift/iOS-Swift/SentrySDKWrapper.swift +++ b/Samples/iOS-Swift/iOS-Swift/SentrySDKWrapper.swift @@ -29,7 +29,7 @@ struct SentrySDKWrapper { if #available(iOS 16.0, *), !SentrySDKOverrides.Other.disableSessionReplay.boolValue { options.sessionReplay = SentryReplayOptions( - sessionSampleRate: 1, + sessionSampleRate: 0, onErrorSampleRate: 1, maskAllText: true, maskAllImages: true