Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

MitchellGoodwin
Copy link
Contributor

@MitchellGoodwin MitchellGoodwin commented Sep 14, 2023

Fixes #124850.

Changes the fallback for the builder on Android. Before the error was from the platform being changed mid Cupertino transition to iOS. If a default builder wasn't set for iOS (which a developer developing only for Android might not), then it defaulted to the Zoom transition. Which changing the transition while on the fly caused issues.

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.

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

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Sep 14, 2023
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@HansMuller seems like you added this logic in the original issue #21715. Outright removing it seems to fix the linked issue, but I'm assuming it covers an edge case I'm not thinking of?

With the code before in the case of this issue, if the theme did not define a builder for the iOS platform, it was defaulting to the zoom page transition, which I'm guessing didn't play nicely with the intended Cupertino page transitions set. The change below seems to fix it, but I'm tagging you to see if you remember what this code covers and if my fix would break that?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't remember that hack (from #21715) however I guess it was possible to end up in a Cupertino pop transition even when the target platform is not iOS and the hack avoided switching to a different transition (based on the actual target platform).

It looks like someone tried to remove the hack in July but that change had to be reverted due to failing internal tests: #114303. Plus the change in #114303 was slightly breaking, since it introduced an additional parameter in buildTransitions. That did seem like the right way to handle the problem.

If removing the 5-year-old hack doesn't cause any tests to fail, including all of the internal ones,

@MitchellGoodwin MitchellGoodwin force-pushed the cupertino-backswipe-on-android branch from c58c3a6 to 8c7355a Compare September 21, 2023 22:04
@MitchellGoodwin MitchellGoodwin force-pushed the cupertino-backswipe-on-android branch from 8c7355a to 350ca65 Compare December 14, 2023 18:33
@MitchellGoodwin MitchellGoodwin marked this pull request as ready for review December 14, 2023 20:30
@MitchellGoodwin MitchellGoodwin changed the title [WIP] Change default builder if on iOS Fixes the transition builder changing the transition on iOS. Dec 14, 2023
@MitchellGoodwin MitchellGoodwin changed the title Fixes the transition builder changing the transition on iOS. Fixes the transition builder changing the Cupertino transition on Android. Dec 14, 2023
Copy link
Member

Choose a reason for hiding this comment

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

Why are we forcing it to CupertinoPageTransitionsBuilder instead of looking up the iOS one in builders and only falling back to CupertinoPageTransitionsBuilder if there is none?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm making the assumption that if a CupertinoPageTransition is in progress, than that's the builder we want to use. If it's not in progress, then we go to the builder, then the CupertinoPageTransitionsBuilder, depending on platform.

Copy link
Member

Choose a reason for hiding this comment

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

I am not (yet) convinced that CupertinoRouteTransitionMixin.isPopGestureInProgress(route) returning true actually means there is a CupertinoPageTransition in progress. CupertinoRouteTransitionMixin.isPopGestureInProgress is implemented as route.navigator.userGestureInProgress - couldn't this also be set by any other custom transition? If one of those is used, we wouldn't want to change to CupertinoPageTransitionsBuilder mid-transition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see what you are saying, but CupertinoRouteTransitionMixin is only added by CupertinoPageTransitionsBuilder. Previously it changed the platform to iOS, so theoretically we would have been getting other issues if it was changing the platform to iOS for anybody using neither CupertinoPageTransitionsBuilder nor ZoomPageTransitionsBuilder.

All that said, I only put in this logic with the boolean to cover whatever edge case setting the platform to iOS was covering before. However I have not been able to track down why it was there, and a previous PR that took this out entirely passed Google testing. I'm fine with just removing it and going straight to checking the builders.

Copy link
Member

Choose a reason for hiding this comment

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

If nothing is breaking I would be in favor of taking this out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was wrong, it does fail a test that changes the OS mid back gesture.

Copy link
Member

Choose a reason for hiding this comment

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

nit: use switch/case for enums as per out style guide.

Copy link
Member

Choose a reason for hiding this comment

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

I am not (yet) convinced that CupertinoRouteTransitionMixin.isPopGestureInProgress(route) returning true actually means there is a CupertinoPageTransition in progress. CupertinoRouteTransitionMixin.isPopGestureInProgress is implemented as route.navigator.userGestureInProgress - couldn't this also be set by any other custom transition? If one of those is used, we wouldn't want to change to CupertinoPageTransitionsBuilder mid-transition?

Comment on lines 770 to 772
Copy link
Member

Choose a reason for hiding this comment

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

Could this be simplified to just

Suggested change
bool cupertinoTransitionInProgress = false;
if (CupertinoRouteTransitionMixin.isPopGestureInProgress(route)) {
platform = TargetPlatform.iOS;
cupertinoTransitionInProgress = true;
}
final bool cupertinoTransitionInProgress = CupertinoRouteTransitionMixin.isPopGestureInProgress(route);

@goderbauer
Copy link
Member

(Analyzer is unhappy)

@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.

@MitchellGoodwin MitchellGoodwin force-pushed the cupertino-backswipe-on-android branch from d87be2a to c24d61f Compare March 7, 2024 17:47
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 774 to 789
PageTransitionsBuilder getTransitionBuilder() {
late PageTransitionsBuilder defaultBuilder;
switch (platform) {
case TargetPlatform.iOS:
defaultBuilder = const CupertinoPageTransitionsBuilder();
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.windows:
case TargetPlatform.macOS:
case TargetPlatform.linux:
defaultBuilder = const ZoomPageTransitionsBuilder();
}
return builders[platform] ?? defaultBuilder;
}

final PageTransitionsBuilder matchingBuilder = getTransitionBuilder();
Copy link
Member

Choose a reason for hiding this comment

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

With those fancy switch expressions this could probably simplify to something like:

final PageTransitionsBuilder matchingBuilder = builders[platform] ?? switch(platform) {
  TargetPlatform.iOS => const CupertinoPageTransitionsBuilder(),
  TargetPlatform.android || TargetPlatform.fuchsia || TargetPlatform.windows || TargetPlatform.macOS || TargetPlatform.linux => const ZoomPageTransitionsBuilder(),
}

final PageTransitionsBuilder matchingBuilder =
builders[platform] ?? const ZoomPageTransitionsBuilder();
PageTransitionsBuilder getTransitionBuilder() {
late PageTransitionsBuilder defaultBuilder;
Copy link
Member

Choose a reason for hiding this comment

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

late -> final. I think dart is smart enough here to figure out that the variable is never accessed before assignment.

@MitchellGoodwin MitchellGoodwin added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 8, 2024
@auto-submit auto-submit bot merged commit 2be5084 into flutter:master Mar 8, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 9, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 9, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 10, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 10, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 11, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Mar 11, 2024
Manual roll Flutter from 7c89ec8 to 3bb2e59 (31 revisions)

Manual roll requested by [email protected]

flutter/flutter@7c89ec8...3bb2e59

2024-03-11 [email protected] Roll Flutter Engine from 210f84eb818b to 3b0b59bb224d (1 revision) (flutter/flutter#144923)
2024-03-11 [email protected] Roll Flutter Engine from d13999c0ca79 to 210f84eb818b (1 revision) (flutter/flutter#144920)
2024-03-11 [email protected] Roll Flutter Engine from 7c2a56a44b41 to d13999c0ca79 (1 revision) (flutter/flutter#144907)
2024-03-10 [email protected] Rename isAvailableForEnvironment to isForEnvironment (#143176) (flutter/flutter#144858)
2024-03-10 [email protected] Roll Flutter Engine from f77664330122 to 7c2a56a44b41 (1 revision) (flutter/flutter#144894)
2024-03-10 [email protected] Roll Flutter Engine from 51fefde43cb3 to f77664330122 (1 revision) (flutter/flutter#144891)
2024-03-09 [email protected] Roll Flutter Engine from 49f01510e4e2 to 51fefde43cb3 (1 revision) (flutter/flutter#144889)
2024-03-09 [email protected] Roll Flutter Engine from 958d7cd560d2 to 49f01510e4e2 (1 revision) (flutter/flutter#144887)
2024-03-09 [email protected] Roll Flutter Engine from fc06f5a99377 to 958d7cd560d2 (2 revisions) (flutter/flutter#144884)
2024-03-09 [email protected] Roll Flutter Engine from 6f7fdc533490 to fc06f5a99377 (1 revision) (flutter/flutter#144876)
2024-03-09 [email protected] Roll Flutter Engine from 196132ffe2f8 to 6f7fdc533490 (1 revision) (flutter/flutter#144875)
2024-03-09 [email protected] Fix multiple calls to Slider's onChanged. (flutter/flutter#143680)
2024-03-09 [email protected] Roll Flutter Engine from d4e3d964dc8a to 196132ffe2f8 (1 revision) (flutter/flutter#144870)
2024-03-09 [email protected] Roll Flutter Engine from e79a72d362a7 to d4e3d964dc8a (1 revision) (flutter/flutter#144866)
2024-03-09 [email protected] Roll Flutter Engine from c3b70321be79 to e79a72d362a7 (1 revision) (flutter/flutter#144865)
2024-03-09 [email protected] Roll Flutter Engine from 79536627661a to c3b70321be79 (1 revision) (flutter/flutter#144864)
2024-03-09 [email protected] Roll Flutter Engine from 7541e902f1b4 to 79536627661a (2 revisions) (flutter/flutter#144863)
2024-03-09 [email protected] Roll Flutter Engine from 953927eae78b to 7541e902f1b4 (7 revisions) (flutter/flutter#144862)
2024-03-09 [email protected] Upgrade vm_service. (flutter/flutter#144845)
2024-03-09 [email protected] Replace dead links (flutter/flutter#144827)
2024-03-09 [email protected] Roll Flutter Engine from e099277ce061 to 953927eae78b (2 revisions) (flutter/flutter#144849)
2024-03-09 [email protected] Mark Mac_arm64_ios module_test_ios bringup: true (flutter/flutter#144861)
2024-03-08 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Rename isAvailableForEnvironment to isForEnvironment (#143176)" (flutter/flutter#144855)
2024-03-08 [email protected] Roll Flutter Engine from 05fdf947f81b to e099277ce061 (1 revision) (flutter/flutter#144844)
2024-03-08 [email protected] Rename isAvailableForEnvironment to isForEnvironment (flutter/flutter#143176)
2024-03-08 [email protected] Roll Flutter Engine from bc4abcda6357 to 05fdf947f81b (9 revisions) (flutter/flutter#144839)
2024-03-08 [email protected] Fixes the transition builder changing the Cupertino transition on Android. (flutter/flutter#134790)
2024-03-08 [email protected] Copy over source maps from dart2js target when they are enabled. (flutter/flutter#144832)
2024-03-08 [email protected] Marks Linux_android new_gallery_opengles_impeller__transition_perf to be unflaky (flutter/flutter#144677)
2024-03-08 [email protected] Roll Flutter Engine from bbb1ed00af49 to bc4abcda6357 (2 revisions) (flutter/flutter#144817)
2024-03-08 [email protected] Roll Packages from 6701c9e to 0badb43 (2 revisions) (flutter/flutter#144831)

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 [email protected],[email protected],[email protected] 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://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
...
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Mar 11, 2024
flutter/flutter@7c89ec8...3bb2e59

2024-03-11 [email protected] Roll Flutter Engine from 210f84eb818b to 3b0b59bb224d (1 revision) (flutter/flutter#144923)
2024-03-11 [email protected] Roll Flutter Engine from d13999c0ca79 to 210f84eb818b (1 revision) (flutter/flutter#144920)
2024-03-11 [email protected] Roll Flutter Engine from 7c2a56a44b41 to d13999c0ca79 (1 revision) (flutter/flutter#144907)
2024-03-10 [email protected] Rename isAvailableForEnvironment to isForEnvironment (#143176) (flutter/flutter#144858)
2024-03-10 [email protected] Roll Flutter Engine from f77664330122 to 7c2a56a44b41 (1 revision) (flutter/flutter#144894)
2024-03-10 [email protected] Roll Flutter Engine from 51fefde43cb3 to f77664330122 (1 revision) (flutter/flutter#144891)
2024-03-09 [email protected] Roll Flutter Engine from 49f01510e4e2 to 51fefde43cb3 (1 revision) (flutter/flutter#144889)
2024-03-09 [email protected] Roll Flutter Engine from 958d7cd560d2 to 49f01510e4e2 (1 revision) (flutter/flutter#144887)
2024-03-09 [email protected] Roll Flutter Engine from fc06f5a99377 to 958d7cd560d2 (2 revisions) (flutter/flutter#144884)
2024-03-09 [email protected] Roll Flutter Engine from 6f7fdc533490 to fc06f5a99377 (1 revision) (flutter/flutter#144876)
2024-03-09 [email protected] Roll Flutter Engine from 196132ffe2f8 to 6f7fdc533490 (1 revision) (flutter/flutter#144875)
2024-03-09 [email protected] Fix multiple calls to Slider's onChanged. (flutter/flutter#143680)
2024-03-09 [email protected] Roll Flutter Engine from d4e3d964dc8a to 196132ffe2f8 (1 revision) (flutter/flutter#144870)
2024-03-09 [email protected] Roll Flutter Engine from e79a72d362a7 to d4e3d964dc8a (1 revision) (flutter/flutter#144866)
2024-03-09 [email protected] Roll Flutter Engine from c3b70321be79 to e79a72d362a7 (1 revision) (flutter/flutter#144865)
2024-03-09 [email protected] Roll Flutter Engine from 79536627661a to c3b70321be79 (1 revision) (flutter/flutter#144864)
2024-03-09 [email protected] Roll Flutter Engine from 7541e902f1b4 to 79536627661a (2 revisions) (flutter/flutter#144863)
2024-03-09 [email protected] Roll Flutter Engine from 953927eae78b to 7541e902f1b4 (7 revisions) (flutter/flutter#144862)
2024-03-09 [email protected] Upgrade vm_service. (flutter/flutter#144845)
2024-03-09 [email protected] Replace dead links (flutter/flutter#144827)
2024-03-09 [email protected] Roll Flutter Engine from e099277ce061 to 953927eae78b (2 revisions) (flutter/flutter#144849)
2024-03-09 [email protected] Mark Mac_arm64_ios module_test_ios bringup: true (flutter/flutter#144861)
2024-03-08 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Rename isAvailableForEnvironment to isForEnvironment (#143176)" (flutter/flutter#144855)
2024-03-08 [email protected] Roll Flutter Engine from 05fdf947f81b to e099277ce061 (1 revision) (flutter/flutter#144844)
2024-03-08 [email protected] Rename isAvailableForEnvironment to isForEnvironment (flutter/flutter#143176)
2024-03-08 [email protected] Roll Flutter Engine from bc4abcda6357 to 05fdf947f81b (9 revisions) (flutter/flutter#144839)
2024-03-08 [email protected] Fixes the transition builder changing the Cupertino transition on Android. (flutter/flutter#134790)
2024-03-08 [email protected] Copy over source maps from dart2js target when they are enabled. (flutter/flutter#144832)
2024-03-08 [email protected] Marks Linux_android new_gallery_opengles_impeller__transition_perf to be unflaky (flutter/flutter#144677)
2024-03-08 [email protected] Roll Flutter Engine from bbb1ed00af49 to bc4abcda6357 (2 revisions) (flutter/flutter#144817)
2024-03-08 [email protected] Roll Packages from 6701c9e to 0badb43 (2 revisions) (flutter/flutter#144831)

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 [email protected],[email protected],[email protected] 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://issues.skia.org/issues/new?component=1389291&template=1850622

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 May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App 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.

Android app with CupertinoPageTransitionsBuilder() and MaterialPageRoute() can't use gesture way to back previous page with no error threw and stucked
3 participants