Skip to content

Commit

Permalink
Merge 766b088 into 36d4147
Browse files Browse the repository at this point in the history
  • Loading branch information
brustolin authored Oct 15, 2024
2 parents 36d4147 + 766b088 commit fba4cfb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ via the option `swizzleClassNameExclude`.
- Finish TTID correctly when viewWillAppear is skipped (#4417)
- Swizzling RootUIViewController if ignored by `swizzleClassNameExclude` (#4407)
- Data race in SentrySwizzleInfo.originalCalled (#4434)
- Thread running at User-initiated quality-of-service for session replay (#4439)

### Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class SentrySessionReplay: NSObject {
//Creating a video is heavy and blocks the thread
//Since this function is always called in the main thread
//we dispatch it to a background thread.
dispatchQueue.dispatchAsync {
dispatchQueue.queue.async(qos: .utility) {
do {
let videos = try self.replayMaker.createVideoWith(beginning: startedAt, end: self.dateProvider.date())
for video in videos {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class SentrySessionReplayTests: XCTestCase {
private class TestReplayMaker: NSObject, SentryReplayVideoMaker {
var screens = [String]()

var createVideoCallBack: ((SentryVideoInfo) -> Void)?

struct CreateVideoCall {
var beginning: Date
var end: Date
Expand All @@ -30,6 +32,7 @@ class SentrySessionReplayTests: XCTestCase {
try? "Video Data".write(to: outputFileURL, atomically: true, encoding: .utf8)
let videoInfo = SentryVideoInfo(path: outputFileURL, height: 1_024, width: 480, duration: end.timeIntervalSince(beginning), frameCount: 5, frameRate: 1, start: beginning, end: end, fileSize: 10, screens: screens)

createVideoCallBack?(videoInfo)
return [videoInfo]
}

Expand Down Expand Up @@ -148,6 +151,25 @@ class SentrySessionReplayTests: XCTestCase {
assertFullSession(sut, expected: true)
}

func testMakeReplayQueueQos() {
let fixture = Fixture()

let sut = fixture.getSut(options: SentryReplayOptions(sessionSampleRate: 1, onErrorSampleRate: 1))
sut.start(rootView: fixture.rootView, fullSession: true)

let expect = expectation(description: "create video called")
fixture.replayMaker.createVideoCallBack = { _ in
let current = qos_class_self()
XCTAssertEqual(current, QOS_CLASS_UTILITY)
expect.fulfill()
}

fixture.dateProvider.advance(by: 5)
Dynamic(sut).newFrame(nil)

wait(for: [expect], timeout: 1)
}

func testReplayScreenNames() throws {
let fixture = Fixture()
let sut = fixture.getSut(options: SentryReplayOptions(sessionSampleRate: 1, onErrorSampleRate: 1))
Expand Down

0 comments on commit fba4cfb

Please sign in to comment.