gravitational/teleport · warning

invalid resize dimensions

Error message

invalid resize dimensions

What it means

ResizeCrop returns 'invalid resize dimensions' when any of outWidth, outHeight, cropW or cropH is zero. The crop must be a non-empty region scaled to a non-empty output; this is a cheap input sanity check before touching the native decoder.

Source

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

	rgba := image.NewRGBA(image.Rect(0, 0, int(outWidth), int(outHeight)))

	// Copy from the Rust-owned memory into Go memory.
	copy(rgba.Pix, unsafe.Slice((*uint8)(data), int(outWidth)*int(outHeight)*4))

	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),

View on GitHub (pinned to 1283425b60)

Solutions

  1. Wait for the client screen spec / first frame before requesting a resize
  2. Validate width/height are non-zero at the API boundary and reject early
  3. Fall back to the current frame dimensions when the requested size is 0
  4. Log the incoming screen spec to find which client sends zero dimensions

Example fix

// before
img, err := dec.ResizeCrop(x, y, w, h, req.Width, req.Height, false)
// after
if req.Width == 0 || req.Height == 0 {
  req.Width, req.Height = currentW, currentH
}
img, err := dec.ResizeCrop(x, y, w, h, req.Width, req.Height, false)
Defensive patterns

Strategy: validation

Validate before calling

if outWidth == 0 || outHeight == 0 || cropW == 0 || cropH == 0 {
  return errors.New("resize requires non-zero output and crop dimensions")
}

Try / catch

img, err := dec.ResizeCrop(x, y, cw, ch, ow, oh, false)
if err != nil {
  if strings.Contains(err.Error(), "invalid resize dimensions") {
    ow, oh = frameW, frameH // fall back to native frame size
    img, err = dec.ResizeCrop(x, y, cw, ch, ow, oh, false)
  }
  if err != nil { return nil, err }
}

Prevention

When it happens

Trigger: Calling ResizeCrop with a zero width/height for the output image or a zero-sized crop rectangle — usually from uninitialized screen-size variables or empty ClientScreenSpec values.

Common situations: Playback before the first client screen-spec arrives (0x0 requested size), malformed resize requests from the web UI, or a capture with a zero-area crop region.

Related errors


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