Skip to content

Images over the browser canvas limit import as a blank preview and leave the app unresponsive #125

Closed

Description

@vycdev

Note

🤖 Claude Opus 5.5 responding on behalf of Victor Sandu

Images larger than Chromium's maximum canvas area import without any warning. The 2D preview stays blank and the app stays sluggish for more than 90 seconds. The size badge reports the new dimensions, so the image looks loaded but can't be worked with.

Environment

  • develop at 05a2997, Vite dev server, Playwright's bundled Chromium on Windows 11, 1440×1000 viewport.
  • Not tested in Firefox, Safari, or the desktop app (WebView2 / WKWebView / WebKitGTK).

Steps

  1. Generate a 17000×17000 PNG (1-bit grayscale stripes, 46 KB):

    // node make-huge.mjs 17000  ->  huge-17000.png
    import fs from 'node:fs';
    import zlib from 'node:zlib';
    const W = Number(process.argv[2]);
    const crc32 = (b) => { let c = ~0; for (const x of b) { c ^= x; for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1; } return ~c >>> 0; };
    const chunk = (t, d) => { const l = Buffer.alloc(4); l.writeUInt32BE(d.length); const td = Buffer.concat([Buffer.from(t), d]); const c = Buffer.alloc(4); c.writeUInt32BE(crc32(td)); return Buffer.concat([l, td, c]); };
    const ihdr = Buffer.alloc(13); ihdr.writeUInt32BE(W, 0); ihdr.writeUInt32BE(W, 4); ihdr[8] = 1;
    const row = 1 + Math.ceil(W / 8); const raw = Buffer.alloc(row * W);
    for (let y = 0; y < W; y++) raw.fill(y % 64 < 32 ? 0xff : 0, y * row + 1, (y + 1) * row);
    fs.writeFileSync(`huge-${W}.png`, Buffer.concat([Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]), chunk('IHDR', ihdr), chunk('IDAT', zlib.deflateSync(raw, { level: 9 })), chunk('IEND', Buffer.alloc(0))]));
  2. Open /app and choose the file with Choose file.

Expected / actual

Expected: Kromacut refuses the image, or offers to downscale it, with a visible explanation, and keeps the current image.

Actual: the badge changes to 17000×17000 within about 5 s. The preview stays empty and no error, alert, console error, or warning appears. The page answered a trivial page.evaluate in 2–10 s at every probe for the full 90 s observed and never recovered. The previous image is still in undo history, so Undo is a way back.

Image Pixels Preview Responsiveness after import
12000×12000 144 M Renders Back to normal (3 ms) after ~19 s
17000×17000 289 M Blank 2–10 s per probe for 90 s+, no recovery

Likely cause (not yet confirmed in code)

Chromium limits a canvas to 268,435,456 pixels (16384×16384), and 17000×17000 is over that. CanvasPreview copies the decoded image into offscreen canvases at full resolution and never checks whether that worked, so later processing seems to keep running against an unusable canvas. I haven't traced which step is slow.

Suggested direction

After decoding, compare naturalWidth × naturalHeight with a conservative pixel limit before committing the image. Above the limit, keep the current image and show a localized notice, possibly with an option to downscale. #124 adds an image-import error notice that this could reuse.

Activity

  1. added
    bug
    on Nov 3, 2026
  2. vycdev commented on Nov 15, 2026

    @vycdev
    OwnerAuthor

    Note

    🤖 Claude Opus 5.5 responding on behalf of vycdev

    Fixed by #146 (31b3881). Imports over 268,435,456 px or 65,535 px per side are refused before they enter image history. iPhone and iPad use a 16,777,216 px budget. A localized notice shows the image dimensions and resize advice, and the current image, undo history and swatches stay unchanged. e0a50d4 and aea63a4 added per-axis canvas probes, so thin panoramas still load and browser privacy noise doesn't cause false rejections.

    Not tested yet: Firefox and the packaged desktop WebViews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions