Skip to content
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

[Blazor] Maui windows apps can't find _framework/blazor.modules.json #15234

Closed
javiercn opened this issue Jun 22, 2022 · 10 comments
Closed

[Blazor] Maui windows apps can't find _framework/blazor.modules.json #15234

javiercn opened this issue Jun 22, 2022 · 10 comments
Assignees
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView delighter platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@javiercn
Copy link
Member

For some reason the apps fail to find the file and as a result initializers don't load. It works fine in other platforms like Android

@gerneio
Copy link

gerneio commented May 9, 2023

This isn't working for me on Android or Windows MAUI currently (unable to test iOS). Neither beforeStart or afterStarted initializers are working (as described here). Using latest net7.0 workloads:

> dotnet workload list

Installed Workload Id      Manifest Version       Installation Source
--------------------------------------------------------------------------------
android                    33.0.46/7.0.100        SDK 7.0.200, VS 17.5.33530.505
ios                        16.2.2054/7.0.100      SDK 7.0.200, VS 17.5.33530.505
maccatalyst                16.2.2054/7.0.100      SDK 7.0.200, VS 17.5.33530.505
maui-android               7.0.81/7.0.100         VS 17.5.33530.505
wasm-tools                 7.0.5/7.0.100          VS 17.5.33530.505
maui-windows               7.0.81/7.0.100         VS 17.5.33530.505
maui-maccatalyst           7.0.81/7.0.100         VS 17.5.33530.505
maui-ios                   7.0.81/7.0.100         VS 17.5.33530.505

Note that I tried this both with putting the {ASSEMBLY NAME}.lib.module.js file under the MAUI project wwwroot folder, as well as under an RCL's wwwroot folder, but same results either way. I do see that the {MAUI_PROJECT}.modules.json file is being created in the output wwwroot folder (which also means I'm naming those files correctly).

Ultimately, after stepping through the _framework/blazor.webview.js for a bit, what I found was that these initializers are supposed to be loaded via the importInitializersAsync JS method, which uses the _framework/blazor.modules.json to determine which JS files needs to be run as initializers. On Android, using CDT and looking at the network tab, I can see that the _framework/blazor.modules.json file is returned as an empty array (same for the Windows app). Both network requests have a status code of 200.

Just wanted to add my experiences, as well as inquire if there are any plausible workarounds? Really what I'm after is the ability to trigger a JS specific workload BEFORE Blazor.Start() is called, or at least before any of the .NET ecosystem is loaded. However, when using the MAUI BlazorWebView, Blazor.Start() is called automatically therefore the autostart=false mechanism can't be used as in WASM.

@ghost
Copy link

ghost commented May 23, 2023

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@mkArtakMSFT mkArtakMSFT added the area-blazor Blazor Hybrid / Desktop, BlazorWebView label May 23, 2023
@mkArtakMSFT mkArtakMSFT transferred this issue from dotnet/aspnetcore May 23, 2023
@mkArtakMSFT mkArtakMSFT added the t/bug Something isn't working label May 23, 2023
@vnbaaij
Copy link

vnbaaij commented Jun 1, 2023

@mkArtakMSFT, @javiercn We are running into this when using the Blazor Fluent UI library in A Blazor Hybrid project (see microsoft/fluentui-blazor#404 (comment)). Any indication on if/when/how this is solved? And are there known workarounds (besides building your own Microsoft.AspNetCore.Components.WebView :))?

@vnbaaij
Copy link

vnbaaij commented Jun 10, 2023

@mkArtakMSFT, @javiercn, one of our contributors has created a nice workaround for this. See https://github.com/microsoft/fluentui-blazor#tempory-workaround-for-maui-issues for the details.

@LuohuaRain
Copy link

is this PR relevant?
dotnet/aspnetcore#48594

@hml-coder
Copy link

Issue also exists with RCL component hosted in BlazorWebView in Windows Forms and Wpf projects. Workaround mentioned by @vnbaaij is required.

@Jarek300
Copy link

Jarek300 commented Oct 5, 2023

Is this problem fixed in .NET 8?

Do Blazor JS module initializers work in NET 8 in Blazor Hybrid? Is loading file wwwroot/{AppName}.lib.module.js in Blazor hybrid / BlazorWebView fixed?

@Zhanglirong-Winnie Zhanglirong-Winnie added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Dec 13, 2023
@Zhanglirong-Winnie
Copy link
Collaborator

Verified this issue with Visual Studio Enterprise 17.9.0 Preview 2. Can repro this issue.

@Eilon Eilon removed this from the .NET 8 + Servicing milestone Dec 15, 2023
@javiercn
Copy link
Member Author

javiercn commented Feb 9, 2024

This should be fixed in #18953

@javiercn javiercn closed this as completed Feb 9, 2024
@datvm
Copy link

datvm commented Feb 9, 2024

@javiercn Hi when is this fix released? And when it is released, do the old projects that use the workaround need to remove it? We have tons of MAUI projects that is currently using the initializersLoader.webview.js workaround

@github-actions github-actions bot locked and limited conversation to collaborators Mar 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView delighter platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

12 participants