Why a WebGL hero can tank PageSpeed
Why a WebGL hero can sink a lab performance score, how I skip it on software renderers, and what Chrome's SwiftShader removal changes for you.
· Updated · 4 min read

If your hero runs a heavy shader, test it on a machine with no GPU. Lab tools often have none, and a raymarcher built for a GPU can be very slow when the CPU draws it. On my homepage, skipping the hero scene on software renderers moved the mobile PageSpeed Insights score from 54 to 90.
I cannot show you the runner's renderer string, so treat the cause as an inference: the fix only triggers when the browser reports a software renderer, and the score changed, so the lab browser was using one.
What a software renderer is#
When a browser has no usable GPU, it can draw WebGL on the CPU. Chrome's version is SwiftShader. Mesa has llvmpipe. Windows has its Basic Render Driver. All of them are correct and slow.
The hero on my homepage is a liquid chrome scene: a raymarched shader that draws six metaball-like drops with reflections and a thin-film sheen. On a GPU it is cheap. Drawn on the CPU, it uses the same processor the rest of the page needs.
How I detect it#
The WEBGL_debug_renderer_info extension exposes the renderer name. MDN warns that it might only be available to privileged contexts depending on browser privacy settings, so the check has to fail open: if there is no string, the scene runs.
const dbg = gl.getExtension("WEBGL_debug_renderer_info");
const gpu = dbg ? String(gl.getParameter(dbg.UNMASKED_RENDERER_WEBGL)) : "";
if (/swiftshader|llvmpipe|software/i.test(gpu)) {
gl.getExtension("WEBGL_lose_context")?.loseContext();
return;
}
When the regex matches, the canvas stays invisible and the HTML hero stands alone. The headline and copy are real HTML, visible at first paint, so nothing the visitor needs lives only in the canvas.
The check is a guess from a name. It misses a software renderer that reports a different string, and it would skip a GPU whose name contains "software". I accept both.
Chrome is removing the fallback#
Chrome's Intent to Remove for the SwiftShader fallback says that WebGL context creation will fail instead of falling back to SwiftShader. Since Chrome 130 DevTools has warned when a context is backed by it. The thread planned the removal for desktop Chrome 137 and shows API owners treating it as a compatibility risk. Samsung's browser policy documentation says that from Chrome 139 on, WebGL context creation fails where it would have used SwiftShader, and I found no Chrome release note to confirm the exact version. Plan for both outcomes.
The reasons given are security, because SwiftShader runs JIT-compiled code in the GPU process, and user experience, because a silent drop to CPU rendering can be very slow. The thread puts SwiftShader at about 2.7% of WebGL contexts, mostly on older Windows machines, and says it is not used on mobile.
Its advice is to handle context creation failure and fall back to something like Canvas 2D. For testing on machines with no GPU, you can opt in with --enable-unsafe-swiftshader.
So there are two cases to handle:
getContext("webgl")returnsnull. Show the poster or the HTML.- It returns a context backed by software. Decide whether the scene is worth running.
The failIfMajorPerformanceCaveat context attribute covers the second case in a standard way: the browser refuses to give you a context that would be dramatically slow. I used the renderer name when I wrote the hero. The attribute is the simpler tool, and I would try it first in a new project.
The other habits that keep the hero cheap#
These changes came in an earlier pass and have the same goal, keeping the scene off the critical path:
- The scene loads through
next/dynamicwith server rendering off, behind the HTML poster. - It starts after the page has loaded and gone idle.
- The shader compiles with
KHR_parallel_shader_compilewhere the driver has it, so the main thread is not blocked ongetProgramParameter(LINK_STATUS). - It runs at 1x CSS resolution and pauses when scrolled off screen.
- Under reduced motion it draws one still frame.
I have not measured each of these separately, so I cannot tell you how much of the gain each one carries.
Check your own machine#
The WebGL Report tool runs a draw test in your browser, flags a software renderer, and lists limits and extensions. Open it on the phone and the laptop you test on. If it says software, your heavy scenes will crawl there, and so will any lab runner without a GPU.
What this does not prove#
I have not seen the PageSpeed runner's renderer string, so the link between the software check and the score is an inference. Lab scores vary between runs. Visitors with a GPU never take the skip path, so the change affects the lab score far more than it affects them.