Skip to content

Implements the Android native stretch effect as a fragment shader (Impeller-only). #169293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

MTtankkeo
Copy link

@MTtankkeo MTtankkeo commented May 22, 2025

Sorry, Closing PR #169196 and reopening this in a new PR for clarity and a cleaner commit history.

Fixed an issue #82906

In the existing Flutter implementation, the Android stretch overscroll effect is achieved using Transform. However, this approach does not evenly stretch the screen as it does in the native Android environment. Therefore, in the Impeller environment, add or modify files to implement the effect using a fragment shader identical to the one used in native Android.

Note

  • The addition of a separate test file for StretchOverscrollEffect was not included because it would likely duplicate coverage already provided by the changes made in overscroll_stretch_indicator_test.dart within this PR.

However, since determining whether stretching occurred by referencing global coordinates is currently considered impossible with the new Fragment Shader approach, the code was modified to partially exclude the relevant test logic in the Impeller.

For reference, in the page_view_test.dart test, there was an issue with referencing the child Transform widget, but because the StretchOverscrollEffect widget is defined instead of the Transform widget in the Impeller environment, the code logic was adjusted accordingly.

  • Golden image tests were updated as the visual effect changes.

Reference Source

Old Skia (Using Transform)

old.mp4

New Impeller (Using fragment shader)

new.mp4

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added tool Affects the "flutter" command-line tool. See also t: labels. framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. labels May 22, 2025
@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #169293 at sha 3c6f85a

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label May 22, 2025
@MTtankkeo MTtankkeo marked this pull request as draft May 22, 2025 20:38
@MTtankkeo MTtankkeo marked this pull request as ready for review May 22, 2025 21:01
@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #169293 at sha 8b26ebc

@MTtankkeo
Copy link
Author

😭 Hi @justinmc, @dkwingsmt, @Piinks, could you please review this PR? Thanks! 😭

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Hi @MTtankkeo thanks for the contribution! This type of change would involve some changes in the engine I think.

@MTtankkeo MTtankkeo marked this pull request as draft May 23, 2025 18:35
@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@dkwingsmt
Copy link
Contributor

After an internal discussion between @Piinks, a couple other folks, and I, we've come to agree with the current direction to add the shader to the framework as long as it aligns with how we implement the ink sparkle. We'll take a more detailed review at this PR soon, but I just want to let you know ASAP so you don't have to look into the engine code. Sorry for the confusion!

@MTtankkeo MTtankkeo marked this pull request as ready for review May 23, 2025 19:22
@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #169293 at sha 93ad7c2

@MTtankkeo MTtankkeo requested a review from chunhtai May 26, 2025 17:45
Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

Code mostly looks good to me just left some minor comment.

@MTtankkeo MTtankkeo requested review from a team and matanlurey as code owners May 27, 2025 20:21
@github-actions github-actions bot added a: tests "flutter test", flutter_test, or one of our tests a: text input Entering text in a text field or keyboard related problems c: contributor-productivity Team-specific productivity, code health, technical debt. platform-android Android applications specifically platform-ios iOS applications specifically engine flutter/engine repository. See also e: labels. labels May 27, 2025
@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #169293 at sha e33cbcc

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #169293 at sha 067d9cd

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Thank you for the updates! Sorry again for my misguidance earlier. So excited to see this move forward.

float norm_viewport_width = 1.0;
float norm_viewport_height = 1.0;

out_u_norm = compute_streched_effect(
Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, one axis assumption is safe here I think. The widget is limited to one axis, and with the 2D scrollables they have their own indicator for each axis.

float norm_viewport_width = 1.0;
float norm_viewport_height = 1.0;

out_u_norm = compute_streched_effect(
Copy link
Contributor

Choose a reason for hiding this comment

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

@MTtankkeo can we simplify this then?

Comment on lines 191 to 193
isImpeller
? 'overscroll_stretch.vertical.start.stretched.impeller.png'
: 'overscroll_stretch.vertical.start.stretched.png',
Copy link
Contributor

Choose a reason for hiding this comment

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

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #169293 at sha a11a6c8

@MTtankkeo
Copy link
Author

Note

Updated to avoid using a separate golden image name or identifier based on review feedback.

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #169293 at sha 1275943

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #169293 at sha ee85d62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. tool Affects the "flutter" command-line tool. See also t: labels. will affect goldens Changes to golden files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants