When canvas is converted to png, sometimes you get an all-black picture.

when I use toDataUrl () to convert canvas to png, sometimes I get an all-black picture, but the amazing thing is that sometimes the picture is normal, does anyone know what"s going on?

// "stage"  canvas 
const canvas = document.querySelector(".stage");
const image = canvas.toDataUrl("image/png");
const link = document.createElement("a");
link.href = image;
link.download = "balabala.png";
const event = document.createEvent("MouseEvents");
event.initMouseEvent("click", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
link.dispatchEvent(event);
Jan.21,2022

Click events should be placed in image.onload. Click black

before the picture is loaded.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9c8ad-18e6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9c8ad-18e6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?