Cysharp/UniTask · error · ArgumentOutOfRangeException
Delay does not allow minus intervalFrameCount. intervalFrame
Error message
Delay does not allow minus intervalFrameCount. intervalFrameCount:
What it means
Thrown by IntervalFrame(intervalFrameCount) when intervalFrameCount is negative. IntervalFrame creates a repeating frame timer where the interval equals both the due time and period. A negative interval is meaningless.
Source
Thrown at src/UniTask/Assets/Plugins/UniTask/Runtime/Linq/UnityExtensions/Timer.cs:52
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);
}
public static IUniTaskAsyncEnumerable<AsyncUnit> IntervalFrame(int intervalFrameCount, PlayerLoopTiming updateTiming = PlayerLoopTiming.Update, bool cancelImmediately = false)
{
if (intervalFrameCount < 0)
{
throw new ArgumentOutOfRangeException("Delay does not allow minus intervalFrameCount. intervalFrameCount:" + intervalFrameCount);
}
return new TimerFrame(intervalFrameCount, intervalFrameCount, updateTiming, cancelImmediately);
}
}
internal class Timer : IUniTaskAsyncEnumerable<AsyncUnit>
{
readonly PlayerLoopTiming updateTiming;
readonly TimeSpan dueTime;
readonly TimeSpan? period;
readonly bool ignoreTimeScale;
readonly bool cancelImmediately;
public Timer(TimeSpan dueTime, TimeSpan? period, PlayerLoopTiming updateTiming, bool ignoreTimeScale, bool cancelImmediately)
{
this.updateTiming = updateTiming;
this.dueTime = dueTime;
this.period = period;View on GitHub (pinned to ceac8d6946)
Solutions
- Clamp the value: var interval = Math.Max(0, intervalFrameCount); before calling IntervalFrame.
- Fix the upstream calculation or configuration that produced the negative value.
Example fix
// before
await UniTaskAsyncEnumerable.IntervalFrame(configuredInterval).ForEachAwaitAsync(_ => { });
// throws if configuredInterval < 0
// after
var interval = Math.Max(1, configuredInterval);
await UniTaskAsyncEnumerable.IntervalFrame(interval).ForEachAwaitAsync(_ => { }); Defensive patterns
Strategy: validation
Validate before calling
var safeInterval = Math.Max(0, intervalFrameCount);
await UniTaskAsyncEnumerable.IntervalFrame(safeInterval).ForEachAwaitAsync(_ => { }); Prevention
- Clamp intervalFrameCount with Math.Max(0, value) before calling IntervalFrame.
- Validate config-driven interval values against negative inputs at the parsing boundary.
When it happens
Trigger: Passing a negative integer to UniTaskAsyncEnumerable.IntervalFrame(intervalFrameCount). E.g., a computed interval from a configuration that allows negative values.
Common situations: Dynamic interval calculation that underflows. Config-driven scheduling with unvalidated input. Using IntervalFrame with a frame budget that went negative.
Related errors
- Delay does not allow minus delayFrameCount. dueTimeFrameCoun
- Delay does not allow minus periodFrameCount. periodFrameCoun
- minimumLength
- capacity
- Delay does not allow minus delayFrameCount. delayFrameCount:
AI-assisted analysis of Cysharp/UniTask@ceac8d6946 (2026-08-13).
Data as JSON: /api/errors/063db8e584ea551b.
Report an issue: GitHub.