fix(refboard): prevent WebGL OOM on large scenes

- Skip thumbnail generation when scene has >50 items (extract.canvas
  on full viewport with many textures causes GPU OOM and context loss)
- Add WebGL context lost/restored handlers — auto-reload scene on recovery
- Reduce texture memory budget from 512MB to 256MB for GPU headroom
This commit is contained in:
Hiren Kangad
2026-03-10 10:45:14 +05:30
parent a2eea8f22f
commit 451ec339a5
3 changed files with 31 additions and 3 deletions
+5 -2
View File
@@ -27,12 +27,15 @@ export function useSaveManager({ resolvedBoardId, isPublicView, canvasRef, setSa
try {
const state = JSON.stringify(scene.serialize());
// Generate thumbnail from PixiJS renderer
// Generate thumbnail — skip for large scenes to avoid GPU OOM
let thumbnail: string | undefined;
try {
const app = canvasRef.current?.getApp();
const viewport = canvasRef.current?.getViewport();
if (app?.renderer?.extract && viewport) {
const itemCount = scene.getAllItems().length;
// Skip thumbnail extraction when >50 items — extract.canvas on
// the full viewport with many textures causes WebGL OOM.
if (app?.renderer?.extract && viewport && itemCount <= 50) {
const fullCanvas = app.renderer.extract.canvas(viewport) as HTMLCanvasElement;
const thumbMax = 400;
const sw = fullCanvas.width;