Skip to content

Page Flashing After Initial Load #42544

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

Closed
RoyIL opened this issue Jul 1, 2022 · 4 comments
Closed

Page Flashing After Initial Load #42544

RoyIL opened this issue Jul 1, 2022 · 4 comments
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-server ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved

Comments

@RoyIL
Copy link

RoyIL commented Jul 1, 2022

Describe the bug

After the initial page load (i.e. the first time the page is loaded), the Blazor Server website seems to render twice, which creates a weird flickering/flashing effect. Has anyone experience a similar issue before, and is there any way to solve it within the current limitations of Blazor?

Expected Behavior

Page loads without flashing/flickering, even if it is going to take more time to load.

.NET Version

6.0.301

Anything else?

Recording.mp4
@RoyIL RoyIL changed the title Page Flashing after Initial Page Load Page Flashing after Initial Load Jul 1, 2022
@RoyIL RoyIL changed the title Page Flashing after Initial Load Page Flashing After Initial Load Jul 1, 2022
@TanayParikh TanayParikh added area-blazor Includes: Blazor, Razor Components feature-blazor-server labels Jul 1, 2022
@Xyncgas
Copy link

Xyncgas commented Jul 2, 2022

Because blazor updates DOM, instead of providing a static page, there is always something to display before the rendering completes which in my opinion you can just have a black screen in the background so everything looks black making users think it is loading instead of flashing

@RoyIL
Copy link
Author

RoyIL commented Jul 2, 2022

Well, the weird thing is that the flashing happens even when the render mode is set to render-mode="Server" in the _Host.cshtml file. Also @Xyncgas, would you know of a good way to implement that?

@javiercn
Copy link
Member

javiercn commented Jul 2, 2022

@RoyIL thanks for contacting us.

That's expected since the initial render doesn't include content as you are using render-mode="Server". If you prerender, you will only see a flash if you do async work, in which case the content briefly disappears and reappears. You can avoid that by preserving prerendered state on the page and ensuring the second render happens synchronously.

We also have a separate item to avoid doing a second render after prerender all together in most situations, if you are interested, I would suggest you upvote that instead.

#15317

@javiercn javiercn added question ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. labels Jul 2, 2022
@ghost ghost added the Status: Resolved label Jul 2, 2022
@RoyIL
Copy link
Author

RoyIL commented Jul 2, 2022

Hi @javiercn, thanks for your comment! It's actually seems to work the other way around for me! When the render-mode is set to Server and I persist the application state, the flashing seems to almost disappear.

However, when the render-mode is set to ServerPrerendered and I attempt to persist the application state, the flashing keeps occurring! Prior to opening this issue, I only attempted persisting the state with the ServerPrerendered mode.

@RoyIL RoyIL closed this as completed Jul 2, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Aug 1, 2022
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-server ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved
Projects
None yet
Development

No branches or pull requests

4 participants