diff --git a/CHANGELOG.md b/CHANGELOG.md index e3714452079..2cce9a874d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Fix retrieving GraphQL operation names crashing ([#3973](https://github.com/getsentry/sentry-cocoa/pull/3973)) - Fix SentryCrashExceptionApplication subclass problem (#3993) - Fix wrong value for `In Foreground` flag on UIKit applications (#4005) +- Session replay wrong video size (#4018) ## 8.26.0 diff --git a/Sources/Sentry/SentrySessionReplay.m b/Sources/Sentry/SentrySessionReplay.m index e487b06cef1..74c6c995be0 100644 --- a/Sources/Sentry/SentrySessionReplay.m +++ b/Sources/Sentry/SentrySessionReplay.m @@ -90,6 +90,8 @@ - (void)start:(UIView *)rootView fullSession:(BOOL)full _videoSegmentStart = nil; _currentSegmentId = 0; _sessionReplayId = [[SentryId alloc] init]; + _replayMaker.videoWidth = (NSInteger)(rootView.frame.size.width * _replayOptions.sizeScale); + _replayMaker.videoHeight = (NSInteger)(rootView.frame.size.height * _replayOptions.sizeScale); imageCollection = [NSMutableArray array]; if (full) { diff --git a/Sources/Swift/Integrations/SessionReplay/SentryReplayVideoMaker.swift b/Sources/Swift/Integrations/SessionReplay/SentryReplayVideoMaker.swift index e10ca6bf3ef..2661d05e788 100644 --- a/Sources/Swift/Integrations/SessionReplay/SentryReplayVideoMaker.swift +++ b/Sources/Swift/Integrations/SessionReplay/SentryReplayVideoMaker.swift @@ -4,6 +4,9 @@ import UIKit @objc protocol SentryReplayVideoMaker: NSObjectProtocol { + var videoWidth: Int { get set } + var videoHeight: Int { get set } + func addFrameAsync(image: UIImage) func releaseFramesUntil(_ date: Date) func createVideoWith(duration: TimeInterval, beginning: Date, outputFileURL: URL, completion: @escaping (SentryVideoInfo?, Error?) -> Void) throws diff --git a/Tests/SentryTests/Integrations/SessionReplay/SentrySessionReplayTests.swift b/Tests/SentryTests/Integrations/SessionReplay/SentrySessionReplayTests.swift index 1cccec763b2..04c4ea8be62 100644 --- a/Tests/SentryTests/Integrations/SessionReplay/SentrySessionReplayTests.swift +++ b/Tests/SentryTests/Integrations/SessionReplay/SentrySessionReplayTests.swift @@ -15,6 +15,9 @@ class SentrySessionReplayTests: XCTestCase { private class TestReplayMaker: NSObject, SentryReplayVideoMaker { + var videoWidth: Int = 0 + var videoHeight: Int = 0 + struct CreateVideoCall { var duration: TimeInterval var beginning: Date @@ -108,6 +111,18 @@ class SentrySessionReplayTests: XCTestCase { expect(fixture.hub.lastEvent) == nil } + func testVideoSize() { + let fixture = startFixture() + let options = SentryReplayOptions(sessionSampleRate: 1, errorSampleRate: 1) + let sut = fixture.getSut(options: options) + let view = fixture.rootView + view.frame = CGRect(x: 0, y: 0, width: 320, height: 900) + sut.start(fixture.rootView, fullSession: true) + + XCTAssertEqual(Int(320 * options.sizeScale), fixture.replayMaker.videoWidth) + XCTAssertEqual(Int(900 * options.sizeScale), fixture.replayMaker.videoHeight) + } + func testSentReplay_FullSession() { let fixture = startFixture()