Skip to content

Default clipBehavior of ClipRect to hardEdge. #21702

@GaryQian

Description

@GaryQian

Using antiAlias in ClipRect, which is no longer the default, is now slow since flutter/engine#6199 enables AA.

Background:
Previously, the engine did not properly pass the AA flag on ClipRect.clipBehavior. flutter/engine#6199 fixes this and enables AA. However, default AA on clipRects has caused severe regressions in benchmark performance.

To maintain expected performance, we should now default the clipBehavior to hardEdge to disable default AA. This is consistent with any flutter projects that did not previously explicitly set the clipBehavior and should not change app appearance.

Migration:

  • If you left clipBehavior as default: Nothing!
  • If you explicitly set clipBehavior as hardEdge: Nothing!
  • If you explicitly set clipBehavior as antiAlias or antiAliasWithSaveLayer: Your application will now actually perform the specified AA. It is up to you to decide if the performance is worth the visual improvement.
  • If you left clipBehavior as default and expected AA: explicitly set clipBehavior to Clip.antiAlias and verify that the performance is acceptable to your application.

For the most part, there should be minimal if any need to migrate code, but I will be glad to assist anyone to achieve the expected clipping behavior.

Summary:
clipBehavior is now properly respected instead of always hardEdge. Any expectation of anti-aliasing should be re-evaluated in regards to performance.

Metadata

Metadata

Assignees

Labels

a: fidelityMatching the OEM platforms betterc: API breakBackwards-incompatible API changesc: performanceRelates to speed or footprint issues (see "perf:" labels)frameworkflutter/packages/flutter repository. See also f: labels.waiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions