From e96b41fc04494366399fe9bf6b73271436d9e9c8 Mon Sep 17 00:00:00 2001
From: Luke Curley
Date: Mon, 29 Jun 2026 13:09:59 -0700
Subject: [PATCH 1/3] Degrade gracefully when WebGL2 is unavailable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The whole app rendered a blank page on browsers/configs that disable
WebGL (e.g. Librewolf's per-domain allow list). new Canvas() ran during
the synchronous SolidJS render and GLContext threw "WebGL2 not supported"
when getContext("webgl2") returned null, aborting the entire render —
even pages that don't need WebGL.
Canvas now catches the failure, exposes a `supported` flag, and guards
all GL operations so the decorative background simply doesn't render.
The room (which needs WebGL for video) is gated behind canvas.supported
and shows a clear "WebGL is required" notice instead of a blank page.
Co-Authored-By: Claude Opus 4.8
---
app/src/room/canvas.ts | 43 ++++++++++++++++++++++++++++++------------
app/src/sup.tsx | 17 ++++++++++++++++-
2 files changed, 47 insertions(+), 13 deletions(-)
diff --git a/app/src/room/canvas.ts b/app/src/room/canvas.ts
index e32f3a91..b3a4bfbb 100644
--- a/app/src/room/canvas.ts
+++ b/app/src/room/canvas.ts
@@ -7,9 +7,14 @@ import { GLContext } from "./gl/context";
export class Canvas {
#canvas: HTMLCanvasElement;
- #glContext: GLContext;
- #camera: Camera;
- #backgroundRenderer: BackgroundRenderer;
+ #glContext?: GLContext;
+ #camera?: Camera;
+ #backgroundRenderer?: BackgroundRenderer;
+
+ // True when a WebGL2 context was successfully created.
+ // Some browsers (or privacy configurations) disable WebGL entirely, in which
+ // case we degrade gracefully instead of crashing the whole app.
+ readonly supported: boolean;
// Use a callback to render after the background.
onRender?: (now: DOMHighResTimeStamp) => void;
@@ -24,14 +29,17 @@ export class Canvas {
}
get gl(): WebGL2RenderingContext {
+ if (!this.#glContext) throw new Error("WebGL2 not supported");
return this.#glContext.gl;
}
get glContext(): GLContext {
+ if (!this.#glContext) throw new Error("WebGL2 not supported");
return this.#glContext;
}
- get camera() {
+ get camera(): Camera {
+ if (!this.#camera) throw new Error("WebGL2 not supported");
return this.#camera;
}
@@ -41,10 +49,17 @@ export class Canvas {
this.visible = new Signal(false);
this.viewport = new Signal(Vector.create(0, 0));
- // Initialize WebGL2 context
- this.#glContext = new GLContext(this.#canvas, this.viewport);
- this.#camera = new Camera();
- this.#backgroundRenderer = new BackgroundRenderer(this.#glContext);
+ // Initialize WebGL2 context. This can fail when WebGL is disabled by the
+ // browser or a privacy extension; in that case we keep the app running
+ // without the GL-rendered background instead of throwing.
+ try {
+ this.#glContext = new GLContext(this.#canvas, this.viewport);
+ this.#camera = new Camera();
+ this.#backgroundRenderer = new BackgroundRenderer(this.#glContext);
+ } catch (err) {
+ console.warn("WebGL2 unavailable, disabling canvas rendering", err);
+ }
+ this.supported = this.#glContext !== undefined;
const resize = (entries: ResizeObserverEntry[]) => {
for (const entry of entries) {
@@ -68,14 +83,14 @@ export class Canvas {
this.#canvas.height = newHeight;
// Update WebGL viewport
- this.#glContext.resize(newWidth, newHeight);
+ this.#glContext?.resize(newWidth, newHeight);
// The internal logic ignores devicePixelRatio because we automatically scale when rendering.
const viewport = Vector.create(newWidth / dpr, newHeight / dpr);
this.viewport.set(viewport);
// Update camera projection
- this.#camera.updateOrtho(viewport);
+ this.#camera?.updateOrtho(viewport);
// Render immediately to avoid black flicker during resize
if (this.visible.peek()) {
@@ -108,8 +123,10 @@ export class Canvas {
resizeObserver.disconnect();
});
- // Only render the canvas when it's visible.
+ // Only render the canvas when it's visible (and WebGL is available).
this.#signals.effect((effect) => {
+ if (!this.#glContext) return;
+
const visible = effect.get(this.visible);
if (!visible) return;
@@ -130,6 +147,8 @@ export class Canvas {
}
#render(now: DOMHighResTimeStamp) {
+ if (!this.#glContext || !this.#backgroundRenderer) return;
+
// Clear the screen
this.#glContext.clear();
@@ -169,6 +188,6 @@ export class Canvas {
close() {
this.#signals.close();
- this.#backgroundRenderer.cleanup();
+ this.#backgroundRenderer?.cleanup();
}
}
diff --git a/app/src/sup.tsx b/app/src/sup.tsx
index 25009301..b3dc1c1a 100644
--- a/app/src/sup.tsx
+++ b/app/src/sup.tsx
@@ -62,11 +62,26 @@ export function Sup(props: { canvas: Canvas; room: string }): JSX.Element {
return (
}>
-
+ }>
+
+
);
}
+function WebGLUnsupported(): JSX.Element {
+ return (
+
+ WebGL is required
+
+ This room needs WebGL to render video, but your browser has it disabled. Some browsers and privacy
+ extensions block WebGL by default to prevent fingerprinting.
+
+ Please enable WebGL (for this site) and reload the page.
+
+ );
+}
+
function App(props: {
connection: Moq.Connection.Reload;
canvas: Canvas;
From a946cf72c7eed1b50399a58aac9eb93ab6c84591 Mon Sep 17 00:00:00 2001
From: Luke Curley
Date: Sat, 7 Nov 2026 09:12:42 -0800
Subject: [PATCH 2/3] fix: guard every WebGL renderer at setup
Co-Authored-By: Codex
---
app/src/about.tsx | 118 +++++++++++++++++++--------------
app/src/components/profile.tsx | 54 ++++++++-------
app/src/room/canvas.ts | 31 ++++-----
app/src/room/gl/context.ts | 10 +--
app/src/sup.tsx | 15 ++---
5 files changed, 120 insertions(+), 108 deletions(-)
diff --git a/app/src/about.tsx b/app/src/about.tsx
index 3212eb78..db1632de 100644
--- a/app/src/about.tsx
+++ b/app/src/about.tsx
@@ -8,17 +8,6 @@ import { Canvas } from "./room/canvas";
import { FakeRoom } from "./room/fake";
export function About(): JSX.Element {
- const canvas = ;
-
- const room = new FakeRoom(new Canvas(canvas as HTMLCanvasElement));
- onCleanup(() => room.close());
-
- const audioEnabled = solid(room.sound.enabled);
- const enableAudio = () => {
- room.sound.enabled.set(true);
- room.sound.tts.enabled.set(true);
- };
-
const services = ["Meet", "Zoom", "Teams", "Discord", "Skype", "WebEx", "FaceTime", "WhatsApp"];
const [currentService, setCurrentService] = createSignal(0);
@@ -30,6 +19,68 @@ export function About(): JSX.Element {
onCleanup(() => clearInterval(interval));
});
+ return (
+
+
+
+
+ I built hang.live because the internet forgot how to hang out. We forgot how to
+ be weird.
+
+
+ So here's a fun (and free) place to hang out with friends. Spend your free time with{" "}
+ real people, not doomscrolling feeds of AI slop. Unless you're into that.
+
+
+
+
+
+
+
+
+ Start a hang
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Powered by new and open source web tech:{" "}
+ MoQ. There's more to live than another {services[currentService()]}{" "}
+ clone. Crazy, I know.
+
+
+
+ );
+}
+
+function Demo(): JSX.Element {
+ const canvas = document.createElement("canvas");
+ canvas.className = "border-3 border-link-hue rounded-lg w-full h-full";
+ canvas.id = "demo";
+ const renderer = new Canvas(canvas);
+ onCleanup(() => renderer.close());
+ if (!renderer.supported) return Interactive demo needs WebGL2.
;
+
+ const room = new FakeRoom(renderer);
+ onCleanup(() => {
+ room.close();
+ room.sound.close();
+ });
+
+ const audioEnabled = solid(room.sound.enabled);
+ const enableAudio = () => {
+ room.sound.enabled.set(true);
+ room.sound.tts.enabled.set(true);
+ };
+
const random = () => (Math.random() > 0.5 ? -0.5 : 0.5) * (Math.random() * Math.random());
const randomLocation = () => ({ x: random(), y: random() });
const randomLeft = () => ({ x: -0.5 * Math.random() * Math.random(), y: random() });
@@ -231,45 +282,10 @@ export function About(): JSX.Element {
});
return (
-
-
-
-
- I built hang.live because the internet forgot how to hang out. We forgot how to
- be weird.
-
-
- So here's a fun (and free) place to hang out with friends. Spend your free time with{" "}
- real people, not doomscrolling feeds of AI slop. Unless you're into that.
-
-
-
-
-
-
-
-
- Start a hang
-
-
-
-
-
-
-
-
-
-
-
- Powered by new and open source web tech:{" "}
- MoQ. There's more to live than another {services[currentService()]}{" "}
- clone. Crazy, I know.
-
-
-
+ <>
+
+
+ {canvas}
+ >
);
}
diff --git a/app/src/components/profile.tsx b/app/src/components/profile.tsx
index 29ac8005..7fceeafe 100644
--- a/app/src/components/profile.tsx
+++ b/app/src/components/profile.tsx
@@ -59,25 +59,27 @@ export default function Profile(props: { local: Local }): JSX.Element {
{/* Avatar/Video Preview */}
-
+ Camera preview needs WebGL2.
}>
+
- {/* Media Controls */}
-
+ {/* Media Controls */}
+
+
@@ -117,25 +119,27 @@ export default function Profile(props: { local: Local }): JSX.Element {
*/
class LocalPreview {
canvas: Canvas;
- sound: Sound;
- space: Space;
+ sound?: Sound;
+ space?: Space;
signals = new Effect();
constructor(element: HTMLCanvasElement, camera: HangLocalSource) {
// Create a minimal canvas without the background effects
this.canvas = new Canvas(element);
+ if (!this.canvas.supported) return;
// Create a minimal sound context (muted for preview)
this.sound = new Sound();
- this.space = new Space(this.canvas, this.sound, {
+ const space = new Space(this.canvas, this.sound, {
// Not elegant, but disable some of the functionality for this profile preview.
profile: true,
});
+ this.space = space;
- const broadcast = this.space.add("local", camera);
- this.signals.cleanup(() => this.space.remove("local"));
+ const broadcast = space.add("local", camera);
+ this.signals.cleanup(() => space.remove("local"));
this.signals.run((effect: Effect) => {
const position = effect.get(broadcast.position);
@@ -155,8 +159,8 @@ class LocalPreview {
close() {
this.signals.close();
- this.space.close();
+ this.space?.close();
this.canvas.close();
- this.sound.close();
+ this.sound?.close();
}
}
diff --git a/app/src/room/canvas.ts b/app/src/room/canvas.ts
index 50044c84..64709825 100644
--- a/app/src/room/canvas.ts
+++ b/app/src/room/canvas.ts
@@ -11,9 +11,7 @@ export class Canvas {
#camera?: Camera;
#backgroundRenderer?: BackgroundRenderer;
- // True when a WebGL2 context was successfully created.
- // Some browsers (or privacy configurations) disable WebGL entirely, in which
- // case we degrade gracefully instead of crashing the whole app.
+ /** Whether this canvas can render with WebGL2. */
readonly supported: boolean;
// Use a callback to render after the background.
@@ -49,17 +47,14 @@ export class Canvas {
this.visible = new Signal(false);
this.viewport = new Signal(Vector.create(0, 0));
- // Initialize WebGL2 context. This can fail when WebGL is disabled by the
- // browser or a privacy extension; in that case we keep the app running
- // without the GL-rendered background instead of throwing.
- try {
- this.#glContext = new GLContext(this.#canvas, this.viewport);
- this.#camera = new Camera();
- this.#backgroundRenderer = new BackgroundRenderer(this.#glContext);
- } catch (err) {
- console.warn("WebGL2 unavailable, disabling canvas rendering", err);
- }
- this.supported = this.#glContext !== undefined;
+ const glContext = GLContext.create(this.#canvas, this.viewport);
+ this.#glContext = glContext;
+ this.supported = glContext !== undefined;
+ if (!glContext) return;
+
+ const camera = new Camera();
+ this.#camera = camera;
+ this.#backgroundRenderer = new BackgroundRenderer(glContext);
const resize = (entries: ResizeObserverEntry[]) => {
for (const entry of entries) {
@@ -83,14 +78,14 @@ export class Canvas {
this.#canvas.height = newHeight;
// Update WebGL viewport
- this.#glContext?.resize(newWidth, newHeight);
+ glContext.resize(newWidth, newHeight);
// The internal logic ignores devicePixelRatio because we automatically scale when rendering.
const viewport = Vector.create(newWidth / dpr, newHeight / dpr);
this.viewport.set(viewport);
// Update camera projection
- this.#camera?.updateOrtho(viewport);
+ camera.updateOrtho(viewport);
// Render immediately to avoid black flicker during resize
if (this.visible.peek()) {
@@ -123,10 +118,8 @@ export class Canvas {
resizeObserver.disconnect();
});
- // Only render the canvas when it's visible (and WebGL is available).
+ // Only render the canvas when it's visible.
this.#signals.run((effect) => {
- if (!this.#glContext) return;
-
const visible = effect.get(this.visible);
if (!visible) return;
diff --git a/app/src/room/gl/context.ts b/app/src/room/gl/context.ts
index c95c798f..04fd5743 100644
--- a/app/src/room/gl/context.ts
+++ b/app/src/room/gl/context.ts
@@ -6,7 +6,8 @@ export class GLContext {
canvas: HTMLCanvasElement;
viewport: Signal
;
- constructor(canvas: HTMLCanvasElement, viewport: Signal) {
+ /** Create a context when the browser supports WebGL2. */
+ static create(canvas: HTMLCanvasElement, viewport: Signal): GLContext | undefined {
const gl = canvas.getContext("webgl2", {
alpha: false,
antialias: true,
@@ -14,10 +15,11 @@ export class GLContext {
premultipliedAlpha: false,
});
- if (!gl) {
- throw new Error("WebGL2 not supported");
- }
+ if (!gl) return;
+ return new GLContext(canvas, viewport, gl);
+ }
+ private constructor(canvas: HTMLCanvasElement, viewport: Signal, gl: WebGL2RenderingContext) {
this.gl = gl;
this.canvas = canvas;
this.viewport = viewport;
diff --git a/app/src/sup.tsx b/app/src/sup.tsx
index cb364a53..8c2962b3 100644
--- a/app/src/sup.tsx
+++ b/app/src/sup.tsx
@@ -21,6 +21,8 @@ import { Sound } from "./room/sound";
import Settings from "./settings";
export function Sup(props: { canvas: Canvas; room: string }): JSX.Element {
+ if (!props.canvas.supported) return ;
+
const connection = new Moq.Connection.Reload({ enabled: true });
onCleanup(() => connection.close());
@@ -61,9 +63,7 @@ export function Sup(props: { canvas: Canvas; room: string }): JSX.Element {
return (
}>
- }>
-
-
+
);
}
@@ -71,12 +71,9 @@ export function Sup(props: { canvas: Canvas; room: string }): JSX.Element {
function WebGLUnsupported(): JSX.Element {
return (
- WebGL is required
-
- This room needs WebGL to render video, but your browser has it disabled. Some browsers and privacy
- extensions block WebGL by default to prevent fingerprinting.
-
- Please enable WebGL (for this site) and reload the page.
+ WebGL2 is required
+ This room needs WebGL2 to render video, but it is unavailable in your browser.
+ Use a browser with WebGL2 enabled and reload the page.
);
}
From e6cae2eb9afa5a9051a62b29b7e8ce9737f9163e Mon Sep 17 00:00:00 2001
From: Luke Curley
Date: Sat, 7 Nov 2026 09:15:23 -0800
Subject: [PATCH 3/3] fix: retain media controls without WebGL2
Co-Authored-By: Codex
---
app/src/components/profile.tsx | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/app/src/components/profile.tsx b/app/src/components/profile.tsx
index 7fceeafe..13fa94e3 100644
--- a/app/src/components/profile.tsx
+++ b/app/src/components/profile.tsx
@@ -63,24 +63,24 @@ export default function Profile(props: { local: Local }): JSX.Element {
-
- {/* Media Controls */}
-
+ {/* Media Controls */}
+
+