mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): handle error from internal konva method
We are dipping into konva's private API for preview images and it appears to be unsafe (got an error once). Wrapped in a try/catch.
This commit is contained in:
parent
52202e45de
commit
423e463b95
@ -30,6 +30,7 @@ import type { GroupConfig } from 'konva/lib/Group';
|
|||||||
import { debounce } from 'lodash-es';
|
import { debounce } from 'lodash-es';
|
||||||
import { atom } from 'nanostores';
|
import { atom } from 'nanostores';
|
||||||
import type { Logger } from 'roarr';
|
import type { Logger } from 'roarr';
|
||||||
|
import { serializeError } from 'serialize-error';
|
||||||
import { getImageDTO, uploadImage } from 'services/api/endpoints/images';
|
import { getImageDTO, uploadImage } from 'services/api/endpoints/images';
|
||||||
import type { ImageDTO } from 'services/api/types';
|
import type { ImageDTO } from 'services/api/types';
|
||||||
import { assert } from 'tsafe';
|
import { assert } from 'tsafe';
|
||||||
@ -550,17 +551,22 @@ export class CanvasObjectRenderer extends CanvasModuleBase {
|
|||||||
if (this.parent.transformer.pixelRect.width === 0 || this.parent.transformer.pixelRect.height === 0) {
|
if (this.parent.transformer.pixelRect.width === 0 || this.parent.transformer.pixelRect.height === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const canvas = this.konva.objectGroup._getCachedSceneCanvas()._canvas as HTMLCanvasElement | undefined | null;
|
try {
|
||||||
if (canvas) {
|
const canvas = this.konva.objectGroup._getCachedSceneCanvas()._canvas as HTMLCanvasElement | undefined | null;
|
||||||
const nodeRect = this.parent.transformer.nodeRect;
|
if (canvas) {
|
||||||
const pixelRect = this.parent.transformer.pixelRect;
|
const nodeRect = this.parent.transformer.nodeRect;
|
||||||
const rect = {
|
const pixelRect = this.parent.transformer.pixelRect;
|
||||||
x: pixelRect.x - nodeRect.x,
|
const rect = {
|
||||||
y: pixelRect.y - nodeRect.y,
|
x: pixelRect.x - nodeRect.x,
|
||||||
width: pixelRect.width,
|
y: pixelRect.y - nodeRect.y,
|
||||||
height: pixelRect.height,
|
width: pixelRect.width,
|
||||||
};
|
height: pixelRect.height,
|
||||||
this.$canvasCache.set({ rect, canvas });
|
};
|
||||||
|
this.$canvasCache.set({ rect, canvas });
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// We are using an internal Konva method, so we need to catch any errors that may occur.
|
||||||
|
this.log.warn({ error: serializeError(error) }, 'Failed to update preview canvas');
|
||||||
}
|
}
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user