Skip to content

Commit

Permalink
ref: Ignore getFramesDelay for ThreadSanitizer (#3516)
Browse files Browse the repository at this point in the history
The ThreadSanitizer now ignores SentryFramesTracker:getFramesDelay.  We
accept the data race of the two properties _currentFrameRate and
previousFrameSystemTimestamp, that are updated on the main thread in the
displayLinkCallback. This method only reads these properties. In most
scenarios, this method will be called on the main thread, for which no
synchronization is needed. When calling this function from a background
thread, the frames delay statistics don't need to be that accurate
because background spans contribute less to delayed frames. We prefer
having not 100% correct frames delay numbers for background spans
instead of adding the overhead of synchronization.
  • Loading branch information
philipphofmann committed Jan 2, 2024
1 parent 48e8c2e commit 80da9d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Sources/Sentry/SentryFramesTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,17 @@ - (SentryScreenFrames *)currentFrames
# endif // SENTRY_TARGET_PROFILING_SUPPORTED
}

/**
* The ThreadSanitizer ignores this method; see ThreadSanitizer.sup.
*
* We accept the data race of the two properties _currentFrameRate and previousFrameSystemTimestamp,
* that are updated on the main thread in the displayLinkCallback. This method only reads these
* properties. In most scenarios, this method will be called on the main thread, for which no
* synchronization is needed. When calling this function from a background thread, the frames delay
* statistics don't need to be that accurate because background spans contribute less to delayed
* frames. We prefer having not 100% correct frames delay numbers for background spans instead of
* adding the overhead of synchronization.
*/
- (CFTimeInterval)getFramesDelay:(uint64_t)startSystemTimestamp
endSystemTimestamp:(uint64_t)endSystemTimestamp
{
Expand Down
3 changes: 3 additions & 0 deletions Tests/ThreadSanitizer.sup
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ race:disable
race:URLSessionDataTaskMock
race:getOriginalImplementation
race:SentrySpanContext

# Ignore SentryFramesTracer:getFramesDelay. Visit the method for the explanation.
race:getFramesDelay

0 comments on commit 80da9d1

Please sign in to comment.