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

ref: Improve frames tracker performance #4469

Merged
merged 4 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Improvements

- Improve frames tracker performance (#4469)

## 8.39.0-beta.1

### Removal of Experimental API
Expand Down
20 changes: 6 additions & 14 deletions Sources/Sentry/SentryFramesTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,8 @@ - (void)displayLinkCallback

- (void)reportNewFrame
{
NSArray *localListeners;
@synchronized(self.listeners) {
localListeners = [self.listeners allObjects];
}

NSDate *newFrameDate = [self.dateProvider date];

for (id<SentryFramesTrackerListener> listener in localListeners) {
for (id<SentryFramesTrackerListener> listener in self.listeners) {
[listener framesTrackerHasNewFrame:newFrameDate];
}
}
Expand Down Expand Up @@ -310,17 +304,15 @@ - (SentryFramesDelayResult *)getFramesDelay:(uint64_t)startSystemTimestamp

- (void)addListener:(id<SentryFramesTrackerListener>)listener
{

@synchronized(self.listeners) {
[self.listeners addObject:listener];
}
// Adding listeners on the main thread to avoid race condition with new frame callback
[self.dispatchQueueWrapper dispatchAsyncOnMainQueue:^{ [self.listeners addObject:listener]; }];
}

- (void)removeListener:(id<SentryFramesTrackerListener>)listener
{
@synchronized(self.listeners) {
[self.listeners removeObject:listener];
}
// Removing listeners on the main thread to avoid race condition with new frame callback
[self.dispatchQueueWrapper
dispatchAsyncOnMainQueue:^{ [self.listeners removeObject:listener]; }];
}

- (void)pause
Expand Down
Loading
Loading