{"record":{"id":"9e9a6c2471206c7b","repo":"Comfy-Org/ComfyUI","slug":"compositor-canvas-cw-x-ch-exceeds-the-maximum-su","errorCode":null,"errorMessage":"Compositor canvas {cw}x{ch} exceeds the maximum supported size of {MAX_RESOLUTION}x{MAX_RESOLUTION}","messagePattern":"Compositor canvas (.+?)x(.+?) exceeds the maximum supported size of (.+?)x(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_extras/nodes_compositor.py","lineNumber":430,"sourceCode":"def _fill_background(canvas: np.ndarray, background: dict) -> np.ndarray:\n    layer = np.empty(canvas.shape, dtype=np.float32)\n    layer[..., :3] = srgb_to_linear(\n        np.array(hex_to_rgb(background[\"color\"]), dtype=np.float32) / 255.0\n    )\n    layer[..., 3] = 1.0\n    return blend_composite(\n        resolve_mode(\"normal\"), canvas, layer, background[\"opacity\"]\n    )\n\n\ndef composite_from_state(\n    tensors: list[torch.Tensor],\n    state: dict,\n    alphas: list[torch.Tensor | None],\n) -> torch.Tensor:\n    cw, ch = state[\"canvas\"]\n    if cw > MAX_RESOLUTION or ch > MAX_RESOLUTION:\n        raise ValueError(\n            f\"Compositor canvas {cw}x{ch} exceeds the maximum supported size of \"\n            f\"{MAX_RESOLUTION}x{MAX_RESOLUTION}\"\n        )\n    canvas = np.zeros((ch, cw, 4), dtype=np.float32)\n    background = state.get(\"background\")\n    if background is not None and background[\"visible\"] and background[\"opacity\"] > 0:\n        canvas = _fill_background(canvas, background)\n    layers = state[\"layers\"]\n    order = state.get(\"order\") or range(len(tensors))\n    for index in order:\n        if index < 0 or index >= len(tensors):\n            continue\n        tensor = tensors[index]\n        entry = layers[index] if index < len(layers) else None\n        params = _layer_params(entry, tensor.shape[2], tensor.shape[1])\n        if not params[\"visible\"]:\n            continue\n        img = _prepare_layer_bitmap(","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_extras/nodes_compositor.py#L412-L448","documentation":"Before allocating the float32 numpy canvas (ch x cw x 4), composite_from_state checks the resolved canvas dimensions against ComfyUI's MAX_RESOLUTION constant. A canvas larger than that on either axis would imply a multi-gigabyte RGBA buffer, so it is rejected up front with a message naming the offending size and the cap.","triggerScenarios":"A LAYERS document whose canvas field (or derived canvas from the background image) resolves to width or height greater than MAX_RESOLUTION (ComfyUI's standard 16384). For example a canvas of [32768, 512] or layer dimensions propagating a huge size.","commonSituations":"Typos in canvas JSON (extra digit), documents authored for a different engine with huge canvases, or workflows that compute canvas size by multiplying scale factors and accidentally double the intended resolution.","solutions":["Cap canvas width/height to MAX_RESOLUTION or below in the document (usually 16384).","Fix the canvas computation upstream — look for a doubled scale factor or concatenated digits.","Tile the work: composite at a smaller canvas and upscale, or split into regions if true gigapixel output is needed."],"exampleFix":"// before\n\"canvas\": [32768, 32768]\n// after\n\"canvas\": [16384, 16384]","handlingStrategy":"validation","validationCode":"from nodes import MAX_RESOLUTION\ndef clamp_canvas(doc):\n    cw, ch = doc.get(\"canvas\", (0, 0))\n    if cw > MAX_RESOLUTION or ch > MAX_RESOLUTION:\n        raise ValueError(\"canvas too large; fix source data\")\n    return doc","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate canvas dims against MAX_RESOLUTION (16384) before building the document.","Audit scale-factor math that computes canvas size multiplicatively.","Split gigapixel composites into tiles."],"tags":["limits","canvas","memory","comfyui"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}