Cysharp/UniTask · error · ArgumentOutOfRangeException
capacity
Error message
capacity
What it means
Thrown by MinimumQueue's constructor when capacity is negative. MinimumQueue is an internal optimized circular-buffer queue used by ArrayPool and player-loop runners. The guard is standard argument validation; end users of UniTask should never instantiate this type directly.
Source
Thrown at src/UniTask/Assets/Plugins/UniTask/Runtime/Internal/MinimumQueue.cs:21
using System;
using System.Runtime.CompilerServices;
namespace Cysharp.Threading.Tasks.Internal
{
// optimized version of Standard Queue<T>.
internal class MinimumQueue<T>
{
const int MinimumGrow = 4;
const int GrowFactor = 200;
T[] array;
int head;
int tail;
int size;
public MinimumQueue(int capacity)
{
if (capacity < 0) throw new ArgumentOutOfRangeException("capacity");
array = new T[capacity];
head = tail = size = 0;
}
public int Count
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get { return size; }
}
public T Peek()
{
if (size == 0) ThrowForEmptyQueue();
return array[head];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(T item)View on GitHub (pinned to ceac8d6946)
Solutions
- Do not instantiate MinimumQueue directly — it is an internal implementation detail.
- If encountered, verify the UniTask source is unmodified and matches the expected version.
Defensive patterns
Strategy: validation
Validate before calling
// MinimumQueue is internal — do not instantiate it directly. // This guard protects UniTask's internal data structures. // No user-facing validation is needed.
Prevention
- Never instantiate internal types from the Cysharp.Threading.Tasks.Internal namespace.
- Keep the UniTask source unmodified to preserve internal invariants.
When it happens
Trigger: Internal: would only fire if ArrayPool or a player-loop runner passed a negative capacity during construction, which cannot happen with the default UniTask source. Direct instantiation by code that references the internal type.
Common situations: Not applicable for normal UniTask usage. Would indicate modified/corrupted UniTask source or incorrect reflection-based access to internal types.
Related errors
- minimumLength
- EmptyQueue
- Delay does not allow minus delayFrameCount. dueTimeFrameCoun
- Delay does not allow minus periodFrameCount. periodFrameCoun
- Delay does not allow minus intervalFrameCount. intervalFrame
AI-assisted analysis of Cysharp/UniTask@ceac8d6946 (2026-08-13).
Data as JSON: /api/errors/a1b2fca6b3ad10cf.
Report an issue: GitHub.