Checking hardware acceleration availability? (Testing available)

烂漫一生 提交于 2019-12-19 09:02:33

问题


I've written CSS that uses -webkit-transform, -webkit-perspective and several similar. My design looks the bees knees on machines where hardware acceleration is available but is practically unusable when not. How can I check hardware acceleration availability and provide fallback CSS?

Side note: Run chrome://gpu-internals/ to manually check for availability.


回答1:


Sadly, the answer seems to be 'you can't (yet)'.

The Modernizr project lists HW acceleration amongst its 'undetectables': https://github.com/Modernizr/Modernizr/wiki/Undetectables.

Part of the problem seems to be that HW acceleration is used on a case-by-case basis when rendering anything on the page. So, even though a browser may theoretically support HW acceleration, whether or not it will be used for any given operation (translation, transition, repaint, etc) won't be known in advance.

You could imagine a detection scheme that used profiling to detect the change in performance with/without HW acceleration - but the things that use HW acceleration happen in a layer out of the page's view. You can't, for instance detect the frame-rate of a transition, even if you could reliably enable/disable HW acceleration.

The webkit rendering API looks like the place this information might be available, but it doesn't look to be accessible via page-level Javascript (even though nodes in the DOM have RenderObjects attached to them): https://www.webkit.org/blog/114/webcore-rendering-i-the-basics/

Looks like the only viable option is user-agent sniffing against a list of known accelerated browsers (yuck).



来源:https://stackoverflow.com/questions/15310894/checking-hardware-acceleration-availability-testing-available

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!