Question

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.

No correct solution

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top