Skip to content
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

Do not animate TabBarView if controller is invalid #123442

Merged

Conversation

gilnobrega
Copy link
Contributor

An exception is raised by TabBar when its TabController gets replaced with another controller while it is animating between two tabs.

This happens because the method _handleScrollNotification in _TabBarViewState tries to set _controller.offset value, which setter depends on a non-nullable _controller.animation.
However, this Animation is null if _controller.dispose() is called, e.g.: when the controller is replaced with another controller.

This merge request prevents calling _controller.offset if a pre-existing boolean _controllerIsValid condition is not met in the _handleScrollNotification method.

Fixes issue #34744

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Mar 25, 2023
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

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

@gilnobrega gilnobrega force-pushed the replace_tabcontroller_mid_animation branch 5 times, most recently from 695afed to 002b201 Compare March 30, 2023 14:58
@HansMuller HansMuller self-requested a review March 31, 2023 21:42
@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

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.

@gilnobrega gilnobrega force-pushed the replace_tabcontroller_mid_animation branch from 002b201 to 112e4a4 Compare April 21, 2023 07:37
@gilnobrega gilnobrega force-pushed the replace_tabcontroller_mid_animation branch from 112e4a4 to d534e14 Compare May 4, 2023 23:27
@HansMuller
Copy link
Contributor

This looks OK, just needs a fix for the analyzer errors.

@gilnobrega gilnobrega force-pushed the replace_tabcontroller_mid_animation branch from 8375805 to f3c08e9 Compare May 5, 2023 15:47
@HansMuller
Copy link
Contributor

HansMuller commented May 5, 2023

BTW: you can check for analyzer errors locally with flutter analyze --flutter-repo

@gilnobrega
Copy link
Contributor Author

BTW: you can check for analyzer errors locally with flutter analyze --flutter-repo

Thanks, I was trying to make sense of what those logs in analyze-linux meant, then I noticed Cirrus CI shows the full log

@gilnobrega gilnobrega force-pushed the replace_tabcontroller_mid_animation branch from 6f63e8e to 52ffda6 Compare May 11, 2023 20:54
Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

LGTM

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2023
auto-submit bot pushed a commit to flutter/packages that referenced this pull request May 22, 2023
flutter/flutter@077d644...ab57304

2023-05-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 482c99af9c69 to aac09195688d (1 revision) (flutter/flutter#127241)
2023-05-20 andrewrkolos@gmail.com Reland "[tool] Move Java functions to their own file" (flutter/flutter#126577)
2023-05-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from f0c02aee69db to 482c99af9c69 (1 revision) (flutter/flutter#127240)
2023-05-19 82336674+gilnobrega@users.noreply.github.com Do not animate `TabBarView` if controller is invalid (flutter/flutter#123442)
2023-05-19 54558023+keyonghan@users.noreply.github.com Run Mac intel only targets on both intel and arm (flutter/flutter#127230)
2023-05-19 737941+loic-sharma@users.noreply.github.com [Windows] Ensure window is shown (flutter/flutter#127046)
2023-05-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 3267fa29491a to f0c02aee69db (4 revisions) (flutter/flutter#127233)
2023-05-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 2b14f8a1f21c to 3267fa29491a (4 revisions) (flutter/flutter#127224)
2023-05-19 pq@users.noreply.github.com fixes to anticipate next Dart linter release (flutter/flutter#127211)
2023-05-19 katelovett@google.com Remove deprecated OverscrollIndicatorNotification.disallowGlow (flutter/flutter#127050)
2023-05-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from f471b37a2146 to 2b14f8a1f21c (1 revision) (flutter/flutter#127221)
2023-05-19 christopherfujino@gmail.com [flutter_tools] only try to take a screenshot from flutter drive if the --screenshot flag is passed (flutter/flutter#127150)
2023-05-19 zanderso@users.noreply.github.com Roll goldctl to f808dcff91b221ae313e540c09d79696cd08b8de (flutter/flutter#127218)
2023-05-19 engine-flutter-autoroll@skia.org Roll Packages from b31a128 to 1e214d7 (3 revisions) (flutter/flutter#127217)
2023-05-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from a0ea4d2d9ea5 to f471b37a2146 (1 revision) (flutter/flutter#127212)
2023-05-19 joshualitt@google.com Revert "Migrate benchmarks to package:web" (flutter/flutter#127207)
2023-05-19 ychris@google.com [tool] delete xcresult bundle file before each xcode retry. (flutter/flutter#127144)
2023-05-19 vashworth@google.com [iOS] Dispose of log readers and port forwarders if launch fails (flutter/flutter#127140)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC dit@google.com,rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
CaseyHillers pushed a commit to CaseyHillers/flutter that referenced this pull request May 24, 2023
nploi pushed a commit to nploi/packages that referenced this pull request Jul 16, 2023
…r#4051)

flutter/flutter@077d644...ab57304

2023-05-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from 482c99af9c69 to aac09195688d (1 revision) (flutter/flutter#127241)
2023-05-20 andrewrkolos@gmail.com Reland "[tool] Move Java functions to their own file" (flutter/flutter#126577)
2023-05-20 engine-flutter-autoroll@skia.org Roll Flutter Engine from f0c02aee69db to 482c99af9c69 (1 revision) (flutter/flutter#127240)
2023-05-19 82336674+gilnobrega@users.noreply.github.com Do not animate `TabBarView` if controller is invalid (flutter/flutter#123442)
2023-05-19 54558023+keyonghan@users.noreply.github.com Run Mac intel only targets on both intel and arm (flutter/flutter#127230)
2023-05-19 737941+loic-sharma@users.noreply.github.com [Windows] Ensure window is shown (flutter/flutter#127046)
2023-05-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 3267fa29491a to f0c02aee69db (4 revisions) (flutter/flutter#127233)
2023-05-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from 2b14f8a1f21c to 3267fa29491a (4 revisions) (flutter/flutter#127224)
2023-05-19 pq@users.noreply.github.com fixes to anticipate next Dart linter release (flutter/flutter#127211)
2023-05-19 katelovett@google.com Remove deprecated OverscrollIndicatorNotification.disallowGlow (flutter/flutter#127050)
2023-05-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from f471b37a2146 to 2b14f8a1f21c (1 revision) (flutter/flutter#127221)
2023-05-19 christopherfujino@gmail.com [flutter_tools] only try to take a screenshot from flutter drive if the --screenshot flag is passed (flutter/flutter#127150)
2023-05-19 zanderso@users.noreply.github.com Roll goldctl to f808dcff91b221ae313e540c09d79696cd08b8de (flutter/flutter#127218)
2023-05-19 engine-flutter-autoroll@skia.org Roll Packages from b31a128 to 1e214d7 (3 revisions) (flutter/flutter#127217)
2023-05-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from a0ea4d2d9ea5 to f471b37a2146 (1 revision) (flutter/flutter#127212)
2023-05-19 joshualitt@google.com Revert "Migrate benchmarks to package:web" (flutter/flutter#127207)
2023-05-19 ychris@google.com [tool] delete xcresult bundle file before each xcode retry. (flutter/flutter#127144)
2023-05-19 vashworth@google.com [iOS] Dispose of log readers and port forwarders if launch fails (flutter/flutter#127140)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC dit@google.com,rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants