Skip to content

Conversation

@eyebrowsoffire
Copy link
Contributor

@eyebrowsoffire eyebrowsoffire commented Mar 25, 2023

This is based off (and dependent on) these changes in the web engine that expose web-specific APIs: flutter/engine#40608

Issue: #126831

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

@eyebrowsoffire eyebrowsoffire marked this pull request as draft March 25, 2023 01:12

export 'src/navigation_non_web/url_strategy.dart'
if (dart.library.html) 'src/navigation/url_strategy.dart';
if (dart.library.ui_web) 'src/navigation/url_strategy.dart';
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC this requires changes in the Dart compilers. Its not automatic from the libraries.json/yaml files

Copy link
Contributor Author

@eyebrowsoffire eyebrowsoffire Mar 27, 2023

Choose a reason for hiding this comment

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

Hmm, I thought otherwise but you might be right. Let me write a unit test that tests that non-web can compile and gets the stubbed version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually it appears that if (dart.library.ui_web) does actually work for me. Hmm.

Copy link
Contributor

Choose a reason for hiding this comment

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

nice. I would check all compilers though :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I swear we added another constant here @sigmundch ?

Copy link
Contributor

Choose a reason for hiding this comment

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

The list of libraries here depends precisely on the names in the libraries.json file used by the CFE when compiling the SDK. If you have a library that doesn't exist, this condition may simply be unconditionally false on all backends.

Seems you recently added dart:ui_web as a public library, so this should be OK. In this case, it appears not only that the library exist, but it's precisely the one platform specific thing that you are using underneath in url_strategy.dart, so it seems reasonable to use this as your conditional import.

That said, there is a caveat in our internal build systems to consider. Our integration with bazel explicitly lists what can be used for configuration specific imports, but I can't recall at this moment how it does so (e.g. by listing specific libraries, or listing modes like "VM" vs "Web" vs "Flutter Web"). Bottomline - the BUILD rules are aware of itand the list of configurations is maintained by hand at the bazel/starlark level. Because it is not derived from the libraries.json, there is a small chance that a change will be needed whenever this rolls into g3.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the context! All the CI checks are passing, except the Google3 testing is giving issues, which is just as you've predicted.

Copy link
Contributor

Choose a reason for hiding this comment

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

The alternative to the g3 issues could be to pick configurations that are already known there. For example dart.library.js or dart.library.js_util. Technically we don't want those if we are going to remove them in the wasm backend (which I think that's the plan). Ideally we would use dart.library.js_interop (the new library), but I'm guessing it probably has the same issue that ui_web has today.

@eyebrowsoffire
Copy link
Contributor Author

CI is obviously not going to pass until after I merge flutter/engine#40608, but things do appear to work for me locally when I run with --local-web-sdk and the built version of that branch.

Copy link
Contributor

@mdebbar mdebbar 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 26 to 29
test('Can create and set a $PathUrlStrategy', () {
final PathUrlStrategy strategy = PathUrlStrategy(location);
setUrlStrategy(strategy);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

While you are at it:

Suggested change
test('Can create and set a $PathUrlStrategy', () {
final PathUrlStrategy strategy = PathUrlStrategy(location);
setUrlStrategy(strategy);
});
test('Can create and set a $PathUrlStrategy', () {
final PathUrlStrategy strategy = PathUrlStrategy(location);
setUrlStrategy(strategy);
});
test('Can usePathUrlStrategy', () {
usePathUrlStrategy();
});

Comment on lines 22 to 23
final HashUrlStrategy strategy = HashUrlStrategy(location);
setUrlStrategy(strategy);
Copy link
Contributor

Choose a reason for hiding this comment

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

The tests look a bit weird without any expect() calls. We could add an explicit expectation for the code not to throw. Not sure if there is any other benefit to doing it this way.

Suggested change
final HashUrlStrategy strategy = HashUrlStrategy(location);
setUrlStrategy(strategy);
expect(() {
final HashUrlStrategy strategy = HashUrlStrategy(location);
setUrlStrategy(strategy);
}, returnsNormally);

jsUrlStrategy = convertToJsUrlStrategy(strategy);
}
jsSetUrlStrategy(jsUrlStrategy);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Upon a second look, we need to call the ui_web.urlStrategy setter here.

import '../navigation_common/platform_location.dart';
import 'utils.dart';

export 'dart:ui_web' show urlStrategy, UrlStrategy;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we actually need to expose the urlStrategy setter here? Users can (and should) get it directly from dart:ui_web, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. Removing.

@goderbauer goderbauer added the platform-web Web applications specifically label Apr 18, 2023
@eyebrowsoffire eyebrowsoffire marked this pull request as ready for review April 18, 2023 23:15
@mdebbar mdebbar added the autosubmit Merge PR when tree becomes green via auto submit App label May 5, 2023
@auto-submit auto-submit bot merged commit 201f731 into flutter:master May 5, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 6, 2023
tarrinneal pushed a commit to flutter/packages that referenced this pull request May 6, 2023
Manual roll Flutter from 0b65723 to 43ac23b (30 revisions)

Manual roll requested by [email protected]

flutter/flutter@0b65723...43ac23b

2023-05-05 [email protected] targets/web.dart - fix typo
(flutter/flutter#126114)
2023-05-05 [email protected] Roll Flutter Engine from
6b467df16e11 to 758cbadfac1f (2 revisions) (flutter/flutter#126175)
2023-05-05 [email protected] add tests for
dominant bottom sheet in scaffold (flutter/flutter#124472)
2023-05-05 [email protected] Added
CupertinoDatepicker monthYear mode (flutter#93508)
(flutter/flutter#125603)
2023-05-05 [email protected] Add
`Switch.trackOutlineWidth` property (flutter/flutter#125848)
2023-05-05 [email protected] Rename
iosdeeplinksettings to iosuniversallinksettings (flutter/flutter#126173)
2023-05-05 [email protected] Roll Flutter Engine from
f3efe11f4449 to 6b467df16e11 (3 revisions) (flutter/flutter#126174)
2023-05-05 [email protected] improvement :
removed required kotlin dependency (flutter/flutter#125002)
2023-05-05 [email protected] Fix incorrect assert hint in flutter.groovy
(flutter/flutter#125283)
2023-05-05 [email protected] Update
.cirrus.yml (flutter/flutter#126166)
2023-05-05 [email protected] tool: replace top-level
functions with enum properties (flutter/flutter#126167)
2023-05-05 [email protected] Use direct dart API from
`dart:ui_web` rather than JS shim. (flutter/flutter#123443)
2023-05-05 [email protected] Add sample
code for SliverAppBar (flutter/flutter#125785)
2023-05-05 [email protected] Roll Flutter Engine from
cef0e9d1a94f to f3efe11f4449 (3 revisions) (flutter/flutter#126163)
2023-05-05 [email protected] Add a ReorderableListView example with
cards + cleanup existing tests (flutter/flutter#126155)
2023-05-05 [email protected] Roll Packages from
6bd59cd to a0f8fd8 (4 revisions) (flutter/flutter#126161)
2023-05-05 [email protected] Bring back
the failing build_test's (flutter/flutter#126014)
2023-05-05 [email protected] [web] Use plain platform views in
benchmarks (flutter/flutter#126080)
2023-05-05 [email protected] Fix Material 3 tab indicator weight and
position (flutter/flutter#125883)
2023-05-05 [email protected] Roll Flutter Engine from
b0f53e7751ad to cef0e9d1a94f (1 revision) (flutter/flutter#126150)
2023-05-05 [email protected] Roll Flutter Engine from
6f26066144fb to b0f53e7751ad (2 revisions) (flutter/flutter#126148)
2023-05-05 [email protected] Roll Flutter Engine from
764991e046c6 to 6f26066144fb (1 revision) (flutter/flutter#126141)
2023-05-05 [email protected] Roll Flutter Engine from
e7cd29153aa9 to 764991e046c6 (1 revision) (flutter/flutter#126137)
2023-05-05 [email protected] Roll Flutter Engine from
a885ed472eea to e7cd29153aa9 (1 revision) (flutter/flutter#126135)
2023-05-05 [email protected] Roll Flutter Engine from
c97a0deccbc1 to a885ed472eea (1 revision) (flutter/flutter#126129)
2023-05-05 [email protected] [NavigationDrawer] adds padding
property in NavigationDrawer Widget (flutter/flutter#123961)
2023-05-05 [email protected] Roll Flutter Engine from
269ce2deebeb to c97a0deccbc1 (1 revision) (flutter/flutter#126124)
2023-05-05 [email protected] Roll Flutter Engine from
4d5070672859 to 269ce2deebeb (16 revisions) (flutter/flutter#126115)
2023-05-05 [email protected] Minor fixes found while working on blankcanvas
(flutter/flutter#125751)
2023-05-05 [email protected] tool-web: use ProcessUtil.run
to invoke child processes (flutter/flutter#126109)

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://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
...
auto-submit bot pushed a commit to flutter/engine that referenced this pull request May 31, 2023
Finally, we can remove this JS global function for customizing the url strategy.

Why I think we don't need to go through an official deprecation process:

1. It was initially made for internal use in Google3, and right now there are no references to it.
2. There's no public documentation of this JS function.
3. External users customize their url strategy through `flutter_web_plugins` which has been [migrated](flutter/flutter#123443) already.
nploi pushed a commit to nploi/packages that referenced this pull request Jul 16, 2023
)

Manual roll Flutter from 0b65723 to 43ac23b (30 revisions)

Manual roll requested by [email protected]

flutter/flutter@0b65723...43ac23b

2023-05-05 [email protected] targets/web.dart - fix typo
(flutter/flutter#126114)
2023-05-05 [email protected] Roll Flutter Engine from
6b467df16e11 to 758cbadfac1f (2 revisions) (flutter/flutter#126175)
2023-05-05 [email protected] add tests for
dominant bottom sheet in scaffold (flutter/flutter#124472)
2023-05-05 [email protected] Added
CupertinoDatepicker monthYear mode (flutter#93508)
(flutter/flutter#125603)
2023-05-05 [email protected] Add
`Switch.trackOutlineWidth` property (flutter/flutter#125848)
2023-05-05 [email protected] Rename
iosdeeplinksettings to iosuniversallinksettings (flutter/flutter#126173)
2023-05-05 [email protected] Roll Flutter Engine from
f3efe11f4449 to 6b467df16e11 (3 revisions) (flutter/flutter#126174)
2023-05-05 [email protected] improvement :
removed required kotlin dependency (flutter/flutter#125002)
2023-05-05 [email protected] Fix incorrect assert hint in flutter.groovy
(flutter/flutter#125283)
2023-05-05 [email protected] Update
.cirrus.yml (flutter/flutter#126166)
2023-05-05 [email protected] tool: replace top-level
functions with enum properties (flutter/flutter#126167)
2023-05-05 [email protected] Use direct dart API from
`dart:ui_web` rather than JS shim. (flutter/flutter#123443)
2023-05-05 [email protected] Add sample
code for SliverAppBar (flutter/flutter#125785)
2023-05-05 [email protected] Roll Flutter Engine from
cef0e9d1a94f to f3efe11f4449 (3 revisions) (flutter/flutter#126163)
2023-05-05 [email protected] Add a ReorderableListView example with
cards + cleanup existing tests (flutter/flutter#126155)
2023-05-05 [email protected] Roll Packages from
6bd59cd to a0f8fd8 (4 revisions) (flutter/flutter#126161)
2023-05-05 [email protected] Bring back
the failing build_test's (flutter/flutter#126014)
2023-05-05 [email protected] [web] Use plain platform views in
benchmarks (flutter/flutter#126080)
2023-05-05 [email protected] Fix Material 3 tab indicator weight and
position (flutter/flutter#125883)
2023-05-05 [email protected] Roll Flutter Engine from
b0f53e7751ad to cef0e9d1a94f (1 revision) (flutter/flutter#126150)
2023-05-05 [email protected] Roll Flutter Engine from
6f26066144fb to b0f53e7751ad (2 revisions) (flutter/flutter#126148)
2023-05-05 [email protected] Roll Flutter Engine from
764991e046c6 to 6f26066144fb (1 revision) (flutter/flutter#126141)
2023-05-05 [email protected] Roll Flutter Engine from
e7cd29153aa9 to 764991e046c6 (1 revision) (flutter/flutter#126137)
2023-05-05 [email protected] Roll Flutter Engine from
a885ed472eea to e7cd29153aa9 (1 revision) (flutter/flutter#126135)
2023-05-05 [email protected] Roll Flutter Engine from
c97a0deccbc1 to a885ed472eea (1 revision) (flutter/flutter#126129)
2023-05-05 [email protected] [NavigationDrawer] adds padding
property in NavigationDrawer Widget (flutter/flutter#123961)
2023-05-05 [email protected] Roll Flutter Engine from
269ce2deebeb to c97a0deccbc1 (1 revision) (flutter/flutter#126124)
2023-05-05 [email protected] Roll Flutter Engine from
4d5070672859 to 269ce2deebeb (16 revisions) (flutter/flutter#126115)
2023-05-05 [email protected] Minor fixes found while working on blankcanvas
(flutter/flutter#125751)
2023-05-05 [email protected] tool-web: use ProcessUtil.run
to invoke child processes (flutter/flutter#126109)

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://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
@eyebrowsoffire eyebrowsoffire deleted the url_strategy branch December 12, 2025 21:56
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 platform-web Web applications specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants