toeverything/AFFiNE · error · Error
Image is empty or invalid
Error message
Image is empty or invalid
What it means
Thrown in the Electron `captureArea` IPC handler when `capturePage` returns an empty image for the requested rectangle — the region was zero-sized/off-screen or the renderer could not produce pixels. The capture fails fast with this error instead of writing an empty PNG.
Source
Thrown at packages/frontend/apps/electron/src/main/ui/handlers.ts:226
// see https://www.electronjs.org/docs/latest/tutorial/spellchecker#how-to-set-the-languages-the-spellchecker-uses
if (isMacOS()) {
return;
}
if (e.sender.session.availableSpellCheckerLanguages.includes(language)) {
e.sender.session.setSpellCheckerLanguages([language, 'en-US']);
}
},
captureArea: async (e, { x, y, width, height }: Electron.Rectangle) => {
const image = await e.sender.capturePage({
x: Math.floor(x),
y: Math.floor(y),
width: Math.floor(width),
height: Math.floor(height),
});
if (image.isEmpty()) {
throw new Error('Image is empty or invalid');
}
const buffer = image.toPNG();
if (!buffer || !buffer.length) {
throw new Error('Failed to generate PNG buffer from image');
}
clipboard.writeImage(nativeImage.createFromBuffer(buffer));
},
} satisfies NamespaceHandlers;
View on GitHub (pinned to b6de0ad51b)
Solutions
- Provide a non-empty, decodable image before calling this handler.
- Check the source of the image (clipboard or file) for corruption.
- Convert the image to a standard format (PNG/JPEG) and retry.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/frontend/apps/electron/src/main/ui/handlers.ts:312 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of toeverything/AFFiNE@b6de0ad51b (2026-08-18).
Data as JSON: /api/errors/2744c47589d27afa.
Report an issue: GitHub.