{"record":{"id":"f1b2e5f7cdee9936","repo":"AvaloniaUI/Avalonia","slug":"propertyset-depth-limit-reached","errorCode":null,"errorMessage":"PropertySet depth limit reached","messagePattern":"PropertySet depth limit reached","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Rendering/Composition/CompositionPropertySet.cs","lineNumber":126,"sourceCode":"\n        internal void Clear(string key)\n        {\n            _objects.Remove(key);\n            _variants.Remove(key);\n        }\n\n        internal PropertySetSnapshot Snapshot() =>\n            SnapshotCore(1);\n        \n        private PropertySetSnapshot SnapshotCore(int allowedNestingLevel)\n        {\n            var dic = new Dictionary<string, PropertySetSnapshot.Value>(_objects.Count + _variants.Count);\n            foreach (var o in _objects)\n            {\n                if (o.Value is CompositionPropertySet ps)\n                {\n                    if (allowedNestingLevel <= 0)\n                        throw new InvalidOperationException(\"PropertySet depth limit reached\");\n                    dic[o.Key] = new PropertySetSnapshot.Value(ps.SnapshotCore(allowedNestingLevel - 1));\n                }\n                else if (o.Value.Server == null)\n                    throw new InvalidOperationException($\"Object of type {o.Value.GetType()} is not allowed\");\n                else\n                    dic[o.Key] = new PropertySetSnapshot.Value((ServerObject)o.Value.Server);\n            }\n\n            foreach (var v in _variants)\n                dic[v.Key] = v.Value;\n            \n            return new PropertySetSnapshot(dic);\n        }\n    }\n\n    public enum CompositionGetValueStatus\n    {\n        Succeeded,","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Rendering/Composition/CompositionPropertySet.cs#L108-L144","documentation":"PropertySet snapshots cap nesting at one level: Snapshot() starts SnapshotCore(1), and each nested CompositionPropertySet decrements the budget. Reaching zero budget throws InvalidOperationException to keep the serialized expression parameter graph shallow and bounded.","triggerScenarios":"Inserting a CompositionPropertySet that itself contains another CompositionPropertySet into a property set, then taking a snapshot (which happens when an animation referencing such parameters is started).","commonSituations":"Building nested PropertySet structures for expression parameters; chaining reference parameters through multiple property sets, which the composition API explicitly does not support (see the 'we DON'T support expression paths' comment in the source).","solutions":["Flatten your parameter data: keep only a single level of nested CompositionPropertySet at most.","Store primitive values (scalars/vectors) directly instead of nesting PropertySets.","Reference CompositionObjects directly via SetReferenceParameter rather than wrapping them in nested PropertySets."],"exampleFix":"// before\nvar inner = compositor.CreatePropertySet();\nvar middle = compositor.CreatePropertySet();\nmiddle.Set(\"child\", inner);\nvar outer = compositor.CreatePropertySet();\nouter.Set(\"m\", middle); // depth 2 -> Snapshot throws\n\n// after\n// flatten: put the values directly in one property set\nouter.InsertScalar(\"v\", 42);","handlingStrategy":"validation","validationCode":"// Enforce a single nesting level before adding nested property sets.\nif (nestingDepth > 1) throw new InvalidOperationException(\"PropertySet nesting exceeds 1 level\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Flatten parameter data; do not nest CompositionPropertySets more than one level.","Store primitives directly instead of wrapping them in nested PropertySets.","Reference CompositionObjects via SetReferenceParameter, not via nested property-set values."],"tags":["composition","property-set","snapshot","limits"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}