canvas icon indicating copy to clipboard operation
canvas copied to clipboard

[bug] Canvas content gets reset if app draws with delay

Open CatchABus opened this issue 2 years ago • 0 comments

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);
}

Screenshot from 2022-11-17 12-38-49

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);
}

Screenshot from 2022-11-17 12-39-05

CatchABus avatar Nov 17 '22 10:11 CatchABus