Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- User feedback no longer subject to sample rates or `beforeSend` (#5692)
- Build error in app extensions (#5682)
- Fix frame metrics including time while in background (#5681)
- Fix Infinite Session Replay Processing Loop (#5765)

## 8.53.2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,19 +224,14 @@ import UIKit
// swiftlint:disable function_body_length cyclomatic_complexity
private func renderVideo(with videoFrames: [SentryReplayFrame], from: Int, at outputFileURL: URL, completion: @escaping (Result<SentryRenderVideoResult, Error>) -> Void) {
SentrySDKLog.debug("[Session Replay] Rendering video with \(videoFrames.count) frames, from index: \(from), to output url: \(outputFileURL)")

guard from < videoFrames.count else {
SentrySDKLog.error("[Session Replay] Failed to render video, reason: index out of bounds")
return completion(.success(SentryRenderVideoResult(
info: nil,
finalFrameIndex: from
)))
return completion(.failure(SentryOnDemandReplayError.indexOutOfBounds))
}
guard let image = UIImage(contentsOfFile: videoFrames[from].imagePath) else {
SentrySDKLog.error("[Session Replay] Failed to render video, reason: can't read image at path: \(videoFrames[from].imagePath)")
return completion(.success(SentryRenderVideoResult(
info: nil,
finalFrameIndex: from
)))
return completion(.failure(SentryOnDemandReplayError.cantReadImage))
}

let videoWidth = image.size.width * CGFloat(videoScale)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
enum SentryOnDemandReplayError: Error {
case cantReadVideoSize
case cantCreatePixelBuffer
case cantReadImage
case errorRenderingVideo
case cantReadVideoStartTime
case indexOutOfBounds
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,40 @@ class SentryOnDemandReplayTests: XCTestCase {
// -- Assert --
XCTAssertEqual(videos.count, 0)
}


func testCreateVideo_DeleteFrameImages_NoVideoCreated() throws {
// -- Arrange --
let processingQueue = SentryDispatchQueueWrapper()
let workerQueue = SentryDispatchQueueWrapper()
let sut = SentryOnDemandReplay(
outputPath: outputPath.path,
processingQueue: processingQueue,
assetWorkerQueue: workerQueue
)

let start = Date(timeIntervalSinceReferenceDate: 0)
sut.addFrameAsync(timestamp: start, maskedViewImage: UIImage.add)

processingQueue.dispatchSync {
// Wait for the frame to be added by adding a sync operation to the serial queue
}
let end = start.addingTimeInterval(10)

// Delete the image added above so that reading the image at the image path fails,
// because it's removed.
let fileManager = FileManager.default
let contents = try fileManager.contentsOfDirectory(at: outputPath, includingPropertiesForKeys: nil)
for fileURL in contents {
try fileManager.removeItem(at: fileURL)
}

// -- Act --
let result = sut.createVideoWith(beginning: start, end: end)

// -- Assert --
XCTAssertEqual(result.count, 0)
}

func testCalculatePresentationTime_withOneFPS_shouldReturnTiming() {
// -- Arrange --
let framesPerSecond = 1
Expand Down
Loading