-
Notifications
You must be signed in to change notification settings - Fork 341
Switch to using Path URL Strategy #3585
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
Conversation
Oh also, survey parsing seems like it'll need updating - I'm not certain how to test that though. If you let me know I can ensure that's working correctly. |
@helin24 I don't know if this will affect IntelliJ/Android Studio. The reason VS Code needed a change was that the URLs were over-encoded which only seemed ok when we were using the fragment. |
Generating the survey url does need updating. The value of You can force the survey prompt to come up by deleting the .devtools file ( |
Done! I extracted the code that extracts the page to a non-web-specific file so it was easier to add tests for it - I don't know if analytics_common was the right place for it, let me know if it's better elsewhere. Btw when I was testing this it worked fine running from the CLI on a new port, but when launching on the normal port from VS Code, the app seemed heavily cached and I had to use Chrome devtools to "clear application data" before the change took affect. I don't know if this is just because it's not a real release or if other users may see this. |
I found an issue when connecting to an app from the connect screen. When doing this, the 'inspector' page does not show up in the url. This is not specific to the inspector, but rather the first page shown after connecting DevTools to the running app. Repro steps:
|
hmm, yeah - I can repro this. You can also just go direct to a URL like this: http://127.0.0.1:9104/?uri=ws%3A%2F%2F127.0.0.1%3A59526%2FIRmSRy-94Gk%3D%2Fws I think this is because we're just showing the first item in the tabbed control when there's no page, so it's valid to not have one and we'll show whatever is the first item. If we never want this, I think probably we could check if there's a page in the URL after we connect, and if not, explicitly push the first visible screen? |
Yeah, once we show a tab, we should verify that the page name is in the url, and if not, we should add it. |
@@ -97,7 +100,18 @@ Future<shelf.Handler> defaultHandler( | |||
if (debugMode) { | |||
return debugProxyHandler!(request); | |||
} else { | |||
return buildDirHandler!(request); | |||
// If the user hits Refresh when on a page being handled by the Flutter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to this file will need to be applied to the g3 handler as well, but I have verified that things work as expected when that is done. I'll update the g3 handler when this change rolls into g3.
|
||
void main() async { | ||
usePathUrlStrategy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will need to be applied to the google3 main file. I'll take an action item to do this when this change is rolled into g3.
I've pushed changes that should fix the URL thing. One updates the URL when the tab controller is initialised (so we know which first tab is being rendered if there isn't one in the QS), and one removes some code that had a bug if you went to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm once tests pass
Yep, though we'll need to gate it on a version of DevTools that includes this PR (without the |
@kenzieschmoll bots are passing, but only because I added a Do you know if there's a better way to do this? |
Future.microtask(() { | ||
final routerDelegate = DevToolsRouterDelegate.of(context); | ||
Router.neglect(context, () { | ||
routerDelegate.navigateIfNotCurrent( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using Future.microtask(), what about WidgetsBinding.instance.addPostFrameCallback ?
another idea - is there a better way to update the url that doesn't trigger a build in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another idea - is there a better way to update the url that doesn't trigger a build in the first place?
I haven't been able to find one. I thought what I was doing here with Router.neglect
would do it, but even if it's not rebuilding, it does still throw being called here.
Instead of using
Future.microtask()
, what aboutWidgetsBinding.instance.addPostFrameCallback
?
That seems to work (both in the browser, and the tests) so I've pushed that. I'm not sure it's an ideal fix, but I don't have any other ideas right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is forcing build to be called because routerDelegate.navigateIfNotCurrent
eventually calls notifyListeners
. One idea is to hide the notifyListeners
call behind a bool if (shouldNotify)
. shouldNotify
could be an optional named parameter that defaults to true. I haven't tried this locally, so we'll need to make sure that this doesn't break any routing behavior if notifyListeners
was false. This may cause more trouble than it is worth, but could be worth looking into.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that notifyListeners()
is how we notify Flutter that the URL may have changed (and in turn, it may update the visible URL to the user). If we remove that, I think the visible URL in the browser won't change at all (since we've only updated our own local state variables).
(If this doesn't seem right, I can do some testing of it though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. The postFrameCallback seems fine then.
40c5924
to
bbcabd0
Compare
@@ -10,6 +10,7 @@ | |||
<head> | |||
<meta charset="utf-8"> | |||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |||
<base href="/"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elliette wanted to get your input on changes to this file to verify that this shouldn't have any effects on serving DevTools in g3 or with DDR / the Dart DevTools extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks safe to me! None of the serving logic should care about the base URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for these changes, Danny. Can you please mirror the devtools_server/ changes in this PR to the new home of devtools_server inside dds?
external_handlers.dart --> https://github.com/dart-lang/sdk/blob/main/pkg/dds/lib/src/devtools/handler.dart#L26
server.dart --> https://github.com/dart-lang/sdk/blob/d1baf327a18dfc92476049a09985b645c08072f5/pkg/dds/lib/devtools_server.dart#L278
Please also leave the changes here for now, as we haven't completely migrated all code off of package:devtools_server and over to the dds implementation.
Thanks! I want to re-test with these final tweaks in VS Code, and @helin24 may want to do the same for IntelliJ. If both are good I'll open the same in DDS. |
This still works in VS Code. I'll make a start on the DDS PR tomorrow. @helin24 I don't anticipate the changes since you last tested (which I believe is just wrapping the router call in |
@DanTup we don't need to test again; thanks for checking |
I see some code in here that seems to assume all paths will start with If we don't expect the |
CC @bkonyi ☝️ |
bbcabd0
to
0aee389
Compare
I've rebased this, and pushed DDS changes here: https://dart-review.googlesource.com/c/sdk/+/239082/ This PR must not roll into the SDK without the changes above first landing, or DevTools will break. I do not know how g3 uses this and cannot test, but I've tested this by:
I concluded that serving always at |
@kenzieschmoll @bkonyi I've not been able to track down why this change fails with old-style (fragment) URLs. It seems that at some point during initialisation (after switching to UrlPathStrategy, although exactly when seemed inconsistent even if I added lots of delays) the fragment was being dropped. As a fix, I decided that the best thing would be to detect legacy URLs right at the start, and redirect (with I've pushed that change to this PR so they'll need reviewing. Since it's been a while since this was started, a summary: DDS ChangeCL: https://dart-review.googlesource.com/c/sdk/+/239082/
I believe these changes are safe to land before the DevTools changes (the opposite is not true). DevTools ChangeThis PR
These changes require the serve has the changes above to function correctly. TestingTo test, I did:
Things I've tested:
Things I'm not able to test:
Future ChangesAfter both changes are landed, further changes to be made:
|
Pushed a fix for these, though for some reason I don't see these lints locally (nor can I see where |
This lint was enabled in a recent PR. If you merge master you should see the lint warnings (you may have to restart the analysis server or your IDE if the change is not picked up automatically). |
Ah, that's what it was. For some reason I thought GH Actions always ran the PR as it was on the source branch, but I can see from the logs that it merges master in first (which is better, I just didn't realise it did). Thanks! |
Tested changes in google3. Google3 does not have a context where devtools is served under |
@kenzieschmoll I merged master into this (there were some conflicts because url_utils was removed, but I'd added to it here, so this brings it back). Do you need to do anything in g3 before landing this (the DDS change has landed)? I see #3585 (comment) but suspect that needs doing as it's rolled into g3? |
Nope, I have a g3 CL ready to go that applies your changes to the g3 handler. You are free to land this. |
/// This is a bit of a hack, as we have file paths instead of the explicit | ||
/// "package:uris" we'd like to have. This will be problematic for a use case | ||
/// such as "packages/my_package/src/utils/packages/flutter/". | ||
String getSimplePackageUrl(String url) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you remove this method and associated tests? (essentially removing everything that was removed as part of https://github.com/flutter/devtools/pull/3932/files#diff-0fb55973e4befafb1d8f5ee26a619a6500f6524ef0dfcf2c252f62aa0644076f)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, good catch. I had to abort/re-do the merge and apparently didn't re-remove it the second time 😞
@kenzieschmoll I did another final test and this all looked good, so I've landed it. Anyone running the Please ping me (and/or revert) if you think this has caused any serious issue. If you let me know once this version of the frontend has landed in the SDK, I'll un-skip those tests that rely on the |
This changes the app to use the PageUrlStrategy in Flutter, which means URLs will just be standard like
/foo
instead of being added to the fragment like/#/foo
.@kenzieschmoll this seems to work well from my testing, including from VS Code (with a small tweak I'll ship in the next week or so), although I'm not certain there aren't pages with unusual navigation I may have missed.
Some things I'm not certain but should be checked before merging though"
defaultHandler
in the server... I've had to extenddefaultHandler
to be able to serve upindex.html
when a request comes in for something like/memory
, because although navigations are usually done client-side, it's possible that the user hits Refresh or we try to launch directly on to a page which will now send/page_id
to the server instead of just/
which won't otherwise get the contents ofindex.html
to launch the Flutter app.I'm not sure who best knows the answer to these questions though.
Fixes #2475.