File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
flutter/lib/src/screenshot Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff 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;
Original file line number Diff line number Diff 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 >();
You can’t perform that action at this time.
0 commit comments