This repository was archived by the owner on Feb 25, 2025. It is now read-only.
[web] Prevent crash when restore is called incorrectly after recording ends.#19948
Merged
ferhatb merged 4 commits intoflutter:masterfrom Jul 22, 2020
Merged
[web] Prevent crash when restore is called incorrectly after recording ends.#19948ferhatb merged 4 commits intoflutter:masterfrom
ferhatb merged 4 commits intoflutter:masterfrom
Conversation
mdebbar
approved these changes
Jul 22, 2020
Contributor
mdebbar
left a comment
There was a problem hiding this comment.
LGTM after addressing assertionsEnabled comment.
Comment on lines
122
to
124
| if (assertionsEnabled) { | ||
| _debugRecordingEnded = true; | ||
| _recordingEnded = true; | ||
| } |
Contributor
There was a problem hiding this comment.
The check for assertionsEnabled should be removed, right?
Contributor
Author
There was a problem hiding this comment.
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(); |
Contributor
There was a problem hiding this comment.
Using expect will probably show a nicer error on failure:
expect(() => rc.restore(), returnsNormally);
nturgut
reviewed
Jul 22, 2020
| expect(mockCanvas.methodCallLog[2].methodName, 'restore'); | ||
| expect(mockCanvas.methodCallLog[3].methodName, 'endOfPaint'); | ||
| }); | ||
|
|
Contributor
There was a problem hiding this comment.
very nit: doc comment on the method.
nturgut
approved these changes
Jul 22, 2020
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/flutter
that referenced
this pull request
Jul 23, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.Breaking Change
Did any tests fail when you ran them? Please read [handling breaking changes].