Skip to content

Commit

Permalink
Fix: Session replay video size (#4018)
Browse files Browse the repository at this point in the history
Session replay used to have a hardcoded video size. Now it gets from the window size
  • Loading branch information
brustolin authored May 28, 2024
1 parent 86b89b9 commit b0e218b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions Sources/Sentry/SentrySessionReplay.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit b0e218b

Please sign in to comment.