Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/lib/exporter/backendPolicy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";

import {
getDefaultLightningRenderBackend,
getDefaultLightningRenderBackendOrder,
normalizeLightningRuntimePlatform,
planLightningExportRoutes,
shouldPreferNativeAutoBackend,
Expand All @@ -27,6 +28,13 @@ describe("backendPolicy", () => {
expect(getDefaultLightningRenderBackend()).toBe("webgl");
});

it("defaults Linux to WebGL first to avoid the WebGPU/Dawn resource-import crash", () => {
expect(getDefaultLightningRenderBackendOrder("linux")).toEqual(["webgl", "webgpu"]);
expect(getDefaultLightningRenderBackendOrder("win32")).toEqual(["webgpu", "webgl"]);
expect(getDefaultLightningRenderBackendOrder("darwin")).toEqual(["webgpu", "webgl"]);
expect(getDefaultLightningRenderBackendOrder("unknown")).toEqual(["webgpu", "webgl"]);
});

it("keeps Windows auto exports on the streaming route by default", () => {
expect(shouldPreferNativeStaticLayoutBeforeBreeze("win32", "auto")).toBe(false);
expect(shouldPreferNativeStaticLayoutBeforeBreeze("darwin", "auto")).toBe(false);
Expand Down
9 changes: 9 additions & 0 deletions src/lib/exporter/backendPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,12 @@ export function planLightningExportRoutes(options: {
export function getDefaultLightningRenderBackend(): ExportRenderBackend {
return "webgl";
}

// WebGPU-on-Linux (Dawn/Vulkan) can corrupt GPU resource imports for VideoFrame-backed
// textures mid-export, crashing PixiJS's WebGPU bind group system well after init
// succeeds. Default Linux to WebGL until that upstream instability is resolved.
export function getDefaultLightningRenderBackendOrder(
platform: LightningRuntimePlatform,
): ExportRenderBackend[] {
return platform === "linux" ? ["webgl", "webgpu"] : ["webgpu", "webgl"];
}
9 changes: 8 additions & 1 deletion src/lib/exporter/modernFrameRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ import {
renderAnnotations,
renderAnnotationToCanvas,
} from "./annotationRenderer";
import {
getDefaultLightningRenderBackendOrder,
normalizeLightningRuntimePlatform,
} from "./backendPolicy";
import { ForwardFrameSource } from "./forwardFrameSource";
import { resolveMediaElementSource } from "./localMediaSource";
import {
Expand Down Expand Up @@ -638,13 +642,16 @@ export class FrameRenderer {
};

const preferredRenderBackend = this.config.preferredRenderBackend;
const runtimePlatform = normalizeLightningRuntimePlatform(
typeof navigator !== "undefined" ? navigator.platform || navigator.userAgent || "" : "",
);
const backendOrder: ExportRenderBackend[] =
preferredRenderBackend === "webgl"
? ["webgl", "webgpu"]
: preferredRenderBackend === "webgpu"
? ["webgpu", "webgl"]
: typeof navigator !== "undefined" && "gpu" in navigator
? ["webgpu", "webgl"]
? getDefaultLightningRenderBackendOrder(runtimePlatform)
: ["webgl"];
const failures: PixiRendererAttempt[] = [];

Expand Down