-
Notifications
You must be signed in to change notification settings - Fork 327
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
Ship DevTools with dart2wasm #7856
Comments
@kenzieschmoll – keep in mind, we can use query param magic to force loading certain versions. So if there are contexts where wasm won't work, we can just disable them. Or we can make loading the wasm version opt-in for testing, etc. |
Ha! just read your last bullet. 🤦 |
The current version of VS Code uses Chromium v120 which sounds like it should support this. However, I don't know if there are things in Electron/VS Code themselves that might impact the user of this. @kenzieschmoll what's the easiest way for me to build DevTools using WASM (can I do it through And when it is running, how do I confirm it is using the wasm version and didn't fall back to js? |
Patch the changes from #7867 and https://dart-review.googlesource.com/c/sdk/+/369100. Then run If the wasm changes are picked up, you should see |
IntelliJ uses JxBrowser version 7.38.2 currently, which includes Chromium 124.0.6367.92 and should support WasmGC. It's hard for me to tell what version of JCEF IntelliJ uses when that option is chosen by user setting, but JCEF is a few versions behind the CEF library, which currently is using Chromium 125 (https://cef-builds.spotifycdn.com/index.html). In summary I think either implementation of embedded browser will be fine for wasm. |
@yjbanov the sequencing will likely be that we'll work on shipping devtools in wasm in google after we decide to ship flutter web in wasm in google3 |
The first has already landed but I patched in the second. I added "--wasm" to my However if I open in an external browser it loads the wasm version, however it throws and the app doesn't load: I presume the first issue is that whatever is being used to detect whether wasm is available is failing. @kevmoo is there an easy way for me to review (or step through) these conditions? Looking through
However if I run that myself in the console, it appears to return |
Seems like the issue is that The docs here confirm the headers in the CL above are required, but I see those are also set: It's not clear to me why this value is |
I tracked this back to microsoft/vscode#186614. It seems cross-origin-isolatation is currently disabled by VS Code. When it was enabled the were performance issues that resulted in it being reverted. I tried running Which seems to be because another header is not present: I don't know the implications of adding that header. |
Yes, if you're loading the app in an iframe, you will need to set a CORP header for the child document if you want cross origin isolation (which is needed for the multi-threaded rendering that the skwasm renderer does). I don't know exactly how the embedding of this works with VS Code. I think |
Thanks! Adding that header on its own didn't work, but then I found I needed This is the same error I posted above when running outside of VS Code. It's not clear to me if that's a DevTools or wasm bug? |
Bug: flutter/devtools#7856 Change-Id: I854fbaad9c1e477c3218bd159cd1a6db1aae8e74 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369100 Reviewed-by: Kevin Moore <[email protected]> Commit-Queue: Kenzie Davisson <[email protected]> Reviewed-by: Ben Konyi <[email protected]>
I can't reproduce on Mac, so I am wondering if this is a Windows issue with wasm. CC @eyebrowsoffire |
@DanTup Could you try building again with |
@eyebrowsoffire that flag didn't seem to work:
I tried
The code for that method is here:
The response from the server appears to be an empty string: Which I guess is coming from here: devtools/packages/devtools_shared/lib/src/server/server_api.dart Lines 70 to 72 in 56dcf74
So possibly this code here is triggering the exception? // A return value of 'null' implies Flutter tool has never been run so
// return false for Flutter GA enabled.
final responseValue = json.decode(resp!.body);
enabled = responseValue ?? false; |
Yes, sorry, I meant There are no casts in that function from the user code that I can see. I wonder if something is being inlined? You can also pass |
It's assigning Using
|
Since that code looks bogus to me, I retried in non-wasm mode and I see errors in the console - however unlike the wasm version, it doesn't stop DevTools loading (which is why I didn't notice it before). In wasm mode, I just get a white page with nothing rendered, but with JS DevTools loads and appears to function. (@kenzieschmoll this seems like a bug though - that API seems to be hard-coded to return an empty string and the code doesn't seem to handle empty strings, it assumes null or a boolean?) |
Yes this regressed recently. Fix is here: #7896 |
@DanTup now that the regression with accessing the Flutter store file has been fixed, are you able to verify whether the wasm build works properly when embedded in VS Code now? |
cross-origin-isolate is still gated with a flag in VS Code (so normal users can't get a wasm version), but if I:
Then it loads: However, I can't interact with the inspector.. clicking on items in the tree just doesn't do anything (no visible selection or anything). I do now have this error in the console, though it appears as the page loads (not when I click) so I'm not sure it's related: However, if I open externally in the browser, then all is good (clicking in the inspector works), so it does seem like there's more broken in VS Code (I don't know if this might be why COI is still behind a flag or unrelated). I'll need to do some more debugging to try and figure out what's wrong here. |
@DanTup – the cast is likely here:
How hard is it to create a |
Ah, thanks for the pointer. I can just use the dev tools to see the network response - and it's a string: Looks like this was actually fixed recently via #7997 but I didn't have a I wasn't expecting it, but re-running with that fix included I can use the inspector tree fine :) Maybe the release notes overlay was partially there absorbing the clicks or something? 🤷♂️ So, in summary:
Then it does appear to work (at least in my limited testing of clicking around the inspector). I don't know if/when VS Code will enable COI by default though (there's an issue at microsoft/vscode#186614 that I think is related). |
Is there a way we can detect whether this is enabled, and fallback to using the dart2js version of DevTools if it is not? |
@kenzieschmoll – we'll have to ask @eyebrowsoffire – or just try it out. I'm pretty sure we do automatically fallback in most failure cases, just not sure of this one. |
This already happens, because |
But, I think we do need to add that extra header in to the DevTools server, otherwise I think we could load the WASM version but then fail with the error shown above at #7856 (comment). |
…ASM when embedded See flutter/devtools#7856 (comment) Change-Id: If9d19eef8f8475e3dddb70db55e6b72e0ceb6f08 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374945 Reviewed-by: Kenzie Davisson <[email protected]> Reviewed-by: Ben Konyi <[email protected]> Commit-Queue: Ben Konyi <[email protected]>
Note: We do fall back to CanvasKit + JS if |
This work is complete. DevTools + Wasm will be shipped as an opt-in feature behind a DevTools setting for the Q4 Dart / Flutter stable release. We will aim to turn this on by default for the Q1 2025 stable release, tracked here: #8395 |
The DevTools codebase is prepared for building DevTools with dart2wasm thanks to the unblocking work here.
There are still a few requirements that we need to meet before moving this effort forward:
Ensure that the VS Code embedded web views support WasmGC (see background information on Chromium and V8)@DanTup can you confirm?--enable-coi
for VS Code. At this time, this is not something we want to recommend because this may cause performance regressions for VS Code. Until Enable COI for desktop withcredentialless
microsoft/vscode#186614 is fixed, we do not expect users using DevTools embedded inside VS Code to be able to use the wasm build. See comments below for more details.serve
andbuild
commands to use wasm #7867--no-strip-wasm
flag support to build and serve commands. #7888package:source_map_stack_trace
dart-lang/tools#586Compare the dart2wasm DevTools build to dart2js and file any issues that come up.
Blocking:
PointerInterceptor
widget does not behave as intended flutter#151793The text was updated successfully, but these errors were encountered: