Checking hardware acceleration availability? (Testing available)
Asked Answered
D

1

4

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.

Deciduous answered 9/3, 2013 at 12:53 Comment(2)
I could imagine two options that I both tried in this fiddle but (luckily?) chrome doesn't allow to 'load a local resource' which basically is what I expect from a browser...Mareah
Good test. I spent a long time searching for solutions before posting this question. I can't believe I am the first to want this!Deciduous
U
2

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

Underside answered 11/3, 2013 at 0:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.