The load event of "iOS12+ Wechat browser" image is triggered in advance.

I have the following extremely simple code:

var img = new Image()
img.onload = () => {
    var canvas = document.createElement("canvas")
    var ctx = canvas.getContext("2d")
    ctx.drawImage(img, 0, 0)
}
img.src = "xxx"

the above code is fine in most cases, but in Wechat of iOS12, a BUG,onload event will be triggered in advance, and the image has not yet been loaded, so canvas cannot draw the image. It"s not always wrong, it"s just one or two times out of 10.

has anyone met?

Aug.13,2021
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-1e4c84c-44ed1.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-1e4c84c-44ed1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?