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

Conversation

@ferhatb
Copy link
Contributor

@ferhatb ferhatb commented Jul 22, 2020

Description

This PR makes web consistent with mobile platforms.

When PaintingContext is used with a painter and component such as TextField, the painter itself causes paintContext.canvas to change to a new instance since one recording ends and another one starts. The code in ClipContext currently is calling save and restore on different Canvas(s) causing an exception on web since it has extra checks.

Related Issues

Fixed flutter/flutter#61697

Tests

Updated recording_canvas_test to cover case.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the [contributor guide] and followed the process outlined there for submitting PRs.
  • I signed the [CLA].
  • I read and followed the [C++, Objective-C, Java style guides] for the engine.
  • I read the [tree hygiene] wiki page, which explains my responsibilities.
  • I updated/added relevant documentation.
  • All existing and new tests are passing.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read [handling breaking changes].

  • No, no existing tests failed, so this is not a breaking change.

@ferhatb ferhatb requested review from mdebbar and nturgut July 22, 2020 16:25
Copy link
Contributor

@mdebbar mdebbar left a comment

Choose a reason for hiding this comment

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

LGTM after addressing assertionsEnabled comment.

Comment on lines 122 to 124
if (assertionsEnabled) {
_debugRecordingEnded = true;
_recordingEnded = true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The check for assertionsEnabled should be removed, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for spotting that!. Done.

final RecordingCanvas rc = RecordingCanvas(Rect.fromLTRB(0, 0, 200, 400));
rc.endRecording();
// Should not throw exception on restore.
rc.restore();
Copy link
Contributor

Choose a reason for hiding this comment

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

Using expect will probably show a nicer error on failure:

expect(() => rc.restore(), returnsNormally);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

expect(mockCanvas.methodCallLog[2].methodName, 'restore');
expect(mockCanvas.methodCallLog[3].methodName, 'endOfPaint');
});

Copy link
Contributor

Choose a reason for hiding this comment

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

very nit: doc comment on the method.

@ferhatb ferhatb merged commit 37fa285 into flutter:master Jul 22, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 23, 2020
@ferhatb ferhatb deleted the restorecrash branch August 10, 2020 20:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[web] Crash in RecordingCanvas.restore()

4 participants