jspblm
jspblm

Reputation: 157

How to get the video card driver name using javascript browser side?

I want to get a string like: Intel Open Source Technology Center Mesa DRI Intel(R) HD Graphics 520 (Skylake GT2)

Only using javascript on the browser. I know that a library from augur.io can find that value but I need a open source solution or to know what js method can be used.

Upvotes: 12

Views: 10620

Answers (1)

user128511
user128511

Reputation:

You can use WebGL's WEBGL_debug_renderer_info extension. Though (a) the user might not have WebGL and (b) the extension might not be available depending on the browser.

function getVideoCardInfo() {
  const gl = document.createElement('canvas').getContext('webgl');
  if (!gl) {
    return {
      error: "no webgl",
    };
  }
  const debugInfo = gl.getExtension('WEBGL_debug_renderer_info');
  return debugInfo ? {
    vendor: gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL),
    renderer:  gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL),
  } : {
    error: "no WEBGL_debug_renderer_info",
  };
}

console.log(getVideoCardInfo());

per @jaromanda X's comment this extension was controversial. Some people maintain that knowing the GPU is a privacy issue. For example the MacPro has (or had) a MacPro only GPU. The MacPro was like a $6000 machine so by knowing the person's GPU you gained some idea that they have $$$$. As in "if GPU = MacPro's GPU then show ad for expensive things". Similarly it's one more piece of info to ID your particular machine.

The counter arguments are many

  • You could to some degree already figure out of the user has a high end GPU by checking the webgl parameters, things like max texture size, number of uniforms supported, etc. Something required to make WebGL useful.

  • In regards to using the info to ID a machine you can already get most of that info by fingerprinting the WebGL parameters and rendering artifacts.

  • For tech support it's often important to know the user's GPU and asking a non tech users to dig through their system to figure it out is not very helpful.

  • Some drivers have bugs and while it's the browser's job to work around those bugs it often takes 3 to 6 months for a bug to be fixed and for that fix to percolate to the release version of a browser. In the meantime companies need a way to work around the bugs which is often in the form of "If GPU = X do Y" where Y could be anything from "use a different technique" to "don't use WebGL for this user". This is what Google Maps does. If the particular GPU/Driver is known to be unstable then Google Maps will fall back to a canvas2d version with much less features.

  • In relation to the last 2 points many websites track errors and or crashes as best they can. By tracking the GPU they can see if crashes correlate to a specific GPU/Driver and implement workarounds.

Note: S.O. really isn't the place to debate whether or not this extension is good or bad. The info above is mostly just FYI. Both sides have their merits.

Upvotes: 26

Related Questions