New issue
Advanced search Search tips

Issue 596251 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2016
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Feature



Sign in to add a comment

createImageBitmap fails with SVG input

Project Member Reported by jakearchibald@chromium.org, Mar 19 2016

Issue description

Owner: xidac...@chromium.org
Status: Assigned (was: Untriaged)

Comment 2 by junov@chromium.org, Mar 22 2016

The spec compliant behavior is to reject the promise with an InvalidStateError, rather than null.

For reference:
https://html.spec.whatwg.org/multipage/webappapis.html#dom-createimagebitmap

To make it possible to go directly from an SVG image to an ImageBitmap, we'd need a new API to specify the scale at which the SVG is to be rasterized.  Currently there is no default sizing algorithm defined in the spec.
junov@: I am not sure which category of "reject the promise" should this case belong to.

In my opinion, the following case seems to fit here:
Read the Blob object's data. If an error occurs during reading of the object, then reject the promise with null, and abort these steps.

Comment 4 by junov@chromium.org, Mar 22 2016

It is point 3: "If the img element's media data is not a bitmap (e.g. it's a vector graphic), then return a promise rejected with an InvalidStateError exception and abort these steps."

Comment 5 by junov@chromium.org, Mar 22 2016

Oh I see, the example uses a blob, not an img...  Hmmm... seems the spec needs to be clarified.

What applies is point 6: "If the image data is not in a supported file format (e.g. it's not actually an image at all), or if the image data is corrupted in some fatal way such that the image dimensions cannot be obtained, then reject the promise with null, and abort these steps."

So it appears the current behavior is correct.
The spec has been updated https://github.com/whatwg/html/issues/864

Promises should never reject with null for the same reasons sync code shouldn't throw null.
To clarify, the solution I was hoping for this ticket was for createImageBitmap to successfully create a bitmap from SVG.
I've created https://github.com/whatwg/html/issues/923 to get feedback on vector formats and createImageBitmap.
Project Member

Comment 9 by bugdroid1@chromium.org, Mar 30 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/672ae7a2037e92b305054849f31a7bb4fb873823

commit 672ae7a2037e92b305054849f31a7bb4fb873823
Author: xidachen <xidachen@chromium.org>
Date: Wed Mar 30 19:12:14 2016

Reject promise with InvalidStateError instead of null in createImageBitmap(Blob)

Right now, the createImageBitmap(Blob) reject promise with null when
the input image cannot be decoded, for example, the input image is a SVG
image. A recently change is made to the specs here:
https://github.com/whatwg/html/pull/884
which states that we should reject the promise with InvalidStateError
insetad of null.

This CL changes it such that it will reject the promise with a
InvalidStateError.

BUG= 596251 

Review URL: https://codereview.chromium.org/1841313003

Cr-Commit-Position: refs/heads/master@{#384045}

[modify] https://crrev.com/672ae7a2037e92b305054849f31a7bb4fb873823/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-invalid-args-expected.txt
[modify] https://crrev.com/672ae7a2037e92b305054849f31a7bb4fb873823/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-invalid-blob-in-workers-expected.txt
[modify] https://crrev.com/672ae7a2037e92b305054849f31a7bb4fb873823/third_party/WebKit/LayoutTests/fast/canvas/resources/canvas-createImageBitmap-invalid-blob-in-workers.js
[modify] https://crrev.com/672ae7a2037e92b305054849f31a7bb4fb873823/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp

Project Member

Comment 10 by bugdroid1@chromium.org, Mar 30 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/672ae7a2037e92b305054849f31a7bb4fb873823

commit 672ae7a2037e92b305054849f31a7bb4fb873823
Author: xidachen <xidachen@chromium.org>
Date: Wed Mar 30 19:12:14 2016

Reject promise with InvalidStateError instead of null in createImageBitmap(Blob)

Right now, the createImageBitmap(Blob) reject promise with null when
the input image cannot be decoded, for example, the input image is a SVG
image. A recently change is made to the specs here:
https://github.com/whatwg/html/pull/884
which states that we should reject the promise with InvalidStateError
insetad of null.

This CL changes it such that it will reject the promise with a
InvalidStateError.

BUG= 596251 

Review URL: https://codereview.chromium.org/1841313003

Cr-Commit-Position: refs/heads/master@{#384045}

[modify] https://crrev.com/672ae7a2037e92b305054849f31a7bb4fb873823/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-invalid-args-expected.txt
[modify] https://crrev.com/672ae7a2037e92b305054849f31a7bb4fb873823/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-invalid-blob-in-workers-expected.txt
[modify] https://crrev.com/672ae7a2037e92b305054849f31a7bb4fb873823/third_party/WebKit/LayoutTests/fast/canvas/resources/canvas-createImageBitmap-invalid-blob-in-workers.js
[modify] https://crrev.com/672ae7a2037e92b305054849f31a7bb4fb873823/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp

Labels: -Type-Bug Type-Feature
Change this from bug-->feature, awaiting for feedback from here:
https://github.com/whatwg/html/issues/923

Comment 12 by junov@chromium.org, Mar 30 2016

Xida, in the interest of clarity, could you close this and create a new fresh crbug that is just about the feature request?
Closing this bug, a new crbug is filed here:
https://bugs.chromium.org/p/chromium/issues/detail?id=599228
Status: Fixed (was: Assigned)

Sign in to add a comment