Skip to content

Blazor server renders twice resulting in static HTML animation showing twice #39740

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
aryehsilver opened this issue Jan 25, 2022 · 5 comments
Closed
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-blazor-server feature-rendering Features dealing with how blazor renders components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved
Milestone

Comments

@aryehsilver
Copy link

aryehsilver commented Jan 25, 2022

All over the web there have been discussions about how Blazor server hits the OnInitialized method twice, once in prerendering and again after the connection has been established in the browser.
All the above address data and how to preserve the state after prerendering.

I am using .Net 6 and have a pure static HTML razor component that has an animation done in CSS. The animation occurs twice.
In development this occurs so fast that it is almost not conceivable to the user. The same when live but using a strong internet connection. When accessing it via a slow internet connection the animation occurs twice.

I have created a reproducible solution which shows the effect https://github.com/aryehsilver/BlazorDoubleRenderTest.

I also have published live where you can see it in action (using a slow connection) https://projects.aryehsilver.co.uk/double-render.

Here is a clip of the animation in action.

Blazor.Double.Render.mp4
@TanayParikh TanayParikh added area-blazor Includes: Blazor, Razor Components feature-blazor-server feature-rendering Features dealing with how blazor renders components labels Jan 25, 2022
@javiercn
Copy link
Member

@aryehsilver thanks for contacting us.

I believe this is the result of the fact that when we render in interactive mode we don't reuse the existing DOM nodes and instead we replace the old DOM nodes with new DOM nodes. I believe a similar thing happens with images and other elements.

It's not really an artifact of the "double" render (static prerender followed by an interactive prerender) but an artifact of how we reconcile the existing prerendered nodes with the new rendered nodes.

@javiercn javiercn added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Jan 25, 2022
@aryehsilver
Copy link
Author

@javiercn thanks for clarifying that.

It does seem to be more of an issue on slower connections where there is noticeable time for the reconciliation of the nodes.
Are there any future plans to get around this issue?
Currently how can we create a better user experience?

@mkArtakMSFT mkArtakMSFT added this to the Backlog milestone Jan 25, 2022
@ghost
Copy link

ghost commented Jan 25, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@3hxx
Copy link

3hxx commented Jul 23, 2022

I'm also experiencing the same problem with the entrance animations for html elements. How can we provide make this better for our users? We only want the animation to play once rather than playing once then half way through resetting and playing again

@danroth27
Copy link
Member

We are tracking addressing this issue as part of #42561

@danroth27 danroth27 added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Nov 21, 2022
@ghost ghost added the Status: Resolved label Nov 21, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Dec 22, 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 enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-blazor-server feature-rendering Features dealing with how blazor renders components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved
Projects
None yet
Development

No branches or pull requests

6 participants