{"record":{"id":"8bca5289fa9ffcb9","repo":"FyroxEngine/Fyrox","slug":"graph-pool-must-be-empty-on-load","errorCode":null,"errorMessage":"Graph pool must be empty on load!","messagePattern":"Graph pool must be empty on load!","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"fyrox-impl/src/scene/graph/mod.rs","lineNumber":1999,"sourceCode":"\n    #[inline]\n    fn index(&self, index: Handle<T>) -> &Self::Output {\n        self.try_get(index).unwrap()\n    }\n}\n\nimpl<T: ObjectOrVariant<Node>> IndexMut<Handle<T>> for Graph {\n    #[inline]\n    fn index_mut(&mut self, index: Handle<T>) -> &mut Self::Output {\n        self.try_get_mut(index).unwrap()\n    }\n}\n\nimpl Visit for Graph {\n    fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult {\n        // Pool must be empty, otherwise handles will be invalid and everything will blow up.\n        if visitor.is_reading() && self.pool.get_capacity() != 0 {\n            panic!(\"Graph pool must be empty on load!\")\n        }\n\n        let mut region = visitor.enter_region(name)?;\n\n        self.root.visit(\"Root\", &mut region)?;\n        self.pool.visit(\"Pool\", &mut region)?;\n        self.sound_context.visit(\"SoundContext\", &mut region)?;\n        self.physics.visit(\"PhysicsWorld\", &mut region)?;\n        self.physics2d.visit(\"PhysicsWorld2D\", &mut region)?;\n        self.lightmap.visit(\"Lightmap\", &mut region)?;\n\n        Log::verify(self.user_data.visit(\"UserData\", &mut region));\n\n        Ok(())\n    }\n}\n\nimpl SceneGraph for Graph {","sourceCodeStart":1981,"sourceCodeEnd":2017,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-impl/src/scene/graph/mod.rs#L1981-L2017","documentation":"Graph's Visit implementation requires the node pool to be empty when deserializing (reading) a graph, because loading into a non-empty pool would produce invalid handles and corrupt the scene. It panics if capacity != 0 during read.","triggerScenarios":"Calling visitor.load / Graph::visit on a Graph whose pool already contains nodes — e.g. loading a saved scene into an existing scene instead of a fresh one.","commonSituations":"Deserializing a save game into an already-populated scene; reusing a Scene/Graph object for multiple loads; calling load twice on the same graph.","solutions":["Load into a fresh Scene/Graph (empty pool) rather than an existing one","Clear the graph (remove all nodes / call clear) before deserializing into it","If merging is needed, load into a temporary Graph and transplant nodes explicitly"],"exampleFix":"// before\nscene.graph.visit(\"Graph\", &mut visitor)?; // graph still has nodes\n// after\nlet mut scene = Scene::new(); // fresh, empty pool\nscene.graph.visit(\"Graph\", &mut visitor)?;","handlingStrategy":"validation","validationCode":"assert_eq!(graph.pool.get_capacity(), 0, \"graph must be empty before loading\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always deserialize graphs into freshly created scenes","Call graph.clear() before loading into a reused graph","Never load a save file into a live scene's graph"],"tags":["serialization","graph","panic","fyrox"],"backgroundTag":"invalid-state-transition","analyzedSha":"76c91aad8eca488ce527b1af707be8b3b24ad72d","analyzedAt":"2026-09-10T16:04:01.633Z","contentChangedAt":"2026-09-10T16:04:01.633Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}