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] Use JSImport for lazy loading assemblies #46437

Merged
merged 6 commits into from
Feb 7, 2023

Conversation

pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Feb 3, 2023

Motivation

  • The current getLazyAssemblies is implemented using legacy/obsolete JS interop.
  • legacy interop has problems with multi-threading and uses unsupported API.
  • legacy interop is not CSP compliant

Contributes to #37787

Description

  • use new generated JavaScript interop with [JSImport]
  • moved async parallel download to C# side
  • only one allocation & copy of the DLL bytes from fetch buffer directly to wasm memory.
  • the new implementation is loading DLLs asynchronously as they arrive, which should be faster overall

@pavelsavara pavelsavara added the feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly label Feb 3, 2023
@pavelsavara pavelsavara added this to the 8.0 milestone Feb 3, 2023
@pavelsavara pavelsavara self-assigned this Feb 3, 2023
@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Feb 3, 2023
@pavelsavara pavelsavara changed the title [WIP] Use JSImport for lazy loading assemblies [blazor] Use JSImport for lazy loading assemblies Feb 6, 2023
@pavelsavara pavelsavara marked this pull request as ready for review February 6, 2023 10:00
@pavelsavara pavelsavara requested a review from a team as a code owner February 6, 2023 10:00
@pavelsavara
Copy link
Member Author

CI Could not connect to security.ubuntu.com:80 (185.125.190.36). - connect (111: Connection refused) is unrelated

Copy link
Member

@maraf maraf left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Member

@ilonatommy ilonatommy left a comment

Choose a reason for hiding this comment

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

I like it, the new version is easier to read. The only idea I got was: can we have names in resources in plural form? resources.lazyAssembly, resources.pdb, resources.assembly -> resources.lazyAssemblies, resources.pdbs, resources.assemblies

@pavelsavara
Copy link
Member Author

I like it, the new version is easier to read. The only idea I got was: can we have names in resources in plural form? resources.lazyAssembly, resources.pdb, resources.assembly -> resources.lazyAssemblies, resources.pdbs, resources.assemblies

Those are from blazor.boot.json and I think we may need to keep it backward compatible.

Copy link
Member

@MackinnonBuck MackinnonBuck left a comment

Choose a reason for hiding this comment

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

LGTM! Just added some nits, feel free to ignore if you disagree with the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants