gravitational/teleport · error

decoder has no pixel format

Error message

decoder has no pixel format

What it means

ResizeCrop queries the C decoder for its bytes-per-pixel value; bpp==0 means the underlying rdp_decoder has no recognized pixel format (the decoder was never initialized with a source format, so output buffer sizing is impossible). The library throws this instead of allocating a bogus zero-byte buffer.

Source

Thrown at lib/srv/desktop/rdp/decoder/decoder.go:177

	return rgba
}

// ResizeCrop returns the source crop region (cropX, cropY, cropW, cropH) scaled to exactly outWidth x outHeight using
// high-quality CatmullRom convolution. The crop must lie within the current frame bounds. When withCursor is true and
// the decoder's tracked cursor is visible, it is composited onto the source frame before the crop is taken, so the
// cursor scales with the screen.
func (d *Decoder) ResizeCrop(cropX, cropY, cropW, cropH, outWidth, outHeight uint16, withCursor bool) (*image.RGBA, error) {
	if d == nil || d.ptr == nil {
		return nil, errors.New("decoder not initialized")
	}
	if outWidth == 0 || outHeight == 0 || cropW == 0 || cropH == 0 {
		return nil, errors.New("invalid resize dimensions")
	}

	bpp := int(C.rdp_decoder_bytes_per_pixel(d.ptr))
	if bpp == 0 {
		return nil, errors.New("decoder has no pixel format")
	}

	w, h := int(outWidth), int(outHeight)
	buf := make([]byte, w*h*bpp)

	var withCursorC C.uint8_t
	if withCursor {
		withCursorC = 1
	}

	ok := C.rdp_decoder_resize_crop(
		d.ptr,
		C.uint16_t(cropX),
		C.uint16_t(cropY),
		C.uint16_t(cropW),
		C.uint16_t(cropH),
		C.uint16_t(outWidth),
		C.uint16_t(outHeight),

View on GitHub (pinned to 1283425b60)

Solutions

  1. Ensure the decoder successfully decoded at least one frame before calling ResizeCrop
  2. Verify the RDP decoder was initialized with a supported pixel format (check New/Init options)
  3. Check that the CGO backend (rdp_decoder) is the real build, not a stub
  4. Log bpp and decoder state before calling ResizeCrop to detect uninitialized state

Example fix

// before
img, err := dec.ResizeCrop(...)
// after
if dec.DecodedFrames() == 0 {
    return nil, errors.New("cannot resize crop before a frame is decoded")
}
img, err := dec.ResizeCrop(...)
Defensive patterns

Strategy: validation

Validate before calling

bpp := int(C.rdp_decoder_bytes_per_pixel(d.ptr))
if bpp == 0 {
    return nil, errors.New("cannot resize: decoder has no pixel format; decode a frame first")
}

Prevention

When it happens

Trigger: Calling ResizeCrop on a decoder whose native pixel format was never set/initialized (C.rdp_decoder_bytes_per_pixel returns 0), e.g. before the first frame is decoded or after a failed decoder init.

Common situations: Calling ResizeCrop on a fresh/failed decoder before any decoded frame arrives; RDP backend built without graphics support; decoder initialized with an unsupported bpp format.

Related errors


AI-assisted analysis of gravitational/teleport@1283425b60 (2026-09-02). Data as JSON: /api/errors/631e657918f7d852. Report an issue: GitHub.