Checking hardware acceleration availability? (Testing available)

别等时光非礼了梦想. 提交于 2019-12-01 07:37:06

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).

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