canvas
canvas copied to clipboard
[bug] Canvas content gets reset if app draws with delay
It seems that if I draw something on canvas using a timeout, the previous drawing will be erased. Seems to occur on android and ios (devices only)
Samples to test:
This works
export function onContextReady(args) {
var canvas = args.object;
var ctx = canvas.getContext("2d");
ctx.rect(50, 20, 200, 120);
ctx.stroke();
ctx.fillStyle = "red";
ctx.fillRect(0, 0, 150, 100);
}
This is with timeout. It will erase first shape and draw red rectangle alone
export function onContextReady(args) {
var canvas = args.object;
var ctx = canvas.getContext("2d");
ctx.rect(50, 20, 200, 120);
ctx.stroke();
ctx.fillStyle = "red";
setTimeout(() => ctx.fillRect(0, 0, 150, 100), 2000);
}