{"record":{"id":"a7510d504d73e9cf","repo":"Unity-Technologies/UnityCsReference","slug":"scriptablebakedreflectionsystemwrapper","errorCode":null,"errorMessage":"ScriptableBakedReflectionSystemWrapper","messagePattern":"ScriptableBakedReflectionSystemWrapper","errorType":"exception","errorClass":"ObjectDisposedException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Camera/ScriptableBakedReflectionSystemWrapper.bindings.cs","lineNumber":56,"sourceCode":"            get { return implementation != null ? implementation.stateHashes : null; }\n        }\n\n        int Internal_ScriptableBakedReflectionSystemWrapper_stageCount\n        {\n            [RequiredByNativeCode]\n            get { return implementation != null ? implementation.stageCount : 0; }\n        }\n\n        void IDisposable.Dispose()\n        {\n            Dispose(true);\n            GC.SuppressFinalize(this);\n        }\n\n        void IScriptableBakedReflectionSystemStageNotifier.EnterStage(int stage, string progressMessage, float progress)\n        {\n            if (Disposed)\n                throw new ObjectDisposedException(\"ScriptableBakedReflectionSystemWrapper\");\n\n            ScriptingEnterStage(m_Ptr, stage, progressMessage, progress);\n        }\n\n        void IScriptableBakedReflectionSystemStageNotifier.ExitStage(int stage)\n        {\n            if (Disposed)\n                throw new ObjectDisposedException(\"ScriptableBakedReflectionSystemWrapper\");\n\n            ScriptingExitStage(m_Ptr, stage);\n        }\n\n        void IScriptableBakedReflectionSystemStageNotifier.SetIsDone(bool isDone)\n        {\n            if (Disposed)\n                throw new ObjectDisposedException(\"ScriptableBakedReflectionSystemWrapper\");\n\n            ScriptingSetIsDone(m_Ptr, isDone);","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Camera/ScriptableBakedReflectionSystemWrapper.bindings.cs#L38-L74","documentation":"Thrown as ObjectDisposedException with the wrapper type name by the IScriptableBakedReflectionSystemStageNotifier.EnterStage implementation when the underlying native wrapper has already been disposed. The wrapper holds a native IntPtr (m_Ptr) that is zeroed on Dispose, so calling EnterStage after disposal dereferences dead state and is explicitly rejected. Disposal typically happens when the editor releases the baked reflection system between bakes or on domain reload.","triggerScenarios":"Calling stageNotifier.EnterStage(stage, progressMessage, progress) on a ScriptableBakedReflectionSystemWrapper instance whose Dispose(bool) has run (m_Ptr == IntPtr.Zero). This occurs when a long-running bake coroutine keeps a reference to the notifier past the system's lifecycle, or after an editor assembly reload invalidates the native handle.","commonSituations":"Custom ScriptableBakedReflectionSystem implementations that cache the stage notifier and call EnterStage across editor play-mode toggles, domain reloads, or after the user cancels and the system is torn down. Stale references captured in closures or background tasks.","solutions":["Check the wrapper's Disposed property before each notifier call and skip/no-op if true.","Re-acquire the active ScriptableBakedReflectionSystem instance at the start of each bake stage instead of holding a long-lived reference.","Tie notifier usage to a using scope or the bake request lifetime so Dispose ordering prevents post-dispose calls."],"exampleFix":"// before\nstageNotifier.EnterStage(stage, msg, progress);\n\n// after\nif (!wrapper.Disposed)\n    stageNotifier.EnterStage(stage, msg, progress);","handlingStrategy":"validation","validationCode":"if (wrapper == null || wrapper.Disposed) return;\n((IScriptableBakedReflectionSystemStageNotifier)wrapper).EnterStage(stage, msg, progress);","typeGuard":null,"tryCatchPattern":"try { notifier.EnterStage(stage, msg, progress); }\ncatch (ObjectDisposedException) { /* system torn down; abort bake */ }","preventionTips":["Check Disposed before each notifier call.","Re-acquire the active system per bake rather than caching long-term.","Avoid capturing the notifier in long-lived async contexts."],"tags":["unity-editor","reflection-probes","object-disposed","native-handle","lifecycle"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}