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: Prerendered HeadContent gets replaced on WASM startup even if it is not changed #42527

Closed
hakenr opened this issue Jul 1, 2022 · 2 comments
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-builtin-components Features related to the built in components we ship or could ship in the future feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved

Comments

@hakenr
Copy link
Contributor

hakenr commented Jul 1, 2022

As the WebAssembly application in browser activates it replaces server-prerendered HeadOutlet content with new (same) content (probably new instances of the DOM objects). Which causes UI flickering if you use HeadContent for injecting CSS links (e.g. to support theme switching).

Expected Behavior

Similar to rendering of regular components, the HeadOutlet should not replace the content if it did not change (in comparison to the server prerendered version).

Steps To Reproduce

Blazor WebAssemblyPrerendered mode (ASP.NET Core Host, server prerendering, ...).
Put a component in MainLayout.razor with some content.
When you start the application, the HeadOutlet prerendered content contains the content from HeadContent (correct).
But as the WebAssembly application in browser activates it replaces the HeadOutlet content with new (same) content (probably new instances of the DOM objects).
Which causes UI flickering if you use HeadContent for injecting CSS links (e.g. to support theme switching).

repro repo: https://github.com/hakenr/BlazorHeadContentPrerenderingFlicker
repro site: https://blazorheadcontentprerenderingflicker.azurewebsites.net/

.NET Version

6.0.6

@hakenr hakenr changed the title Blazor: Prerendered HeadContent gets replaced on WASM startup although it is not changed Blazor: Prerendered HeadContent gets replaced on WASM startup even it is not changed Jul 1, 2022
@hakenr hakenr changed the title Blazor: Prerendered HeadContent gets replaced on WASM startup even it is not changed Blazor: Prerendered HeadContent gets replaced on WASM startup even if it is not changed Jul 1, 2022
@javiercn javiercn added area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-blazor-builtin-components Features related to the built in components we ship or could ship in the future labels Jul 1, 2022
@javiercn
Copy link
Member

javiercn commented Jul 4, 2022

@hakenr thanks for contacting us.

I believe this happens because as you mention, we replace the entire contents of the DOM after prerendering.

I have filed a separate issue here to provide more context on other areas where this behavior is problematic as well as some ideas on how we can improve this area.

We are going to use the other issue to track improvements in this space, so I'm going to close this issue and I would suggest you go and upvote the issue referenced here so that we can gather customer interest on it.

@javiercn javiercn added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Jul 4, 2022
@ghost ghost added the Status: Resolved label Jul 4, 2022
@ghost
Copy link

ghost commented Jul 5, 2022

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

@ghost ghost closed this as completed Jul 5, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Aug 4, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-builtin-components Features related to the built in components we ship or could ship in the future feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved
Projects
None yet
Development

No branches or pull requests

2 participants