{"record":{"id":"c6b5e3ee279b8475","repo":"dotnet/maui","slug":"renderer-c6b5e3","errorCode":null,"errorMessage":"renderer","messagePattern":"renderer","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/iOS/RendererPool.cs","lineNumber":24,"sourceCode":"#else\n\nnamespace Microsoft.Maui.Controls.Compatibility.Platform.MacOS\n#endif\n{\n\t[System.Obsolete]\n\tpublic sealed class RendererPool\n\t{\n\t\treadonly Dictionary<Type, Stack<IVisualElementRenderer>> _freeRenderers =\n\t\t\tnew Dictionary<Type, Stack<IVisualElementRenderer>>();\n\n\t\treadonly VisualElement _oldElement;\n\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;","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/iOS/RendererPool.cs#L6-L42","documentation":"RendererPool constructor throws ArgumentNullException(\"renderer\") when the IVisualElementRenderer argument is null. RendererPool manages recycled renderers for a parent renderer and cannot operate without one; it also rejects null oldElement for the same reason.","triggerScenarios":"Constructing RendererPool with a null renderer; typically inside a custom layout renderer during OnElementChanged when the new renderer is not yet established.","commonSituations":"Custom renderers that build a RendererPool before Platform.GetRenderer returns a value; layout/renderers that recycle children and reference a null parent during teardown.","solutions":["Construct RendererPool only after the renderer is non-null and initialized.","Null-check both arguments before construction.","Move RendererPool initialization to OnElementChanged (not the constructor)."],"exampleFix":"// before\n_pool = new RendererPool(null, oldElement);\n// after\nif (renderer == null)\n    throw new InvalidOperationException(\"Renderer not ready for RendererPool.\");\n_pool = new RendererPool(renderer, oldElement);","handlingStrategy":"validation","validationCode":"if (renderer == null || oldElement == null)\n    throw new InvalidOperationException(\"RendererPool requires non-null renderer and oldElement.\");\nvar pool = new RendererPool(renderer, oldElement);","typeGuard":"static bool CanBuildPool(IVisualElementRenderer r, VisualElement oldE) => r != null && oldE != null;","tryCatchPattern":null,"preventionTips":["Construct RendererPool only after renderer is ready.","Null-check both arguments.","Move RendererPool setup to OnElementChanged."],"tags":["maui","xamarin-forms","ios","renderer","rendererpool","argument-validation"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}