Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Thread running at User-initiated quality-of-service for Session replay #4439

Merged
merged 9 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
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 @@ -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)
brustolin marked this conversation as resolved.
Show resolved Hide resolved

### Improvements

Expand Down
6 changes: 5 additions & 1 deletion Sources/Sentry/SentrySessionReplayIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ - (void)startWithOptions:(SentryReplayOptions *)replayOptions
= (NSInteger)(shouldReplayFullSession ? replayOptions.sessionSegmentDuration + 1
: replayOptions.errorReplayDuration + 1);


dispatch_queue_attr_t attributes = dispatch_queue_attr_make_with_qos_class( DISPATCH_QUEUE_SERIAL, DISPATCH_QUEUE_PRIORITY_LOW, 0);
SentryDispatchQueueWrapper* dispatchQueue = [[SentryDispatchQueueWrapper alloc] initWithName:"Sentry Session Replay" attributes:attributes];
brustolin marked this conversation as resolved.
Show resolved Hide resolved

self.sessionReplay = [[SentrySessionReplay alloc]
initWithReplayOptions:replayOptions
replayFolderPath:docs
Expand All @@ -290,7 +294,7 @@ - (void)startWithOptions:(SentryReplayOptions *)replayOptions
touchTracker:_touchTracker
dateProvider:SentryDependencyContainer.sharedInstance.dateProvider
delegate:self
dispatchQueue:[[SentryDispatchQueueWrapper alloc] init]
dispatchQueue:dispatchQueue
displayLinkWrapper:[[SentryDisplayLinkWrapper alloc] init]];

[self.sessionReplay
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 @@ -63,7 +66,7 @@ class SentrySessionReplayTests: XCTestCase {
var lastReplayId: SentryId?
var currentScreen: String?

func getSut(options: SentryReplayOptions = .init(sessionSampleRate: 0, onErrorSampleRate: 0) ) -> SentrySessionReplay {
func getSut(options: SentryReplayOptions = .init(sessionSampleRate: 0, onErrorSampleRate: 0), dispatchQueue: SentryDispatchQueueWrapper = TestSentryDispatchQueueWrapper() ) -> SentrySessionReplay {
return SentrySessionReplay(replayOptions: options,
replayFolderPath: cacheFolder,
screenshotProvider: screenshotProvider,
Expand All @@ -72,7 +75,7 @@ class SentrySessionReplayTests: XCTestCase {
touchTracker: SentryTouchTracker(dateProvider: dateProvider, scale: 0),
dateProvider: dateProvider,
delegate: self,
dispatchQueue: TestSentryDispatchQueueWrapper(),
dispatchQueue: dispatchQueue,
displayLinkWrapper: displayLink)
}

Expand Down Expand Up @@ -147,7 +150,7 @@ class SentrySessionReplayTests: XCTestCase {
XCTAssertNotNil(fixture.lastReplayRecording)
assertFullSession(sut, expected: true)
}

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