{"record":{"id":"de6c302acf2f5c18","repo":"BabylonJS/Babylon.js","slug":"freezing-active-meshes-was-cancelled","errorCode":null,"errorMessage":"Freezing active meshes was cancelled","messagePattern":"Freezing active meshes was cancelled","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/scene.pure.ts","lineNumber":4645,"sourceCode":"            for (const task of objectRendererTasks) {\r\n                task.objectRenderer._freezeActiveMeshes(freezeMeshes);\r\n            }\r\n\r\n            // Wait for all object renderers to finish freezing\r\n            this._freezeActiveMeshesCancel = _RetryWithInterval(\r\n                () => {\r\n                    let ok = true;\r\n                    let notCancelled = true;\r\n                    for (const task of objectRendererTasks) {\r\n                        ok &&= task.objectRenderer._isFrozen;\r\n                        notCancelled &&= task.objectRenderer._freezeActiveMeshesCancel !== null;\r\n                    }\r\n                    if (ok) {\r\n                        return true;\r\n                    } else if (!notCancelled) {\r\n                        // At least one object renderer cancelled freezing meshes because of an error\r\n                        // Throws an error that will be caught by _RetryWithInterval.onError\r\n                        throw new Error(\"Freezing active meshes was cancelled\");\r\n                    }\r\n                    return false;\r\n                },\r\n                () => {\r\n                    // All meshes of all object renderers could be frozen correctly\r\n                    this._freezeActiveMeshesCancel = null;\r\n                    this._activeMeshesFrozen = true;\r\n                    this._activeMeshesFrozenButKeepClipping = keepFrustumCulling;\r\n                    this._skipEvaluateActiveMeshesCompletely = skipEvaluateActiveMeshes;\r\n\r\n                    onSuccess?.();\r\n                },\r\n                (err, isTimeout) => {\r\n                    // An error occurred => not all meshes could be frozen\r\n                    // Unfreezes all meshes so that we remain in a valid state\r\n                    this._freezeActiveMeshesCancel = null;\r\n                    this.unfreezeActiveMeshes();\r\n                    if (!isTimeout) {\r","sourceCodeStart":4627,"sourceCodeEnd":4663,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/scene.pure.ts#L4627-L4663","documentation":"Scene.freezeActiveMeshes() asks every object renderer to freeze its active meshes; this happens asynchronously via a retry helper (_RetryWithInterval). If any object renderer's freeze step reports failure (ok === false) or is cancelled (notCancelled === false, e.g. due to an error in a renderer), the scene throws this Error to abort the freeze operation instead of leaving the scene half-frozen.","triggerScenarios":"Calling scene.freezeActiveMeshes() (or freezeActiveMeshes(update) in a render loop) when at least one attached object renderer errors or cancels during its _freezeActiveMeshes step; the retry/onError path surfaces the cancellation as this thrown error.","commonSituations":"Performance-tuning a Babylon.js scene by freezing meshes to skip mesh evaluation; custom object renderers or plugins whose freeze callback fails; scenes with renderers attached that are not ready when freeze is attempted.","solutions":["Inspect the object renderers' _freezeActiveMeshes results/logs to find which renderer cancelled and fix the underlying error it hit","Retry freezeActiveMeshes after the scene and all renderers are fully ready (e.g. after assets finish loading / onReadyObservable fires)","Avoid mixing custom object renderers with mesh freezing, or ensure their freeze implementation returns true","If freezing is unstable, remove the freeze call and let the scene evaluate meshes each frame"],"exampleFix":"// before\nscene.registerBeforeRender(() => { scene.freezeActiveMeshes(); });\n// after\nscene.executeWhenReady(() => { try { scene.freezeActiveMeshes(); } catch (e) { console.warn('freeze cancelled', e); } });","handlingStrategy":"try-catch","validationCode":"// Ensure scene is ready and no problematic object renderers are attached\nif (scene.isReady() && scene.progressBar === undefined) {\n  scene.executeWhenReady(() => scene.freezeActiveMeshes());\n}","typeGuard":null,"tryCatchPattern":"try {\n  scene.freezeActiveMeshes();\n} catch (e) {\n  if (e instanceof Error && e.message === 'Freezing active meshes was cancelled') {\n    // fall back to per-frame mesh evaluation; investigate renderer errors\n    scene.unfreezeActiveMeshes?.();\n  } else { throw e; }\n}","preventionTips":["Call freezeActiveMeshes only inside scene.executeWhenReady after all assets load","Keep custom object renderers' freeze implementations error-free and returning true","Re-freeze (unfreeze then freeze) after dynamic scene changes instead of freezing mid-load","Log the renderer that cancels to identify the failing component quickly"],"tags":["babylonjs","scene","rendering","performance"],"backgroundTag":"mesh-freeze-cancelled","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}