stride3d/stride · error · ArgumentNullException
item
Error message
item
What it means
Argument-null validation in GraphicsRendererCollectionBase.Add: the item (a T renderer) is null. The collection tracks active renderers and later iterates them every frame; a null entry would break enumeration and rendering, so Add rejects it with ArgumentNullException named 'item'.
Solutions
- Check the renderer for null before adding.
- Ensure the renderer was constructed successfully.
- Throw/log upstream instead of adding a null entry.
Example fix
// before renderers.Add(CreateRenderer()); // may be null // after var r = CreateRenderer(); if (r != null) renderers.Add(r);
Defensive patterns
Strategy: type-guard
Validate before calling
if (renderer == null) { log.Warn("Skipping null renderer"); return; }
renderers.Add(renderer); Type guard
bool IsValid<T>(T item) where T : class => item != null;
Try / catch
try { renderers.Add(item); }
catch (ArgumentNullException ex) when (ex.ParamName == "item")
{
log.Warn("Tried to add a null renderer to the collection");
} Prevention
- Null-check results of renderer factories before Add.
- Avoid optional-injection services returning null silently.
When it happens
Trigger: Calling Add(null) on a GraphicsRendererCollection (e.g. RenderStage effects/renderers list).
Common situations: A factory method returning null renderer (failed creation) that is then added unconditionally; optional renderer resolved from a service that is absent.
Related errors
- An error occurred while adding an item to the node, see the…
- An error occurred while adding an item to the node, see the…
- An error occurred while removing an item to the node, see…
- Custom strides is not supported with packed PixelFormats
- output
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/fd3b7747b6adffa0.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Rendering/Rendering/GraphicsRendererCollectionBase.cs:69
{
return currentRenderers.GetEnumerator();
}
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return currentRenderers.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)currentRenderers).GetEnumerator();
}
public void Add(T item)
{
if (item == null)
{
throw new ArgumentNullException("item");
}
currentRenderers.Add(item);
}
public void Clear()
{
currentRenderers.Clear();
}
public bool Contains(T item)
{
return currentRenderers.Contains(item);
}
public void CopyTo(T[] array, int arrayIndex)
{
currentRenderers.CopyTo(array, arrayIndex);
}View on GitHub (pinned to 96fad776d2)