[flutter_tools] Update to latest dwds APIs#51004
[flutter_tools] Update to latest dwds APIs#51004jonahwilliams merged 68 commits intoflutter:masterfrom
Conversation
| return null; | ||
| } | ||
| } | ||
| var module = window.\$requireLoader.urlToModuleId.get(url) |
There was a problem hiding this comment.
It looks like the dartLoader doesn't exist anymore - should I be using the requireLoader? Otherwise I'm not sure exactly what this code should look like. I tried a few permutations but they all crash
There was a problem hiding this comment.
You shouldn't need either. You are correct that the dartLoader was removed and replaced with reqruireLoader. However, package:dwds now embeds the requrieLoader in the entry bootstrap.
See here:
https://github.com/dart-lang/webdev/blob/master/dwds/lib/src/handlers/injected_handler.dart#L74
And here:
https://github.com/dart-lang/webdev/blob/master/dwds/lib/src/loaders/require.dart#L179
Let me know if removing this doesn't fix your problem.
There was a problem hiding this comment.
Removing SGTM, but I don't see any handling of the dartStackTraceUtility in the new dwds code
There was a problem hiding this comment.
@jakemac53 said that logic was safe to remove. He can probably provide more context.
There was a problem hiding this comment.
Another difference is that If I throw an unhandled exception, before the stackTraceMapper would first be called with a url like http://localhost:53973/dart_sdk.js that would be mapped to the module name dart_sdk. Now it's failing with http://localhost:53973/something/dart_stack_trace_mapper.js which might indicate something isn't getting set up correctly. Still investigating
There was a problem hiding this comment.
I think it needs to be added by build_web_compilers - it has its own version. Flutter also i think has its own version.
There was a problem hiding this comment.
Is there an equivalent to this line I need to do for the requireLoader?
I'm currrently using the following code:
dart_sdk._isolate_helper.startRootIsolate(() => {}, []);
if (window.\$dartStackTraceUtility && !window.\$dartStackTraceUtility.ready) {
window.\$dartStackTraceUtility.ready = true;
let dart = dart_sdk.dart;
window.\$dartStackTraceUtility.setSourceMapProvider(function(url) {
url = url.replace(window.\$dartUriBase, '');
var module = window.\$requireLoader.urlToModuleId.get(url);
if (!module) return;
return dart.getSourceMap(url);
});
}
But I'm only get url from the stack trace mapper itself, which leads me to believe that I set it up incorrectly.
There was a problem hiding this comment.
There is not but I'm happy to add it to package:dwds somewhere here: https://github.com/dart-lang/webdev/blob/master/dwds/lib/src/loaders/require.dart#L222
There was a problem hiding this comment.
Its not so much what API goes into dwds, there is a slight bug now since we use the stack trace mapper from the SDK. This expects there to be a field called window.$dartLoader.rootDirectories:
https://github.com/dart-lang/sdk/blob/master/pkg/dev_compiler/web/stack_trace_mapper.dart#L39
All stack traces actually are crashing in the stack trace mapper now. I can work around by defining this in the bootstrap script myself
There was a problem hiding this comment.
Ahh I see. I'm thinking we just duplicate window.$dratLoader.rootDirectories in the DWDS bootstrap for now and eventually clean up the SDK.
|
Everything seems to working for the most part, except the hot restarts are requesting more resources than necessary and doing full page reloads. I think I've misconfigured something with the modules/digests, but I'm not sure where |
|
So far I've discovered that the special entrypoint in temp seems to be throwing off the module naming. It works a bit better if I stick |
|
@annagrin has been running into similar issues while testing. Let's put this on hold for now and I'll dig through the issue with her. |
|
It might help if we could relax the requirement to use either a multiroot scheme or a package scheme. That would at least simplify some of the paths used and server configuration. |
99259cf to
ea055df
Compare
| bool useBuildRunner = false, | ||
| String coverage, | ||
| bq.TabledataResourceApi tableData, | ||
| bool forceSingleCore = false, |
There was a problem hiding this comment.
Without this change, we would try to spin up multiple chrome instances and stall. I'm also suspicious that some of the previous flakes in integration tests were caused by having multiple flutter_tester shells active.
There was a problem hiding this comment.
This is interesting. Do you not use the concurrency parameter of package:test?
There was a problem hiding this comment.
We do, but by default it gets set to the number of cores that the bot has.
| bool useBuildRunner = false, | ||
| String coverage, | ||
| bq.TabledataResourceApi tableData, | ||
| bool forceSingleCore = false, |
There was a problem hiding this comment.
This is interesting. Do you not use the concurrency parameter of package:test?
| @override | ||
| Future<String> dartSourceContents(String serverPath) { | ||
| Future<String> dartSourceContents(String serverPath) async { | ||
| if (serverPath == null || serverPath.trim().isEmpty) { |
There was a problem hiding this comment.
This is an interesting guard. Not that it's wrong by does package:dwds ever request null paths?
There was a problem hiding this comment.
I noticed that devtools was requesting null paths before the change to the tracked library names. I will re-verify this
There was a problem hiding this comment.
Updated - we only get a null path when devtools tries to request the web-entrypoint file with the org-dartlang-app scheme. I made this check more specific, but we should probably fix/hide this file otherwise
| document.head.appendChild(requireEl); | ||
|
|
||
| // Invoked by connected chrome debugger for hot reload/restart support. | ||
| window.\$hotReloadHook = function(modules) { |
| return dart.getSourceMap(module); | ||
| }); | ||
| } | ||
| dart_sdk._isolate_helper.startRootIsolate(() => {}, []); |
There was a problem hiding this comment.
I'm not familiar with this. What is this for?
There was a problem hiding this comment.
I think I copied this from the build_runner tooling, so its probably just a straggler. Will remove once I verify its not necessary
There was a problem hiding this comment.
Not necessary removed
| // Require JS configuration. | ||
| require.config({ | ||
| waitSeconds: 0, | ||
| window.\$dartLoader = {}; |
There was a problem hiding this comment.
Is the dartLoader stuff required? Shouldn't be anymore.
There was a problem hiding this comment.
We still need this since we're using the stack trace mapper from the SDK, and that code unconditionally refers to these getters
There was a problem hiding this comment.
Oh yes. Hmmm. We should reconsider that at one point.
| tempDirectory = createResolvedTempDirectorySync('debugger_stepping_test.'); | ||
| }); | ||
|
|
||
| test('Web debugger can step over statements', () async { |
| final String suffix = Platform.isWindows && subshard == 'commands' | ||
| ? 'permeable' | ||
| : ''; | ||
| final bool forceSingleCore = Platform.isLinux && subshard == 'integration'; |
There was a problem hiding this comment.
Why only Linux? (Add a comment explaining)
There was a problem hiding this comment.
Added comment
| bool useBuildRunner = false, | ||
| String coverage, | ||
| bq.TabledataResourceApi tableData, | ||
| bool forceSingleCore = false, |
| } else { | ||
| cpus = 2; // Don't default to 1, otherwise we won't catch race conditions. | ||
| } | ||
| // Integration tests that depend on external processes like chrome |
| final bool hasPackage = line.startsWith('package'); | ||
| final RegExp parser = hasPackage | ||
| ? RegExp(r'^(package:.+) (\d+):(\d+)\s+(.+)$') | ||
| ? RegExp(r'^(package.+) (\d+):(\d+)\s+(.+)$') |
There was a problem hiding this comment.
Consider adding a comment for this regexp. Separately, where would 'package' not be followed by ':' ?
There was a problem hiding this comment.
I filled a bug on it here with more details: #52685
There was a problem hiding this comment.
kk. Maybe link to that issue in a comment here.
| ); | ||
| } | ||
| } on Exception catch (err) { | ||
| globals.printError(err.toString()); |
There was a problem hiding this comment.
If we can't give any more information here, and it will fail later regardless, should this just be a printTrace() ?
There was a problem hiding this comment.
Commented below
| } | ||
| } on Exception catch (err) { | ||
| globals.printError(err.toString()); | ||
| return OperationResult(1, err.toString()); |
There was a problem hiding this comment.
Will including the err.toString() in the OperationResult case it to be printed twice?
There was a problem hiding this comment.
I've just updated here and above to be fatal errors, so we should print the message with a throwToolExit.
I can't think of a case where we hit a HotRestartException or WipError that we could recover from, so getting people out of the tool is likely better than getting stuck in a loop of prompting the user to "Try again after fixing the above error"
| sdkRoot, | ||
| '--incremental', | ||
| '--target=$targetModel', | ||
| '--debugger-module-names', |
There was a problem hiding this comment.
Are there any comments worth adding here about what this flag does?
There was a problem hiding this comment.
Added a comment. This is a breaking change flag, so once all of the tooling is updated we can make it the default and remove
There was a problem hiding this comment.
Is there an issue we can link to for the migration?
| .toList(), | ||
| workingDirectory: _projectFolder.path, | ||
| environment: <String, String>{'FLUTTER_TEST': 'true'}, | ||
| environment: <String, String>{'FLUTTER_TEST': 'true', 'FLUTTER_WEB': 'true'}, |
There was a problem hiding this comment.
Consider documenting here that this achieves the effect of flutter config --enable-web.
zanderso
left a comment
There was a problem hiding this comment.
lgtm. when this makes it to dev/, monitor crash logging for new crashers.
|
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Update to latest dwds APIs, moving back to dwds driven hot restart and enabling future work on expression evaluation.
@grouma
@annagrin
Fixes #52193