fix(frontend): gracefully handle missing WebGL context (#1147)
Wrap the OGL Renderer instantiation in a try-catch so the app does not crash when WebGL is unavailable (e.g. hardware acceleration disabled). The Galaxy background simply does not render instead of taking down the entire page. Fixes #1144 Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
This commit is contained in:
parent
3212c7c5a2
commit
609ff5849f
|
|
@ -198,11 +198,28 @@ export default function Galaxy({
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!ctnDom.current) return;
|
if (!ctnDom.current) return;
|
||||||
const ctn = ctnDom.current;
|
const ctn = ctnDom.current;
|
||||||
const renderer = new Renderer({
|
|
||||||
|
let renderer;
|
||||||
|
try {
|
||||||
|
renderer = new Renderer({
|
||||||
alpha: transparent,
|
alpha: transparent,
|
||||||
premultipliedAlpha: false,
|
premultipliedAlpha: false,
|
||||||
});
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(
|
||||||
|
"Galaxy: WebGL is not available. The galaxy background will not be rendered.",
|
||||||
|
error,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const gl = renderer.gl;
|
const gl = renderer.gl;
|
||||||
|
if (!gl) {
|
||||||
|
console.warn(
|
||||||
|
"Galaxy: WebGL context is null. The galaxy background will not be rendered.",
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (transparent) {
|
if (transparent) {
|
||||||
gl.enable(gl.BLEND);
|
gl.enable(gl.BLEND);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue