{"record":{"id":"833521bf757aac06","repo":"dotnet/maui","slug":"view-833521","errorCode":null,"errorMessage":"view","messagePattern":"view","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/iOS/RendererPool.cs","lineNumber":36,"sourceCode":"\n\t\treadonly IVisualElementRenderer _parent;\n\n\t\tpublic RendererPool(IVisualElementRenderer renderer, VisualElement oldElement)\n\t\t{\n\t\t\tif (renderer == null)\n\t\t\t\tthrow new ArgumentNullException(\"renderer\");\n\n\t\t\tif (oldElement == null)\n\t\t\t\tthrow new ArgumentNullException(\"oldElement\");\n\n\t\t\t_oldElement = oldElement;\n\t\t\t_parent = renderer;\n\t\t}\n\n\t\tpublic IVisualElementRenderer GetFreeRenderer(VisualElement view)\n\t\t{\n\t\t\tif (view == null)\n\t\t\t\tthrow new ArgumentNullException(\"view\");\n\n\t\t\tvar rendererType = Controls.Internals.Registrar.Registered.GetHandlerTypeForObject(view) ?? typeof(ViewRenderer);\n\n\t\t\tStack<IVisualElementRenderer> renderers;\n\t\t\tif (!_freeRenderers.TryGetValue(rendererType, out renderers) || renderers.Count == 0)\n\t\t\t\treturn null;\n\n\t\t\tvar renderer = renderers.Pop();\n\t\t\trenderer.SetElement(view);\n\t\t\treturn renderer;\n\t\t}\n\n\t\tpublic void UpdateNewElement(VisualElement newElement)\n\t\t{\n\t\t\tif (newElement == null)\n\t\t\t\tthrow new ArgumentNullException(\"newElement\");\n\n\t\t\tvar sameChildrenTypes = true;","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/iOS/RendererPool.cs#L18-L54","documentation":"GetFreeRenderer(VisualElement view) returns a recycled renderer of the correct type for a given view, falling back to ViewRenderer when no handler is registered (line 38). A null view cannot be looked up in the registrar and cannot be passed to renderer.SetElement (line 45), so the method rejects null up front.","triggerScenarios":"Calling pool.GetFreeRenderer(null), or passing a view reference that was set to null by an element-detach/teardown race before the pool is queried for a free renderer.","commonSituations":"Custom layout renderers that iterate children while the logical-children collection is being mutated; collection-changed handlers firing during disposal.","solutions":["Null-check the view before calling GetFreeRenderer and skip iteration entries that are null.","Ensure element lifecycle (cleanup of LogicalChildren) completes before invoking renderer pooling.","Prefer Registrar.Registered.GetHandlerTypeForObject on a known non-null element."],"exampleFix":"// before\nvar r = pool.GetFreeRenderer(child);\n\n// after\nif (child == null) continue;\nvar r = pool.GetFreeRenderer(child);","handlingStrategy":"validation","validationCode":"if (view == null) return null; // or continue in a loop\nvar renderer = pool.GetFreeRenderer(view);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter nulls out of child collections before pooling.","Avoid mutating LogicalChildren while iterating."],"tags":["argumentnullexception","ios","renderer-pool","lifecycle"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}