Skip to content

Commit

Permalink
validation for fetchedDisplayRefreshRate
Browse files Browse the repository at this point in the history
  • Loading branch information
Volodymyr B committed Sep 19, 2024
1 parent 3b7bfe8 commit c05ea27
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions flutter/lib/src/span_frame_metrics_collector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import 'native/sentry_native_binding.dart';
@internal
class SpanFrameMetricsCollector implements PerformanceContinuousCollector {
static const _frozenFrameThresholdMs = 700;
static const _defaultRefreshRate = 60;

static const totalFramesKey = 'frames.total';
static const framesDelayKey = 'frames.delay';
static const slowFramesKey = 'frames.slow';
Expand Down Expand Up @@ -39,7 +41,7 @@ class SpanFrameMetricsCollector implements PerformanceContinuousCollector {
bool get isTrackingRegistered => _isTrackingRegistered;
bool _isTrackingRegistered = false;

int displayRefreshRate = 60;
int displayRefreshRate = _defaultRefreshRate;

final _stopwatch = Stopwatch();

Expand All @@ -59,7 +61,7 @@ class SpanFrameMetricsCollector implements PerformanceContinuousCollector {
}

final fetchedDisplayRefreshRate = await _native?.displayRefreshRate();
if (fetchedDisplayRefreshRate != null) {
if (fetchedDisplayRefreshRate != null && fetchedDisplayRefreshRate > 0) {
options.logger(SentryLevel.debug,
'Retrieved display refresh rate at $fetchedDisplayRefreshRate');
displayRefreshRate = fetchedDisplayRefreshRate;
Expand Down Expand Up @@ -251,6 +253,6 @@ class SpanFrameMetricsCollector implements PerformanceContinuousCollector {
_isTrackingPaused = true;
frames.clear();
activeSpans.clear();
displayRefreshRate = 60;
displayRefreshRate = _defaultRefreshRate;
}
}

0 comments on commit c05ea27

Please sign in to comment.