{"record":{"id":"a0fc471bc7a0bb3b","repo":"stride3d/stride","slug":"could-not-recreate-all-objects","errorCode":null,"errorMessage":"Could not recreate all objects.","messagePattern":"Could not recreate all objects\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"critical","filePath":"sources/engine/Stride.Graphics/ResumeManager.cs","lineNumber":110,"sourceCode":"                            if (resource.OnRecreate())\n                            {\n                                wasSomethingRecreated = true;\n                                resource.LifetimeState = GraphicsResourceLifetimeState.Active;\n                            }\n                            else\n                            {\n                                // Couldn't be recreated?\n                                hasDestroyedObjects = true;\n                            }\n                        }\n                    }\n                }\n\n                if (hasDestroyedObjects)\n                {\n                    // Attach the list of objects that could not be recreated to the exception.\n                    var destroyedObjects = graphicsDevice.Resources.Where(x => x.LifetimeState == GraphicsResourceLifetimeState.Destroyed).ToList();\n                    throw new InvalidOperationException(\"Could not recreate all objects.\") { Data = { { \"DestroyedObjects\", destroyedObjects } } };\n                }\n            }\n        }\n\n        /// <summary>\n        ///   Called when the Resume Manager is being destroyed.\n        /// </summary>\n        /// <param name=\"immediately\">\n        ///   A value indicating whether the resources used by the Resume Manager should be destroyed immediately\n        ///   (<see langword=\"true\"/>), or if it can be deferred until it's safe to do so (<see langword=\"false\"/>).\n        /// </param>\n        public void OnDestroyed(bool immediately = false)\n        {\n            lock (graphicsDevice.Resources)\n            {\n                foreach (var resource in graphicsDevice.Resources)\n                {\n                    resource.OnDestroyed(immediately);","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/ResumeManager.cs#L92-L128","documentation":"ResumeManager.OnRecreate re-creates graphics resources after a device reset/context resume. If some resources were destroyed and could not be recreated, it throws InvalidOperationException with a 'DestroyedObjects' entry in Data listing the resources stuck in the Destroyed lifetime state.","triggerScenarios":"Calling OnRecreate (via OnRender) after a device lost/reset event when at least one registered graphics resource fails to recreate, leaving destroyed objects behind.","commonSituations":"GPU device removal/reset on mobile or after driver crash, resuming an app after system suspend, or window/backbuffer recreation where a resource's recreation logic fails (e.g. format no longer supported).","solutions":["Inspect the exception's Data[\"DestroyedObjects\"] list to identify which resources failed to recreate","Fix the recreation path of the failing resources (e.g. unsupported format/size after device reset)","Dispose and rebuild the GraphicsDevice or reload the affected assets if resources cannot be restored","Handle device-lost events gracefully so recreation retries with valid parameters"],"exampleFix":"// before\ncatch (InvalidOperationException) { /* ignored */ }\n// after\ncatch (InvalidOperationException ex) when (ex.Data.Contains(\"DestroyedObjects\"))\n{\n    var destroyed = (List<GraphicsResource>)ex.Data[\"DestroyedObjects\"];\n    foreach (var r in destroyed) r.Dispose();\n    RecreateDeviceAndResources();\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { resumeManager.OnRecreate(); } catch (InvalidOperationException ex) when (ex.Data.Contains(\"DestroyedObjects\")) { /* inspect ex.Data[\"DestroyedObjects\"] and rebuild device */ }","preventionTips":["Handle GraphicsDevice device-lost/reset events explicitly","Keep resource recreation logic resilient to changed formats/sizes","Dispose unusable resources instead of leaving them Destroyed"],"tags":["graphics","device-reset","resource-management"],"backgroundTag":"invalid-state-transition","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}