如何使用javascript浏览器端获取视频卡驱动程序名称? [英] How to get the video card driver name using javascript browser side?

查看:109
本文介绍了如何使用javascript浏览器端获取视频卡驱动程序名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想得到一个字符串,例如:英特尔开放源技术中心Mesa DRI英特尔(R)HD Graphics 520(Skylake GT2)

仅在浏览器上使用javascript.我知道 augur.io 中的库可以找到该值,但是我需要一个开源解决方案,或者知道可以使用哪种js方法.

解决方案

您可以使用WebGL的WEBGL_debug_renderer_info扩展名.尽管(a)用户可能没有WebGL,并且(b)扩展名可能不可用,具体取决于浏览器.

 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()); 

根据@jaromanda X的评论,此扩展名引起争议.有人认为了解GPU是隐私问题.例如,MacPro拥有(或拥有)仅MacPro的GPU. MacPro就像一台价值6000美元的机器,因此通过了解此人的GPU,您可以了解到他们有$$$$.如如果GPU = MacPro的GPU,然后展示昂贵商品的广告"中的内容.同样,标识您的特定计算机是另外一条信息.

计数器参数很多

  • 通过检查webgl参数,最大纹理大小,支持的制服数量等,您可以在某种程度上已经发现用户拥有高端GPU,这些都是使WebGL有用的必要条件.

  • p>
  • 关于使用信息来标识机器,您已经可以通过对WebGL参数进行指纹识别和渲染工件来获取大部分信息.

  • 对于技术支持而言,了解用户的GPU并要求非技术用户深入研究其系统以解决问题通常不是很重要.

  • 某些驱动程序存在错误,而解决这些错误是浏览器的工作,通常需要3到6个月的时间才能修复错误,并使该补丁渗透到浏览器的发行版中.同时,公司需要一种解决错误的方法,这种错误通常以"If GPU = X do Y"的形式出现,其中Y可以是从使用其他技术"到不为该用户使用WebGL"之类的任何东西. .这就是Google Maps所做的.如果已知特定的GPU/驱动程序不稳定,那么Google Maps将退回到具有更少功能的canvas2d版本.

  • 相对于最后2点,许多网站都尽其所能地跟踪错误和/或崩溃.通过跟踪GPU,他们可以查看崩溃是否与特定的GPU/驱动程序相关,并实施解决方法.

注意:S.O.真的不是辩论这个扩展是好是坏的地方.上面的信息主要是仅供参考.双方各有千秋.

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.

解决方案

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.

这篇关于如何使用javascript浏览器端获取视频卡驱动程序名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆