Non-blocking cross-browser image rendering on the canvas
calendar.perfplanet.com·12h
📝WebFonts
Preview
Report Post

Canvas-based rendering has become a prominent tool for building complex web UI interfaces. When working with large images on canvas, one critical challenge stands out: keeping the main thread responsive during image decoding.

Unfortunately there’s no universal way to decode an image for canvas’ drawImage() without blocking the main thread across all browsers. An approach that works perfectly in Firefox will block the main thread in Chrome and Safari. The fix that works for Chrome, will block the main thread in Firefox and Safari. The search for the perfect solution becomes a game of whack-a-mole.

You might be wondering why drawImage() is necessary at all; why not just use a standard <img /> element? It’s a fair question, and the answer depends on what you’re building.

Our t…

Similar Posts

Loading similar posts...