Cysharp/UniTask · error · ArgumentOutOfRangeException
Delay does not allow minus delayFrameCount. dueTimeFrameCoun
Error message
Delay does not allow minus delayFrameCount. dueTimeFrameCount:
What it means
Thrown by the single-parameter TimerFrame(dueTimeFrameCount) when dueTimeFrameCount is negative. A negative frame delay is meaningless — it implies firing the timer before the current frame. This is a standard precondition check on the public API.
Source
Thrown at src/UniTask/Assets/Plugins/UniTask/Runtime/Linq/UnityExtensions/Timer.cs:28
{
return new Timer(dueTime, null, updateTiming, ignoreTimeScale, cancelImmediately);
}
public static IUniTaskAsyncEnumerable<AsyncUnit> Timer(TimeSpan dueTime, TimeSpan period, PlayerLoopTiming updateTiming = PlayerLoopTiming.Update, bool ignoreTimeScale = false, bool cancelImmediately = false)
{
return new Timer(dueTime, period, updateTiming, ignoreTimeScale, cancelImmediately);
}
public static IUniTaskAsyncEnumerable<AsyncUnit> Interval(TimeSpan period, PlayerLoopTiming updateTiming = PlayerLoopTiming.Update, bool ignoreTimeScale = false, bool cancelImmediately = false)
{
return new Timer(period, period, updateTiming, ignoreTimeScale, cancelImmediately);
}
public static IUniTaskAsyncEnumerable<AsyncUnit> TimerFrame(int dueTimeFrameCount, PlayerLoopTiming updateTiming = PlayerLoopTiming.Update, bool cancelImmediately = false)
{
if (dueTimeFrameCount < 0)
{
throw new ArgumentOutOfRangeException("Delay does not allow minus delayFrameCount. dueTimeFrameCount:" + dueTimeFrameCount);
}
return new TimerFrame(dueTimeFrameCount, null, updateTiming, cancelImmediately);
}
public static IUniTaskAsyncEnumerable<AsyncUnit> TimerFrame(int dueTimeFrameCount, int periodFrameCount, PlayerLoopTiming updateTiming = PlayerLoopTiming.Update, bool cancelImmediately = false)
{
if (dueTimeFrameCount < 0)
{
throw new ArgumentOutOfRangeException("Delay does not allow minus delayFrameCount. dueTimeFrameCount:" + dueTimeFrameCount);
}
if (periodFrameCount < 0)
{
throw new ArgumentOutOfRangeException("Delay does not allow minus periodFrameCount. periodFrameCount:" + dueTimeFrameCount);
}
return new TimerFrame(dueTimeFrameCount, periodFrameCount, updateTiming, cancelImmediately);
}View on GitHub (pinned to ceac8d6946)
Solutions
- Clamp the value: var frames = Math.Max(0, dueTimeFrameCount); before calling TimerFrame.
- Fix the upstream calculation that produced the negative frame count.
Example fix
// before
var delay = targetFrame - Time.frameCount;
await UniTaskAsyncEnumerable.TimerFrame(delay).ForEachAwaitAsync(_ => { }); // throws if targetFrame already passed
// after
var delay = Math.Max(0, targetFrame - Time.frameCount);
await UniTaskAsyncEnumerable.TimerFrame(delay).ForEachAwaitAsync(_ => { }); Defensive patterns
Strategy: validation
Validate before calling
var safeFrames = Math.Max(0, dueTimeFrameCount);
await UniTaskAsyncEnumerable.TimerFrame(safeFrames).ForEachAwaitAsync(_ => { }); Prevention
- Always clamp frame counts with Math.Max(0, value) before passing to TimerFrame.
- Validate dynamic/computed frame delays at the source rather than at the API boundary.
When it happens
Trigger: Passing a computed or user-supplied negative integer to UniTaskAsyncEnumerable.TimerFrame(dueTimeFrameCount). E.g., a calculated delay based on a target frame that has already passed.
Common situations: Scheduling a frame-based timer relative to a past frame count. An arithmetic underflow in computing the delay. Dynamic scheduling from serialized data with bad values.
Related errors
- Delay does not allow minus periodFrameCount. periodFrameCoun
- Delay does not allow minus intervalFrameCount. intervalFrame
- minimumLength
- capacity
- Delay does not allow minus delayFrameCount. delayFrameCount:
AI-assisted analysis of Cysharp/UniTask@ceac8d6946 (2026-08-13).
Data as JSON: /api/errors/44857f23045061d7.
Report an issue: GitHub.