Patrick Klug
Patrick Klug

Reputation: 14411

Explain massive performance difference in html canvas image drawing

While investigating some performance issues I stumbled upon the following performance comparison:

http://jsperf.com/fastest-canvas-drawing/2

which yields the following result:

enter image description here

This seems to suggest that if you use anything but a createObjectURL image drawImage will be more than 90% slower. Is this really the case? Why?

Upvotes: 1

Views: 201

Answers (1)

John Flatness
John Flatness

Reputation: 33789

Did you run this test in Chrome, Safari or another WebKit?

window.URL is undefined in Chrome, you'd need to use window.webkitURL instead (although not anymore in Chrome 23, but the use of mozGetAsFile kills you anyway). You're seeing such faster results because the tests are just erroring out under Chrome for that option.

On Firefox, the results are much more in line with one another, as you might expect.

Upvotes: 1

Related Questions