stride3d/stride · error · ArgumentOutOfRangeException

value

Error message

value

What it means

The FrameDelayCount property setter on Stride's ImageReadback renderer validates that the assigned value is strictly greater than 0. A frame delay of 0 or negative is meaningless for readback pipelining (the renderer needs at least one frame of latency to schedule GPU->CPU copies), so it throws ArgumentOutOfRangeException. This is a fail-fast guard on a public property, thrown at assignment time rather than at render time.

Solutions

  1. Assign a value >= 1, e.g. frameDelayCount = 1 for minimal latency.
  2. If you want immediate readback, do not reduce FrameDelayCount to 0; instead disable/remove the ImageReadback processor from the graphics compositor.
  3. Clamp or validate user/config-supplied values before assignment: Math.Max(1, requestedDelay).

Example fix

// before
imageReadback.FrameDelayCount = 0;
// after
imageReadback.FrameDelayCount = Math.Max(1, requestedDelay);
Defensive patterns

Strategy: validation

Validate before calling

if (frameDelayCount <= 0) throw new ArgumentException("FrameDelayCount must be > 0");
imageReadback.FrameDelayCount = frameDelayCount;

Type guard

static bool IsValidFrameDelay(int v) => v > 0;

Try / catch

try { imageReadback.FrameDelayCount = value; }
catch (ArgumentOutOfRangeException) { imageReadback.FrameDelayCount = 1; }

Prevention

When it happens

Trigger: Setting imageReadback.FrameDelayCount = 0 (or any negative value) directly in code, or deserializing/binding a SceneCameraRenderer/editor configuration where the property is set to 0 from a script or asset property grid.

Common situations: Developers assuming 0 means 'no delay / read back immediately' and assigning 0; procedural setup code computing a delay value that resolves to 0; data-binding an int field initialized to 0 onto the property.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/1a73c34bbe4ed947. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Rendering/Rendering/Images/ImageReadback/ImageReadback.cs:57

            FrameDelayCount = 16;
            clock = new Stopwatch();
        }

        /// <summary>
        /// Gets or sets the number of frame to store before reading back. Default is <c>16</c>.
        /// </summary>
        /// <value>The frame delay count.</value>
        public int FrameDelayCount
        {
            get
            {
                return frameDelayCount;
            }
            set
            {
                if (value <= 0)
                {
                    throw new ArgumentOutOfRangeException("value", "Expecting a value > 0");
                }

                frameDelayCount = value;
            }
        }

        /// <summary>
        /// Gets a boolean indicating whether a result is available from <see cref="Result"/>.
        /// </summary>
        /// <value>A result available.</value>
        public bool IsResultAvailable { get; private set; }

        /// <summary>
        /// Gets a boolean indicating whether the readback is slow and may be stalling, indicating a <see cref="FrameDelayCount"/> to low or
        /// an input texture too large for an efficient non-blocking readback.
        /// </summary>
        /// <value>The readback is slow and stalling.</value>
        public bool IsSlow { get; private set; }

View on GitHub (pinned to 96fad776d2)