New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 592590 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 580202
Owner:
Closed: Mar 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

createImageBitmap does synchronous decode on main thread

Reported by a...@scirra.com, Mar 7 2016

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2670.0 Safari/537.36

Example URL:
https://www.scirra.com/labs/imageConversion/

Steps to reproduce the problem:
1. Visit the example URL.
2. Click "Load images as blobs" and wait for it to finish downloading. (There is about 20mb of total image data.)
3. Click the button to convert via drawImage/getImageData and note the time to convert all the images.
4. Click the button to convert via createImageBitmap/getImageData and note the time to convert all the images.

What is the expected behavior?
The first button forces all images to synchronously decode on the main thread as it draws HTMLImageElements to a canvas then calls getImageData immediately after. This is expected to be slow.

The second button should decode all images asynchronously using createImageBitmap, then quickly complete the drawImage and getImageData calls, since the image decoding is already complete. Therefore on a quad-core computer, I would expect this to complete about four times faster (maybe three for allowing the overhead of having to call getImageData synchronously on the main thread only).

What went wrong?
On my machine:
drawImage/getImageData takes ~970ms
createImageBitmap/getImageData takes ~800ms

Using createImageBitmap to asynchronously decode images has only improved performance by about 18% on a quad-core machine. Further, if I open dev tools and record a timeline while using createImageBitmap, it shows a lot of "image decode" operations on the main thread, some taking as long as 45ms.

Does it occur on multiple sites: Yes

Is it a problem with a plugin? No 

Did this work before? N/A 

Does this work in other browsers? N/A 

Chrome version: 51.0.2670.0  Channel: canary
OS Version: 10.0
Flash Version: Shockwave Flash 21.0 r0

This appears to defeat the purpose of createImageBitmap: it is supposed to be asynchronous and able to use multiple CPU cores, but instead it just ends up doing the same slow synchronous main-thread decoding it was designed to avoid.
 
Components: -Blink Blink>Image

Comment 2 by noel@chromium.org, Mar 14 2016

Cc: kbr@chromium.org junov@chromium.org noel@chromium.org
Components: -Blink>Image Blink>Canvas
Owner: xidac...@chromium.org
Status: Assigned (was: Unconfirmed)
Mergedinto: 580202
Status: Duplicate (was: Assigned)
@ash: could you please try again on windows canary. I tried 51.0.2679.0, what I got is this:
drawImage/getImageData takes 1050ms
createImageBitmap/getImageData takes 276ms

Comment 6 by a...@scirra.com, Mar 16 2016

Yes actually it seems faster in Canary 51.0.2679.0  now.

Sign in to add a comment