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

Issue 796202 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner:
Last visit > 30 days ago
Closed: Jan 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Discrepancy in exception in Canvas::ToBlob and OffscreenCanvas::ConvertToBlob

Project Member Reported by xlai@chromium.org, Dec 19 2017

Issue description

HTMLCanvasElement.toBlob and OffscreenCanvas.convertToBlob appear to handle exception cases differently:

1. Calling toBlob/ConvertToBlob without rendering contexts -> canvas will return a null blob; OffscreenCanvas return with an exception.
2. IsPaintable is implemented differently and resolve with different exception handling methods.
etc.
 

Comment 1 by xlai@chromium.org, Dec 19 2017

Also, when encoding fails, canvas.toBlob returns with a null blob. But OffscreenCanvas.convertToBlob just rejects the promise.
Project Member

Comment 2 by bugdroid1@chromium.org, Dec 21 2017

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

commit 8dd25838e2d3d498d3801cd6269d7de8a637ce51
Author: xlai <xlai@chromium.org>
Date: Thu Dec 21 16:07:08 2017

Make ConvertToBlob behave the same as toBlob in exception/failure handling

The HTMLCanvasElement::toBlob have the following behavior:
1. When it has invalid image size (width/height is zero), it will return
   a null blob.
2. When it does not have contexts but has valid image size, it will generate
   a blob representing a transparent image.
3. When it fails encoding, it will return a null blob.

This behavior is correctly obeying the spec as in
https://html.spec.whatwg.org/multipage/canvas.html#dom-canvas-toblob.

But OffscreenCanvas::convertToBlob is currently doing differently:
1. When it has invalid image size (width/height is zero), it throws exception.
2. When it does not have contexts, it throws exception.
3. When it fails encoding, it throws exception.

The CL changes all above-mentioned cases in OffscreenCanvas to behave as same
as that in HTMLCanvas.

This CL also includes a few small fixes to the discrepancy between Offscreen
and html canvases (e.g. GetSourceImageForCanvas(), Offscreen2D.GetImage(),
IsPaintable()). It also move some functions to CanvasRenderingContextHost to
reduce code duplication.

TBR=junov@chromium.org

Bug:  796202 
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I1af7f26aa0a6371d03a9a13dfb03f986a1e5ce39
Reviewed-on: https://chromium-review.googlesource.com/834394
Commit-Queue: Olivia Lai <xlai@chromium.org>
Reviewed-by: Fernando Serboncini <fserb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#525701}
[modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/LayoutTests/TestExpectations
[rename] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/LayoutTests/fast/canvas-api/OffscreenCanvas-convertToBlob-failures.html
[modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-zero-size-readback.html
[modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
[modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/Source/core/html/HTMLCanvasElement.h
[modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp
[modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/Source/core/html/canvas/CanvasRenderingContextHost.cpp
[modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/Source/core/html/canvas/CanvasRenderingContextHost.h
[modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.cpp
[modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.h
[modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/Source/modules/canvas/offscreencanvas2d/OffscreenCanvasRenderingContext2D.cpp

Comment 4 by xlai@chromium.org, Jan 30 2018

Status: WontFix (was: Assigned)

Sign in to add a comment