Skip to content

Switch from rAF to Promise to fix FOUC in Safari#63

Merged
nkzawa merged 1 commit into
vercel:masterfrom
ericf:safari-fouc
Dec 30, 2016
Merged

Switch from rAF to Promise to fix FOUC in Safari#63
nkzawa merged 1 commit into
vercel:masterfrom
ericf:safari-fouc

Conversation

@ericf

@ericf ericf commented Dec 30, 2016

Copy link
Copy Markdown
Contributor

This fixes the FOUC issue in Safari by switching from requestAnimationFrame() to Promise#then() for the debouncing/batching mechanism. requestAnimationFrame() causes FOUC in Safari, setTimeout() causes FOUC in Chrome, while Promise#then() ensures micro task enqueueing of styles update before paint in Safari, Chrome, and Firefox.

This maintains the same semantics where only the latest call to updateOnClient() causes the rendering of styles by "cancelling" the previously created promises by making them noops.

Fixes #52
/cc @rauchg @nkzawa

@ericf ericf mentioned this pull request Dec 30, 2016
@nkzawa

nkzawa commented Dec 30, 2016

Copy link
Copy Markdown
Contributor

This is awesome ! I didn't notice this solution, thanks 👍

@nkzawa nkzawa merged commit e384734 into vercel:master Dec 30, 2016
@ericf ericf deleted the safari-fouc branch December 30, 2016 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FOUC in Safari

2 participants