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

Javascript 会不会阻塞 CSS Animation的执行? #31

Open
OPY-bbt opened this issue Jan 19, 2020 · 0 comments
Open

Javascript 会不会阻塞 CSS Animation的执行? #31

OPY-bbt opened this issue Jan 19, 2020 · 0 comments

Comments

@OPY-bbt
Copy link
Owner

OPY-bbt commented Jan 19, 2020

现代浏览器已经将CSS Animation 动画 从 UI thread 分离开了。但是也不是绝对不阻塞,而是分情况的。
起因是今天遇到了一个神奇的情况,当JS主线程忙绿时,为什么有的loading动画不会被阻塞,而有的会。
最后发现被阻塞的CSS动画里添加了颜色渐变。这让我想起了浏览器工作原理里的一幅图。
975fcbf7f83cc20d216f3d68a85d0f37
图中可以看到,如果更改颜色,发生在paint过程中,而paint执行在主线程。但是如果只是用transform旋转则只会执行在合成线程。

知识虽然知道,但实际遇到问题还需要思考一下。缺少知识点与应用场景的串联。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant