Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request addresses a scaling issue with PlatformViews during showCupertinoSheet transitions. It introduces a filterQuality parameter to showCupertinoSheet and related classes, allowing developers to disable the default ImageFilterLayer that causes rendering conflicts with PlatformViews by setting filterQuality to null. The changes plumb this new parameter through CupertinoSheetRoute and CupertinoSheetTransition. Additionally, a debug-time assertion is added to PlatformViewLayer to detect and report when a PlatformView is incorrectly nested within filter-based layers like ImageFilterLayer, ColorFilterLayer, or ShaderMaskLayer, improving developer experience by providing clear error messages for such conflicts. A minor related change adjusts the timing of when debugCreator is set on layers within RenderTransform to ensure this information is available for the new assertion. Finally, tests are added to verify the new assertion logic.
|
Refactored the original implementation: changing the new parameter from |
dkwingsmt
left a comment
There was a problem hiding this comment.
Thank you very much for the investigation. Fantastic implementation of the assertion!
My only concern is the API design. I think the current property name is not intuitive enough, especially for those who wonder why their app crashes. I've evaluated several options, and I'm proposing the name hasPlatformViews, which is as explicit as possible on what this property is used for and focuses on the perspective of the developers ("if you have platform views, turn on this to avoid errors" without having to understand why). What do you think?
Also I propose the following doc to acommpany the name:
/// Whether the underlying route contains platform views.
///
/// Defaults to false, which uses an [ImageFilterLayer] for high-quality scaling.
/// However, since image filters cannot be applied to platform views, they may
/// appear "detached" or remain at their original size while the background
/// page scales.
///
/// When set to true, the transition uses a [TransformLayer] instead. This
/// ensures platform views scale in sync with the rest of the route, although
/// the scaling quality may be slightly lower (less antialiasing).|
@dkwingsmt Thanks for reviewing. I think |
dkwingsmt
left a comment
There was a problem hiding this comment.
LGTM. Thank you for the investigation!
|
autosubmit label was removed for flutter/flutter/182935, because This PR has not met approval requirements for merging. The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.
|
|
Thanks for your contribution! This PR has reached completion, however we're not able to merge this PR at the moment due to the Material/Cupertino code freeze (#184093). As soon as the decoupling is complete, we will post a way to port this PR to the new packages to land. In the meantime, I'll convert this PR to a draft and apply a label so that we can quickly find it when the freeze is lifted. |
|
I've marked this PR as not ready to port to flutter/packages yet. The changes not in the material or cupertino libraries will remain here. |
|
Advice for PR splitting: Since this touches material/cupertino along with other parts of flutter/flutter, it will need to be split up. If the material/cupertino changes are dependent on the other non-material/cupertino changes in this PR, then the material/cupertino changes will need to wait for them to roll to stable before they can be ported over to material_ui/cupertino_ui in flutter/packages (which uses the stable branch).
|
|
If you would like to return to this, material_ui and cupertino_ui are now accepting contributions. :) The portions of this PR that affect the cupertino library can be ported over to flutter/packages, although they may have to wait for the changes in rendering to land here and reach stable first. Guidance and instructions for easily porting over can be found in #188444 |
|
@Piinks Created new PR at flutter/packages#12565. |
Can you say more about this? Why is that so? |
|
@Piinks Because the rendering PR is all about assertion debug check. It's used to detect similar issues and does not affect the actual functionality. |
|
I confirm that the framework changes are not needed for the new flag to work. The new PR looks good to me. Would you like to convert this PR to contain the remaining framework changes? |
Good call, also, since these changes were not needed to fix the issue, it would be good to know the motivation for them. :) Seems like maybe a separate issue? |
|
It's already separated at #188542 |
From flutter/flutter#182935 Fixes flutter/flutter#169495 The scale transition in showCupertinoSheet for the underlying route defaulted to FilterQuality.medium, which pushes an implicit `ImageFilterLayer`. Platform views cannot be correctly sampled or transformed by rasterization-based filters. Consequently, they fail to reflect the scale transformation during the transition animation when an `ImageFilterLayer` is present, leading to a broken visual effect where the background scales but the platform view remains at its original size. **Solution:** Added `hasPlatformView` parameter. `false` by default which matches the original behavior. When set to `true`, we use standard `TransformLayer` by setting filterQuality to `null`. ## Pre-Review Checklist
From flutter/flutter#182935 Fixes flutter/flutter#169495 The scale transition in showCupertinoSheet for the underlying route defaulted to FilterQuality.medium, which pushes an implicit `ImageFilterLayer`. Platform views cannot be correctly sampled or transformed by rasterization-based filters. Consequently, they fail to reflect the scale transformation during the transition animation when an `ImageFilterLayer` is present, leading to a broken visual effect where the background scales but the platform view remains at its original size. **Solution:** Added `hasPlatformView` parameter. `false` by default which matches the original behavior. When set to `true`, we use standard `TransformLayer` by setting filterQuality to `null`. ## Pre-Review Checklist
The scale transition in showCupertinoSheet for the underlying route defaulted to FilterQuality.medium, which pushes an implicit ImageFilterLayer.
Platform views cannot be correctly sampled or transformed by rasterization-based filters. Consequently, they fail to reflect the scale transformation during the transition animation when an ImageFilterLayer is present, leading to a broken visual effect where the background scales but the platform view remains at its original size.
Solution:
enableFilterparameter toshowCupertinoSheetand related classes. When set tofalse, the transition uses a standard TransformLayer, which allows platform views to scale correctly.PlatformViewLayer.redepthChildrento detect when a platform view is nested inside unsupported filter layers (ImageFilterLayer, ColorFilterLayer, or ShaderMaskLayer). This will help developers catch similar rasterization conflicts earlier.Fixes: #169495
Example usage
Visual Changes
Before vs. After Comparison
Notes on Visuals:
WebViewstays at its original size while the rest of the underlying route scales down.WebViewscales smoothly in sync with the transition whenenableFilteris set tofalse.Pre-launch Checklist
///).