Skip to content

Commit 4ccd5ea

Browse files
committed
better logging
1 parent 183e995 commit 4ccd5ea

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

flutter/lib/src/screenshot/recorder.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class ScreenshotRecorder {
2222
@protected
2323
final SentryFlutterOptions options;
2424

25-
@protected
2625
final String logName;
2726
bool _warningLogged = false;
2827
late final SentryMaskingConfig? _maskingConfig;

flutter/lib/src/screenshot/stabilizer.dart

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,20 @@ class ScreenshotStabilizer<R> {
7777
'Giving up after $_tries tries.');
7878
} else {
7979
// Add a delay to give the UI a chance to stabilize.
80-
if (_tries > 0) {
81-
await Future<void>.delayed(
82-
Duration(milliseconds: min(100, 10 * (_tries - 1))));
80+
// Only do this on every other frame so that there's a greater chance
81+
// of two subsequent frames being the same.
82+
final sleepMs = _tries % 2 == 1 ? min(100, 10 * (_tries - 1)) : 0;
83+
84+
if (_tries > 1) {
85+
_options.logger(
86+
SentryLevel.debug,
87+
'${_recorder.logName}: '
88+
'Retrying screenshot capture due to UI changes. '
89+
'Delay before next capture: $sleepMs ms.');
90+
}
91+
92+
if (sleepMs > 0) {
93+
await Future<void>.delayed(Duration(milliseconds: sleepMs));
8394
}
8495

8596
final completer = Completer<void>();

0 commit comments

Comments
 (0)