Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
use JavaScript to detect GPU used from within your browser
var canvas = document.createElement('canvas');
var gl;
var debugInfo;
var vendor;
var renderer;
try {
gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
} catch (e) {
if (gl) {
debugInfo = gl.getExtension('WEBGL_debug_renderer_info');
vendor = gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL);
renderer = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
// Sample output:
// » console.log(renderer);
// ATI Technologies Inc. AMD Radeon R9 M370X OpenGL Engine
Copy link

mkateregga commented Jul 23, 2019

Hello anyone,

I have a data set of webgl debugger renderer similar to what is generated by this webgl-detect-gpu.js. My interest is to try and detect from this data which one is malicious or fraudulent. Does anyone has an idea how I could do that using a python script or bash script?

Copy link

FrancYescO commented Jun 4, 2021

If can be usefull to anyone:
changing line
gl = canvas.getContext('webgl', { powerPreference: "high-performance" }) || canvas.getContext('experimental-webgl', { powerPreference: "high-performance" });

allow you to create the canvas using the -if any- high performance GPU

Copy link

SoumavaBanerjee commented Jun 6, 2021

Hey, thanks for putting this up! It really helped me.

Copy link

justforuse commented Sep 1, 2021

Just wonder what the console output in M1, can anyone tell me?😊

Copy link

danigb commented Sep 20, 2021

The above script with M1:

  debugInfo: {
  renderer: "Apple M1",
  vendor: "Apple"

Or using

  "gpu": "apple m1 (Apple M1)",
  "isMobile": false,
  "tier": 1,
  "type": "FALLBACK"

Copy link

justforuse commented Nov 4, 2021

@danigb thanks bro

Copy link

adamthewan commented Jan 11, 2022

Using this method on M1, sometimes getting Google SwiftShader

Copy link

athlonzam commented May 3, 2022

do you have vue3 version. thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment