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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSR/Universal: styles flicker on lazy-load module rendering #32855

Closed
jbogarthyde opened this issue Sep 25, 2019 · 10 comments
Closed

SSR/Universal: styles flicker on lazy-load module rendering #32855

jbogarthyde opened this issue Sep 25, 2019 · 10 comments
Assignees
Labels
area: router area: server Issues related to server-side rendering freq2: medium P4 A relatively minor issue that is not relevant to core functions risk: low state: needs eng input type: bug/fix
Milestone

Comments

@jbogarthyde
Copy link
Contributor

馃摎 Docs or angular.io bug report

Description

Universal apps are reported to flicker when lazy-loaded modules are initiated from the server-side. The doc should provide info on how to avoid this problem.

It has to do with how bootstrap and routing interact, causing new styles to be swapped in after initial rendering.
There seem to be several contributing factors, which are still being investigated.

馃敩 Minimal Reproduction

From @Splaktar: It looks like there is still a root issue that needs to be fixed.

What's the affected URL?**

https://angular.io/guide/universal

@rockument69
Copy link
Member

@jbogarthyde : Perhaps you can add a comment on this. As I understand it, you have a closed PR that addresses this issue: 32702. There are also open issues in angular-core: 75 and 1184 that the doc team can't address. Should we mark this for engineering input?

@Splaktar
Copy link
Member

Splaktar commented May 26, 2020

PR #32702 and PR #32707 are related, but do not address this issue.

There is still no content in the Universal Guide about a FOUC (Flash of Unstyled Content) or flickering on page load, nor is there any guidance on lazy loaded modules.

This is already labeled as needing engineering input and that is still the state. In the community, there are no clear best practices here and ideally the Angular team (especially with the work on GSX) should hopefully be able to distill their knowledge (and possibly provide examples) into some best practices that the community can reference (given the caveat that all apps are not created equal).

Also of note, this is an issue that nearly all production-grade Universal apps need to investigate, debug, and troubleshoot. Some guidance here would be very impactful.

@tskweres
Copy link

SSR flickers, any solutions out there?

@Splaktar
Copy link
Member

SSR flickers, any solutions out there?

There is no single solution that works for every app, but the primary set of solutions that can be used are all linked from this issue (and the issues linked within those).

@CaerusKaru CaerusKaru removed the target: patch This PR is targeted for the next patch release label Jun 17, 2020
@arminops
Copy link

arminops commented Aug 16, 2020

Guys. My problem solved with 2 solutions:

Disabling lazyloading and also with loadChildren direct importing module.
loadingChildren: () => AuthModule. No flickering

I removed initialNavigation (Also Lazyloading enabled) - No flickering

How removing initialNavigation affects SSR?

#23427

@jelbourn jelbourn added P4 A relatively minor issue that is not relevant to core functions and removed severity2: inconvenient labels Oct 1, 2020
@adrian-marcelo-gallardo

In my case I solved the issue by configuring initialNavigation: 'enabledBlocking', as documented in: https://angular.io/api/router/InitialNavigation

@gitalvininfo
Copy link

gitalvininfo commented Jan 27, 2021

@adrian-marcelo-gallardo I'm on Angular 10, initialNavigation: 'enabledBlocking' is not defined.

This issue still exist, in my case I have a landing page when first visit, landing page is visible for about 100ms, it is really bad ux for first time visitors of the app.

Already tried solutions like Transferstate but in my case does not meet my expectations to solve the issue. My landing page do not have any XHR request.

I also tried the TransferHttpCacheModule, I notice that first visit, sometimes it loads correctly without the glimpse of landing page, and sometimes it lessens the flicker amount of time for about 20ms but still I can see a glimpse of my landing page, after that it somehow fix my issue, but when I clear my cache, it returns back to previous state which the landing page is visible for about 20ms.

Also tried Preboot as what others is suggesting, but it is not suitable for my app, I have a mat-progress-spinner which acts as loading, when preboot is enabled and I hit F5/refresh my loading icon freezes for a while, it does not animate, which I think is very ugly and after about 1sec it goes back to normal state (app is working as usual like normal angular app).

I'm actually stuck here and I can't just leave it as it is.

@Parsa-Sedigh
Copy link

Angular 11.2 and using initialNavigation: 'enabled' solved the flickering effect for me

@alan-agius4
Copy link
Contributor

Closing as this is documented in https://angular.io/api/router/InitialNavigation

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2022
@alan-agius4 alan-agius4 modified the milestones: Backlog, Fixit H1'2022 Jun 27, 2022
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: router area: server Issues related to server-side rendering freq2: medium P4 A relatively minor issue that is not relevant to core functions risk: low state: needs eng input type: bug/fix
Projects
None yet
Development

No branches or pull requests