mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-03 06:12:14 +08:00
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:
@@ -198,11 +198,28 @@ export default function Galaxy({
|
||||
useEffect(() => {
|
||||
if (!ctnDom.current) return;
|
||||
const ctn = ctnDom.current;
|
||||
const renderer = new Renderer({
|
||||
alpha: transparent,
|
||||
premultipliedAlpha: false,
|
||||
});
|
||||
|
||||
let renderer;
|
||||
try {
|
||||
renderer = new Renderer({
|
||||
alpha: transparent,
|
||||
premultipliedAlpha: false,
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
"Galaxy: WebGL is not available. The galaxy background will not be rendered.",
|
||||
error,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const gl = renderer.gl;
|
||||
if (!gl) {
|
||||
console.warn(
|
||||
"Galaxy: WebGL context is null. The galaxy background will not be rendered.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (transparent) {
|
||||
gl.enable(gl.BLEND);
|
||||
|
||||
Reference in New Issue
Block a user