Skip to content

Commit 20289db

Browse files
fix: remove over-aggressive WebGL shader compilation pre-check (#236)
The shader-compilation test on a detached test canvas produced false negatives on Windows (ANGLE backend) and Linux (Mesa), causing the globe to refuse initialization even when WebGL was fully functional. macOS was unaffected due to its Metal-backed WebGL implementation. Replace with a lightweight context-existence check; globe.gl's own Three.js initialization already handles deeper WebGL failures via the existing try/catch. Fixes: #234 Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Brian Keating <brianbruff@users.noreply.github.com>
1 parent 1f54696 commit 20289db

1 file changed

Lines changed: 8 additions & 22 deletions

File tree

src/Log4YM.Web/src/plugins/GlobePlugin.tsx

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -317,35 +317,21 @@ export function GlobeCore({ hideOverlays, hideCompass }: { hideOverlays?: boolea
317317
useEffect(() => {
318318
if (!containerRef.current) return;
319319

320-
// Thorough WebGL check - test actual shader compilation.
320+
// Quick WebGL availability check — only tests for context existence.
321+
// The shader-compilation pre-check that was here produced false negatives on
322+
// Windows (ANGLE backend) and Linux (Mesa) even when WebGL was fully functional,
323+
// preventing the globe from loading on non-macOS platforms.
324+
// globe.gl's own Three.js initialization handles deeper WebGL failures via the
325+
// try/catch below.
321326
try {
322327
const testCanvas = document.createElement('canvas');
323-
const gl2 = testCanvas.getContext('webgl2');
324-
const gl: WebGLRenderingContext | null = gl2 ??
325-
(testCanvas.getContext('webgl') ?? testCanvas.getContext('experimental-webgl') as WebGLRenderingContext | null);
326-
328+
const gl = testCanvas.getContext('webgl2') ?? testCanvas.getContext('webgl');
327329
if (!gl) {
328330
setWebglError('WebGL is not supported in your browser.');
329331
return;
330332
}
331-
332-
const vertexShader = gl.createShader(gl.VERTEX_SHADER);
333-
if (!vertexShader) {
334-
setWebglError('WebGL shader creation failed.');
335-
return;
336-
}
337-
338-
gl.shaderSource(vertexShader, 'void main() { gl_Position = vec4(0.0); }');
339-
gl.compileShader(vertexShader);
340-
341-
if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
342-
setWebglError('WebGL shader compilation failed.');
343-
gl.deleteShader(vertexShader);
344-
return;
345-
}
346-
gl.deleteShader(vertexShader);
347333
} catch (e) {
348-
setWebglError('Failed to initialize WebGL.');
334+
setWebglError('WebGL is not available in this environment.');
349335
return;
350336
}
351337

0 commit comments

Comments
 (0)