Skip to content

Conversation

@hrishikesh-kadam
Copy link
Contributor

List which issues are fixed by this PR. You must list at least one issue.

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

  • No breaking changes

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 relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • 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.

final List<RouteMatch>? result = _getLocRouteRecursively(
location: uri.path,
remainingLocation: uri.path,
location: uri.path.isEmpty ? '/' : uri.path,
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of fixing this in the parsing, this should probably be fixed in GoRouteInformationProvider to normalize the uri when it receives deeplink from engine.

Copy link
Contributor Author

@hrishikesh-kadam hrishikesh-kadam Oct 11, 2023

Choose a reason for hiding this comment

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

Following are the three call stacks when the breakpoint is set at the above change:

  1. On a normal launch

    Call stack
    RouteConfiguration._getLocRouteMatches (.../.pub-cache/hosted/pub.dev/go_router-11.1.3/lib/src/configuration.dart:304)
    RouteConfiguration.findMatch (.../.pub-cache/hosted/pub.dev/go_router-11.1.3/lib/src/configuration.dart:281)
    GoRouteInformationParser.parseRouteInformationWithDependencies (.../.pub-cache/hosted/pub.dev/go_router-11.1.3/lib/src/parser.dart:87)
    _RouterState._processRouteInformation (.../flutter/stable/packages/flutter/lib/src/widgets/router.dart:744)
    _RouterState.restoreState (.../flutter/stable/packages/flutter/lib/src/widgets/router.dart:622)
    RestorationMixin._doRestore (.../flutter/stable/packages/flutter/lib/src/widgets/restoration.dart:923)
    RestorationMixin.didChangeDependencies (.../flutter/stable/packages/flutter/lib/src/widgets/restoration.dart:909)
    _RouterState.didChangeDependencies (.../flutter/stable/packages/flutter/lib/src/widgets/router.dart:692)
    StatefulElement._firstBuild (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:5448)
    ComponentElement.mount (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:5273)
    Element.inflateWidget (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:4182)
    Element.updateChild (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:3707)
    ComponentElement.performRebuild (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:5322)
    Element.rebuild (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:5016)
    ComponentElement._firstBuild (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:5279)
    ComponentElement.mount (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:5273)
    Element.inflateWidget (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:4182)
    Element.updateChild (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:3707)
    ComponentElement.performRebuild (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:5322)
    Element.rebuild (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:5016)
  2. Launching deep-link with Uri containing scheme and authority using adb shell, when the app is closed by clicking the system back button (To mock deep-link on cold start)

    Call stack
    RouteConfiguration._getLocRouteMatches (.../.pub-cache/hosted/pub.dev/go_router-11.1.3/lib/src/configuration.dart:304)
    RouteConfiguration.findMatch (.../.pub-cache/hosted/pub.dev/go_router-11.1.3/lib/src/configuration.dart:281)
    GoRouteInformationParser.parseRouteInformationWithDependencies (.../.pub-cache/hosted/pub.dev/go_router-11.1.3/lib/src/parser.dart:87)
    _RouterState._processRouteInformation (.../flutter/stable/packages/flutter/lib/src/widgets/router.dart:744)
    _RouterState.restoreState (.../flutter/stable/packages/flutter/lib/src/widgets/router.dart:622)
    RestorationMixin._doRestore (.../flutter/stable/packages/flutter/lib/src/widgets/restoration.dart:923)
    RestorationMixin.didChangeDependencies (.../flutter/stable/packages/flutter/lib/src/widgets/restoration.dart:909)
    _RouterState.didChangeDependencies (.../flutter/stable/packages/flutter/lib/src/widgets/router.dart:692)
    StatefulElement._firstBuild (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:5448)
    ComponentElement.mount (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:5273)
    Element.inflateWidget (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:4182)
    Element.updateChild (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:3707)
    ComponentElement.performRebuild (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:5322)
    Element.rebuild (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:5016)
    ComponentElement._firstBuild (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:5279)
    ComponentElement.mount (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:5273)
    Element.inflateWidget (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:4182)
    Element.updateChild (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:3707)
    ComponentElement.performRebuild (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:5322)
    Element.rebuild (.../flutter/stable/packages/flutter/lib/src/widgets/framework.dart:5016)
  3. Launching deep-link with Uri containing scheme and authority using adb shell, when the app is in foreground or backgrounded by clicking the home button

    Call stack
    RouteConfiguration._getLocRouteMatches (.../.pub-cache/hosted/pub.dev/go_router-11.1.3/lib/src/configuration.dart:304)
    RouteConfiguration.findMatch (.../.pub-cache/hosted/pub.dev/go_router-11.1.3/lib/src/configuration.dart:281)
    GoRouteInformationParser.parseRouteInformationWithDependencies (.../.pub-cache/hosted/pub.dev/go_router-11.1.3/lib/src/parser.dart:87)
    _RouterState._processRouteInformation (.../flutter/stable/packages/flutter/lib/src/widgets/router.dart:744)
    _RouterState._handleRouteInformationProviderNotification (.../flutter/stable/packages/flutter/lib/src/widgets/router.dart:762)
    ChangeNotifier.notifyListeners (.../flutter/stable/packages/flutter/lib/src/foundation/change_notifier.dart:403)
    GoRouteInformationProvider.notifyListeners (.../.pub-cache/hosted/pub.dev/go_router-11.1.3/lib/src/information_provider.dart:147)
    GoRouteInformationProvider._platformReportsNewRouteInformation (.../.pub-cache/hosted/pub.dev/go_router-11.1.3/lib/src/information_provider.dart:246)
    GoRouteInformationProvider.didPushRouteInformation (.../.pub-cache/hosted/pub.dev/go_router-11.1.3/lib/src/information_provider.dart:277)
    WidgetsBinding._handlePushRouteInformation (.../flutter/stable/packages/flutter/lib/src/widgets/binding.dart:704)
    <asynchronous gap> (Unknown Source:0)
    MethodChannel._handleAsMethodCall (.../flutter/stable/packages/flutter/lib/src/services/platform_channel.dart:547)
    <asynchronous gap> (Unknown Source:0)
    _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (.../flutter/stable/packages/flutter/lib/src/services/binding.dart:567)
    <asynchronous gap> (Unknown Source:0)

You can see, GoRouteInformationProvider gets involved only in the 3rd case.

Copy link
Contributor

Choose a reason for hiding this comment

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

for 1 and 2, it would hit this line
https://github.com/flutter/flutter/blob/38f318b46547a6c96715b1d8454c36606acddd42/packages/flutter/lib/src/widgets/router.dart#L619

We should make sure the initialroute is normalized in here

String _effectiveInitialLocation(String? initialLocation) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Incorporated suggested changes in the 6cc2fc4 commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before resolving this conversation, please note that the difference between 49f39ad and 6cc2fc4 is that former tries to fix the issue as late as possible and later as early as possible.
This might create issues in the future when the package handles other schemes like file:///.

@chunhtai chunhtai requested a review from hannah-hyj October 12, 2023 18:24
@chunhtai chunhtai self-requested a review October 19, 2023 22:19
final Uri platformDefaultUri =
Uri.parse(WidgetsBinding.instance.platformDispatcher.defaultRouteName);
final String platformDefault =
WidgetsBinding.instance.platformDispatcher.defaultRouteName;
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the deeplink is called when the app is already running? wasn't the path be missing in that case? I think you need to also modify the logic in _platformReportsNewRouteInformation

Copy link
Contributor Author

@hrishikesh-kadam hrishikesh-kadam Oct 27, 2023

Choose a reason for hiding this comment

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

For now, the change is not required because the RouteInformation.location getter in _platformReportsNewRouteInformation() handles the empty path.

Once the package maintainers decide to migrate from RouteInformation.location to RouteInformation.uri, then it would be the right time to edit.
Also, the care should be taken about where to strip the scheme and authority, either early or late in the code as mentioned in this comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah interesting, thanks for reminding. Can you add a todo somewhere to remind us about location to uri migration? That way we won't break the code when that happens

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

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 LGTM, just we should add a todo to remind ourself once the migration happens

final Uri platformDefaultUri =
Uri.parse(WidgetsBinding.instance.platformDispatcher.defaultRouteName);
final String platformDefault =
WidgetsBinding.instance.platformDispatcher.defaultRouteName;
Copy link
Contributor

Choose a reason for hiding this comment

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

ah interesting, thanks for reminding. Can you add a todo somewhere to remind us about location to uri migration? That way we won't break the code when that happens

Copy link
Member

@hannah-hyj hannah-hyj left a comment

Choose a reason for hiding this comment

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

LGTM

@hannah-hyj hannah-hyj added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 27, 2023
@auto-submit auto-submit bot merged commit 6bcb747 into flutter:main Oct 27, 2023
@hrishikesh-kadam hrishikesh-kadam deleted the fix-deep-link-cold-start branch October 28, 2023 17:23
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 30, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 30, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 30, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 31, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Oct 31, 2023
flutter/packages@2af6954...c9fec61

2023-10-31 [email protected] [image_picker] Prevent multiple active calls on iOS (flutter/packages#5272)
2023-10-30 [email protected] [in_app_purchase_android] Add missing response code to BillingResponse enum (flutter/packages#5120)
2023-10-30 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 2.22.4 to 2.22.5 (flutter/packages#5263)
2023-10-30 [email protected] Bump play-service-maps dependency from version 18.1.0 to 18.2.0 (flutter/packages#5243)
2023-10-30 [email protected] Roll Flutter from a4ec627 to e12d1a7 (3 revisions) (flutter/packages#5267)
2023-10-30 [email protected] [camerax] Loosen restrictions of fallback strategies for choosing resolutions (flutter/packages#5239)
2023-10-30 [email protected] [pigeon] Don't wrap non-nullable primitives in Obj-C (flutter/packages#5214)
2023-10-30 [email protected] [flutter_lints] Replace "flutter pub add --dev" with "dev:" (flutter/packages#5260)
2023-10-28 [email protected] Roll Flutter from 5907c97 to a4ec627 (18 revisions) (flutter/packages#5255)
2023-10-27 [email protected] [go_router] Fixes deep-link with no path on cold start (flutter/packages#5113)
2023-10-27 [email protected] [two_dimensional_scrollables] Fix pinned row painting when one axis is reversed (flutter/packages#5187)
2023-10-27 [email protected] Roll Flutter from c555599 to 5907c97 (45 revisions) (flutter/packages#5252)

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-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: 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
ksokolovskyi pushed a commit to ksokolovskyi/flutter that referenced this pull request Oct 31, 2023
flutter/packages@2af6954...c9fec61

2023-10-31 [email protected] [image_picker] Prevent multiple active calls on iOS (flutter/packages#5272)
2023-10-30 [email protected] [in_app_purchase_android] Add missing response code to BillingResponse enum (flutter/packages#5120)
2023-10-30 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 2.22.4 to 2.22.5 (flutter/packages#5263)
2023-10-30 [email protected] Bump play-service-maps dependency from version 18.1.0 to 18.2.0 (flutter/packages#5243)
2023-10-30 [email protected] Roll Flutter from a4ec627 to e12d1a7 (3 revisions) (flutter/packages#5267)
2023-10-30 [email protected] [camerax] Loosen restrictions of fallback strategies for choosing resolutions (flutter/packages#5239)
2023-10-30 [email protected] [pigeon] Don't wrap non-nullable primitives in Obj-C (flutter/packages#5214)
2023-10-30 [email protected] [flutter_lints] Replace "flutter pub add --dev" with "dev:" (flutter/packages#5260)
2023-10-28 [email protected] Roll Flutter from 5907c97 to a4ec627 (18 revisions) (flutter/packages#5255)
2023-10-27 [email protected] [go_router] Fixes deep-link with no path on cold start (flutter/packages#5113)
2023-10-27 [email protected] [two_dimensional_scrollables] Fix pinned row painting when one axis is reversed (flutter/packages#5187)
2023-10-27 [email protected] Roll Flutter from c555599 to 5907c97 (45 revisions) (flutter/packages#5252)

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-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: 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
@reidbaker reidbaker mentioned this pull request Jan 12, 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 p: go_router

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants