Run details:
Mozilla/5.0 (iPhone; CPU iPhone OS 14_4_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1
Mobile Safari 14
iOS 14.4.2
Mobile
3 years ago
Test name Executions per second
Image 21857364.0 Ops/sec
ImageBitmap 22161024.0 Ops/sec
Script Preparation code:
x
 
var img = new Image();
var imageBitmap;
var doneLoading = false;
let canvas = document.createElement('canvas');
canvas.width = 640;
canvas.height = 480;
let canvas2 = document.createElement('canvas');
canvas2.width = 640;
canvas2.height = 480;
var ctx = canvas.getContext('2d');
var ctx2 = canvas2.getContext('2d');
img.addEventListener('load', function() {
  Promise.all([
    createImageBitmap(img)
  ]).then(function(images) {
  imageBitmap = images[0];
  doneLoading = true;
}, false);
});
img.src = 'https://media.discordapp.net/attachments/447410261289205781/574359442913492992/unknown.png';
Tests:
  • Image

     
    if (doneLoading)
    ctx.drawImage(img,0,0);
  • ImageBitmap

     
    if (doneLoading)
    ctx2.drawImage(imageBitmap,0,0);