stride3d/stride · error · NotSupportedException

Chunks with multiple passes are not supported.

Error message

Chunks with multiple passes are not supported.

What it means

The LZ4 chunk flags can encode multiple compression passes (bits above the Compressed flag). LZ4Stream's decoder only supports single-pass chunks, so a chunk with a nonzero pass count triggers NotSupportedException — the data was written by an unsupported encoder configuration.

Solutions

  1. Re-encode the data with a writer that produces single-pass LZ4 chunks (same library version as the reader)
  2. Upgrade the reader/library to a version supporting multi-pass chunks
  3. Inspect the flags byte of the failing chunk to confirm the producer's format

Example fix

// before
// file written by newer encoder with multi-pass chunks
var s = new LZ4Stream(File.OpenRead(f)); // NotSupportedException
// after
var f2 = RecompressSinglePass(f); // rewrite with matching library version
var s = new LZ4Stream(File.OpenRead(f2));
Defensive patterns

Strategy: fallback

Validate before calling

// read first chunk flags and check pass bits before full read
var flags = ReadFirstChunkFlags(path);
if (((int)flags >> 2) != 0) throw new NotSupportedException("Multi-pass LZ4 chunk; re-encode required");

Try / catch

try { using var s = new LZ4Stream(File.OpenRead(path)); ... }
catch (NotSupportedException ex) when (ex.Message.Contains("multiple passes")) { // re-encode with supported writer
}

Prevention

When it happens

Trigger: Reading a stream produced with chunk flags encoding passes > 0 (multiple compression passes), which this reader version cannot decode.

Common situations: Cross-version incompatibility: newer Stride/encoder wrote multi-pass chunks; third-party LZ4 stream producer with different flag semantics; corrupted flags byte that happens to set pass bits.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at sources/core/Stride.Core.Serialization/Serialization/LZ4/LZ4Stream.cs:298

            if (compressedDataBuffer == null || compressedDataBuffer.Length < compressedLength)
                compressedDataBuffer = new byte[compressedLength];
            var chunk = ReadBlock(compressedDataBuffer, 0, compressedLength);

            if (chunk != compressedLength) throw new IOException("Can't read beyond end of stream."); // currupted

            if (!isCompressed)
            {
                // swap the buffers
                (compressedDataBuffer, dataBuffer) = (dataBuffer, compressedDataBuffer);
                bufferLength = compressedLength;
            }
            else
            {
                if (dataBuffer == null || dataBuffer.Length < originalLength)
                    dataBuffer = new byte[originalLength];
                var passes = (int)flags >> 2;
                if (passes != 0)
                    throw new NotSupportedException("Chunks with multiple passes are not supported.");
                LZ4Codec.Decode(compressedDataBuffer, 0, compressedLength, dataBuffer, 0, originalLength);
                bufferLength = originalLength;
            }

            bufferOffset = 0;
        } while (bufferLength == 0); // skip empty block (shouldn't happen but...)

        return true;
    }

    #endregion

    #region overrides

    /// <inheritdoc/>
    public override bool CanRead
    {
        get { return compressionMode == CompressionMode.Decompress; }

View on GitHub (pinned to 96fad776d2)