WebGL noise is not deterministic: `readPixels` of the same scene returns a different result on every read (canvas 2D noise also alters flat fills)
Environment: ShardX Launcher 2.0.3 (engine 152.0.7977.65), macOS arm64 host. Temporary profiles created through the local API, no proxy, probe run on about:blank.
POST /profiles/temporary
{"fingerprint_id": "mac-m2-mbp13",
"noise": {"canvas": true, "webgl": true, "audio": true, "client_rects": true}}
1. WebGL: every read is different
Probe: a fresh 64×64 WebGL canvas, one fixed fragment shader, one draw call, readPixels, hash of the bytes.
const g = document.createElement('canvas'); g.width = g.height = 64;
const gl = g.getContext('webgl');
const sh = (t, s) => { const x = gl.createShader(t); gl.shaderSource(x, s); gl.compileShader(x); return x; };
const pr = gl.createProgram();
gl.attachShader(pr, sh(gl.VERTEX_SHADER, 'attribute vec2 p;varying vec2 v;void main(){v=p;gl_Position=vec4(p,0,1);}'));
gl.attachShader(pr, sh(gl.FRAGMENT_SHADER, 'precision mediump float;varying vec2 v;void main(){gl_FragColor=vec4(sin(v.x*9.0)*0.5+0.5,cos(v.y*7.0)*0.5+0.5,v.x*v.y*0.5+0.5,1.0);}'));
gl.linkProgram(pr); gl.useProgram(pr);
gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1,-1,1,-1,-1,1,1,1]), gl.STATIC_DRAW);
const loc = gl.getAttribLocation(pr, 'p'); gl.enableVertexAttribArray(loc);
gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0); gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
const px = new Uint8Array(64*64*4); gl.readPixels(0, 0, 64, 64, gl.RGBA, gl.UNSIGNED_BYTE, px);
hash of px |
|
|---|---|
| noise off, two reads in each of two different profiles | 7a6a84b1 every time (host GPU, as expected) |
| noise on, same profile, run 1 | 561be701 |
| run 2 (same page) | abc3ff95 |
| run 3 (same page) | 586e1af2 |
| after page reload | d756d6ca |
A real GPU answers the same scene with the same bytes every time, so "draw twice, compare" is enough to tell the readback is being perturbed. The noise should be a pure function of the profile seed and the input, the way the canvas 2D noise already is (two toDataURL() reads of the same drawing match, in the same run and across runs).
Possibly related to #77, although the symptom there is the opposite one (hashes identical across profiles).
2. Canvas 2D: noise lands on a flat fill
const c = document.createElement('canvas'); c.width = c.height = 64;
const x = c.getContext('2d'); x.fillStyle = 'rgb(10,20,30)'; x.fillRect(0, 0, 64, 64);
const d = x.getImageData(0, 0, 64, 64).data; let off = 0;
for (let i = 0; i < d.length; i += 4) if (d[i] !== 10 || d[i+1] !== 20 || d[i+2] !== 30 || d[i+3] !== 255) off++;
off is 0 with noise off and 13–14 (of 4096) with canvas noise on, in two different profiles. Since #55 the read-back paths agree with each other; the residual tell is that the perturbation also lands on uniform regions, where a real browser has none. A solid fill has no anti-aliasing, so any pixel that is not exactly the fill colour gives the noise away. Leaving uniform regions untouched would close this one.
What works: audio and client-rects noise were stable across reads and different per profile in the same test.
in 2.1.0