Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[web] Fix leaking canvas in text placeholder tests #21253

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion lib/web_ui/dev/browser_lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ios-safari:
# `heightOfHeader` is the number of pixels taken by the phone's header menu
# and the browsers address bar.
# TODO: https://github.com/flutter/flutter/issues/65672
heightOfHeader: 282
heightOfHeader: 283
# `heightOfFooter` is the number of pixels taken by the phone's navigation
# menu.
heightOfFooter: 250
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/dev/safari_installation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class IosSafariArgParser extends BrowserArgParser {
);
} catch (e) {
throw Exception('Error getting requested simulator. Try running '
'`felt create` command first before running the tests. Exception: '
'`felt create_simulator` command first before running the tests. Exception: '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:D thanks!

'$e');
}

Expand Down
3 changes: 2 additions & 1 deletion lib/web_ui/dev/test_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ class TestCommand extends Command<bool> with ArgUtils {
// after solving the git issue faced on macOS and Windows bots:
// TODO: https://github.com/flutter/flutter/issues/63710
if ((isChrome && isLuci && io.Platform.isLinux) ||
((isChrome || isSafariIOS) && !isLuci)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove this part for now :) I didn't merged the recipe change

(isChrome && !isLuci) || (isSafariIOS && isLuci)) {
print('INFO: Also running the screenshot tests.');
// Separate screenshot tests from unit-tests. Screenshot tests must run
// one at a time. Otherwise, they will end up screenshotting each other.
// This is not an issue for unit-tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ void testMain() async {
final Rect screenRect = const Rect.fromLTWH(0, 0, 600, 600);
final RecordingCanvas recordingCanvas = RecordingCanvas(screenRect);

recordingCanvas.save();
Offset offset = Offset.zero;
for (PlaceholderAlignment placeholderAlignment
in PlaceholderAlignment.values) {
Expand All @@ -39,6 +40,7 @@ void testMain() async {
);
offset = offset.translate(0.0, 80.0);
}
recordingCanvas.restore();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just see save/restore pairs. why was it leaking when restore is not called ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the way canvas pool works lazily now? I saw you added restore calls in multiple tests: #15153

recordingCanvas.endRecording();
recordingCanvas.apply(canvas, screenRect);
return scuba.diffCanvasScreenshot(canvas, 'text_with_placeholders');
Expand All @@ -48,6 +50,7 @@ void testMain() async {
final Rect screenRect = const Rect.fromLTWH(0, 0, 600, 600);
final RecordingCanvas recordingCanvas = RecordingCanvas(screenRect);

recordingCanvas.save();
Offset offset = Offset.zero;
_paintTextWithPlaceholder(
recordingCanvas,
Expand All @@ -72,6 +75,7 @@ void testMain() async {
after: 'ipsum.',
textAlignment: TextAlign.end,
);
recordingCanvas.restore();
recordingCanvas.endRecording();
recordingCanvas.apply(canvas, screenRect);
return scuba.diffCanvasScreenshot(canvas, 'text_align_with_placeholders');
Expand Down