Skip to content

Conversation

@dnfield
Copy link
Contributor

@dnfield dnfield commented Feb 15, 2020

Description

Currently, FadeInImage continues to build the placeholder even if it's invisible. This is really sad if the placeholder is a multi frame looping animation, or just a large chunk of memory that no one else needs.

Just listening to the animation for the placeholder, when the status is completed for the current animation, setState to trigger a rebuild.

Related Issues

#35592

Tests

I added the following tests:

Test that when the animation completes on the placeholder, it's no longer in the tree.

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 Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • 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.

Copy link
Contributor

@liyuqian liyuqian left a comment

Choose a reason for hiding this comment

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

LGTM with a nit.

@dnfield dnfield merged commit 8aa6761 into flutter:master Feb 18, 2020
@dnfield dnfield deleted the fade_in_fix branch February 18, 2020 19:30
),
]));
]))..addStatusListener((AnimationStatus status) {
if (_placeholderOpacityAnimation.isCompleted) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this always going to be the same as status == AnimationStatus.completed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes - the implementation of isCompleted is status == AnimationStatus.completed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh - sorry.

This might not be the same if we've changed the _placeholderOpacityAnimation, but the previous one we were listening to is still finishing.

This is meant to guard against that case, so we don't end up rebuilding unless the current animation is completed.

@dnfield dnfield added a: images Loading, displaying, rendering images perf: memory Performance issues related to memory perf: speed Performance issues related to (mostly rendering) speed c: performance Relates to speed or footprint issues (see "perf:" labels) labels Feb 18, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: images Loading, displaying, rendering images c: performance Relates to speed or footprint issues (see "perf:" labels) framework flutter/packages/flutter repository. See also f: labels. perf: memory Performance issues related to memory perf: speed Performance issues related to (mostly rendering) speed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants