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

Issue 713632 link

Starred by 8 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Apr 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 1
Type: Bug-Regression

Blocked on:
issue skia:6547

Blocking:
issue 634542


Show other hotlists

Hotlists containing this issue:
Hotlist-2


Sign in to add a comment

putImageData is “darkening” the image

Reported by ricardo....@arealmedia.com, Apr 20 2017

Issue description

Steps to reproduce the problem:
Execute the following code but with an existence image:

///// JAVASCRIPT
var canvasLocal = document.getElementById('c'),
	context = canvasLocal.getContext('2d'),
	canvasToRender1 = document.getElementById('c2'),
	ctx = canvasLocal.getContext("2d"),
	canvasToRender1Ctx = canvasToRender1.getContext('2d'),
	base_image = new Image();

base_image.src = 'imagem3.jpg';
base_image.onload = function() {
	canvasLocal.width = canvasToRender1.width = base_image.width;
	canvasLocal.height = canvasToRender1.height = base_image.height;

	context.drawImage(base_image, 0, 0);

	var imgData = ctx.getImageData(0, 0, base_image.width, base_image.height);

	//canvasToRender1Ctx.drawImage(canvasLocal,0,0)

	canvasToRender1Ctx.putImageData(imgData,0,0);
}

/// HTML

<html>
<head>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

</head>
<body>

<canvas id="c"></canvas>
<canvas id="c2"></canvas>
<script src="javascript.js"></script>
</body>
</html>

What is the expected behavior?
The two images on different canvas looks the same

What went wrong?
the image on the second canvas looks darken that the first one

Did this work before? No 

Chrome version: 57.0.2987.132  Channel: stable
OS Version: 6.0.1 or higher
Flash Version: 

I don't think this is a regression because it is not depends on the chrome version but with android version. Android version 6.0.0 or above works fine.
 
Screenshot_2017-04-20-10-30-06-190_com.android.chrome.png
583 KB View Download

Comment 1 by mmenke@chromium.org, Apr 20 2017

Components: -Blink Blink>Canvas
Sounds like the same as  issue 713702 .

Comment 2 by junov@chromium.org, Apr 20 2017

Labels: Needs-Feedback
Owner: zakerinasab@chromium.org
Status: Assigned (was: Unconfirmed)
@ricardo.rocha: In the bug you state that the poblem happens with Android 6.0.1 or higher and in the text you say that it works fine with Android 6.0.0 or above.  Those two statements seem contradictory.  Please clarify.
Yes, it looks like the same issue but I have more info.

Sorry, It was a mistake. It is work Android 6.0.0 or below.

Comment 4 by junov@chromium.org, Apr 24 2017

 Issue 714546  has been merged into this issue.

Comment 5 by junov@chromium.org, Apr 24 2017

Labels: -Pri-2 Pri-1

Comment 6 by junov@chromium.org, Apr 24 2017

Cc: ccameron@chromium.org
Labels: -Type-Bug Type-Bug-Regression
@ccameron: any ideas of what might have triggered this?
 issue 713702  should probably be merged, too.

Comment 8 by kbr@chromium.org, Apr 25 2017

Blockedon: skia:6547
Cc: msarett@chromium.org zakerinasab@chromium.org
 Issue 713702  has been merged into this issue.
Project Member

Comment 10 by bugdroid1@chromium.org, Apr 25 2017

The following revision refers to this bug:
  https://skia.googlesource.com/skia/+/7ab6a7f40b23610577bd64fbcb6121a2a715469b

commit 7ab6a7f40b23610577bd64fbcb6121a2a715469b
Author: Brian Osman <brianosman@google.com>
Date: Tue Apr 25 19:28:07 2017

Fix writePixels of sRGB data to legacy GPU surface

Adjusted unit test to verify this behavior.

Bug:  skia:6547   chromium:713632   chromium:713702 
Change-Id: I6240937b2faf6ccb6adfc9477dc85ae961cdbbb7
Reviewed-on: https://skia-review.googlesource.com/14279
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>

[modify] https://crrev.com/7ab6a7f40b23610577bd64fbcb6121a2a715469b/tests/SRGBReadWritePixelsTest.cpp
[modify] https://crrev.com/7ab6a7f40b23610577bd64fbcb6121a2a715469b/src/gpu/GrContext.cpp

Project Member

Comment 11 by bugdroid1@chromium.org, Apr 26 2017

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

commit 678a0bea8eb9989953ca780f6afcb382ae047aee
Author: zakerinasab <zakerinasab@chromium.org>
Date: Wed Apr 26 17:50:29 2017

Fix darkened pixels when rendering using GPU

This CL fixes the issue reported in bugs  713632  and  713702 , where the
pixels are darker than usual when rendered with GPU on some specific
devices.

BUG= 713632 
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

Review-Url: https://codereview.chromium.org/2838153003
Cr-Commit-Position: refs/heads/master@{#467372}

[add] https://crrev.com/678a0bea8eb9989953ca780f6afcb382ae047aee/content/test/data/gpu/pixel_canvas2d_untagged.html
[modify] https://crrev.com/678a0bea8eb9989953ca780f6afcb382ae047aee/content/test/gpu/gpu_tests/pixel_expectations.py
[modify] https://crrev.com/678a0bea8eb9989953ca780f6afcb382ae047aee/content/test/gpu/gpu_tests/pixel_test_pages.py
[modify] https://crrev.com/678a0bea8eb9989953ca780f6afcb382ae047aee/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp

Status: Fixed (was: Assigned)

Comment 13 by junov@chromium.org, Apr 26 2017

Labels: Merge-Request-59 Merge-Request-58
Either of these two CLs should be merged to M-58 and M-59
Project Member

Comment 14 by sheriffbot@chromium.org, Apr 26 2017

Labels: -Merge-Request-59 Hotlist-Merge-Approved Merge-Approved-59
Your change meets the bar and is auto-approved for M59. Please go ahead and merge the CL to branch 3071 manually. Please contact milestone owner if you have questions.
Owners: amineer@(Android), cmasso@(iOS), gkihumba@(ChromeOS), Abdul Syed@(Desktop)

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Project Member

Comment 15 by sheriffbot@chromium.org, Apr 26 2017

Labels: -Merge-Request-58 Merge-Review-58 Hotlist-Merge-Review
This bug requires manual review: Request affecting a post-stable build
Please contact the milestone owner if you have questions.
Owners: amineer@(Android), cmasso@(iOS), bhthompson@(ChromeOS), govind@(Desktop)

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
 Issue 715399  has been merged into this issue.
Project Member

Comment 17 by sheriffbot@chromium.org, May 1 2017

Cc: junov@chromium.org
This issue has been approved for a merge. Please merge the fix to any appropriate branches as soon as possible!

If all merges have been completed, please remove any remaining Merge-Approved labels from this issue.

Thanks for your time! To disable nags, add the Disable-Nags label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Project Member

Comment 18 by bugdroid1@chromium.org, May 1 2017

Labels: -merge-approved-59 merge-merged-3071
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1e6b9d44e81ce02e2c913ae15f8a77679fa47cab

commit 1e6b9d44e81ce02e2c913ae15f8a77679fa47cab
Author: Reza.Zakerinasab <zakerinasab@chromium.org>
Date: Mon May 01 16:08:08 2017

Fix darkened pixels when rendering using GPU

This CL fixes the issue reported in bugs  713632  and  713702 , where the
pixels are darker than usual when rendered with GPU on some specific
devices.

BUG= 713632 
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

Review-Url: https://codereview.chromium.org/2838153003
Cr-Commit-Position: refs/heads/master@{#467372}
(cherry picked from commit 678a0bea8eb9989953ca780f6afcb382ae047aee)

Review-Url: https://codereview.chromium.org/2855633002 .
Cr-Commit-Position: refs/branch-heads/3071@{#322}
Cr-Branched-From: a106f0abbf69dad349d4aaf4bcc4f5d376dd2377-refs/heads/master@{#464641}

[add] https://crrev.com/1e6b9d44e81ce02e2c913ae15f8a77679fa47cab/content/test/data/gpu/pixel_canvas2d_untagged.html
[modify] https://crrev.com/1e6b9d44e81ce02e2c913ae15f8a77679fa47cab/content/test/gpu/gpu_tests/pixel_expectations.py
[modify] https://crrev.com/1e6b9d44e81ce02e2c913ae15f8a77679fa47cab/content/test/gpu/gpu_tests/pixel_test_pages.py
[modify] https://crrev.com/1e6b9d44e81ce02e2c913ae15f8a77679fa47cab/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp

Labels: -Merge-Review-58 Merge-Rejected-58
We've already shipped M58 and thus have no tolerance for add'l risk via cherry picks unless the regression is critical.  Given the regression existed in M57 and usage of putImageData appears to be very low (<=0.0001% of all pageloads per https://www.chromestatus.com/metrics/feature/popularity) I'm rejecting the M58 merge - when M59 moves to stable the fix will be deployed.

Apologies, but we have to make tradeoffs given the nature of the product - please let me know if this is causing anyone major issues in prod sites and we can re-evaluate.

Comment 20 by oss...@cendio.com, May 3 2017

Our customers are hit by this rather badly as it breaks noVNC. See screen shots here:

https://www.cendio.com/bugzilla/show_bug.cgi?id=6347

If I understand things correctly M59 will be with users at the start of June?
I can confirm this, our customers are hit badly as well. And it's not just a small issue, but big one. We are using canvas for resizing images and these are some very important images from warehouse sent to suppliers. And now they are very bad and details can't be seen properly. So please fix it ASAP. Thanks
I'd like to see this fixed as soon as possible too. We will have to produce a workaround, anyway. Can I have confirmation that decomposing one big putImageData into smaller putImageData with an area smaller than 256x256 will not trigger the bug? Are 256x256 bitmaps (or less) guaranteed to avoid the bug?

If we manage to produce a working alternative to putImageData that works, we will post it here.

Comment 23 by oss...@cendio.com, May 3 2017

It's the size of the canvas that matters, not the size of the putImageData() call. We do very small blits and we see the issue.
You can use the drawImage instade of the putImageData like I did. See this stackoverflow post: http://stackoverflow.com/questions/43515988/putimagedata-is-darkening-the-image?noredirect=1#comment74096918_43515988

Comment 25 by oss...@cendio.com, May 3 2017

Indeed. However that doesn't work if you have raw pixel data in a Javascript array.
That's too bad. I also generate a pixel array with javascript. Can anybody suggest a way to produce a workaround? Thanks.
Hi, is there any release date for this fix in Android Chrome ?

Thanks
After some tests:

-It does not work on Chrome beta 59.0.3071.12
-It works on Chrome Dev 60.0.3096.5

Both builds are available on Google play.


I'd like to add that for my usage I found a workaround, if someone is looking for interim solution before the fix is rolled out.

If getImageData/putImageData are done on the same context, the issue does not seem to appear. Like:

var imageData = interimContext.getImageData(0, 0, w, h); // have to getImageData, using new ImageData has the same "darkening" issue
// ... Manipulate imageData as needed here
interimContext.putImageData(imageData, 0, 0)
// Draw things from interim canvas to the final one
targetContext.drawImage(interimCanvas, 0, 0)
Hi,

I may have found a workaround for those who need pixel manipulation. (Sorry for the little noise the following code includes, only mobile keyboard & copy-paste available to me). You have to use getImageData instead of createImageData to create a new pixels array. It works for me as I set all array pixels. Code that works for me:

    canvas = document.querySelector('canvas');
    var image = document.querySelector('img');
    context = canvas.getContext('2d');
    canvas.width = iw;
    canvas.height = ih;
    context.drawImage(image, 0, 0);
    var src_pixels = context.getImageData(0, 0, iw, ih);
    src = src_pixels.data;
    allsrc = src.length;

    canvas.width = cw;
    canvas.height = ch;
    //BUG : final image darker
    //tgt_pixels = context.createImageData(cw, ch);
    //WORKAROUND : final image OK
    tgt_pixels = context.getImageData(0, 0, cw, ch);
    target = tgt_pixels.data;
    alltgt = target.length;

One missing info : to draw final image I use
context.putImageData(tgt_pixels, 0, 0);
Chrome 59 (59.0.3071.92)for Android witch fix this issue is supposed to be released this week according to this post:

https://chromereleases.googleblog.com/2017/06/chrome-for-android-update.html

The update is not available on my account. Anyone here had the update ?

Thanks
Project Member

Comment 33 by bugdroid1@chromium.org, Aug 23 2017

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

commit 5f0a7fa2b08349306dd1f7cc0e039b73c14d259a
Author: Justin Novosad <junov@chromium.org>
Date: Wed Aug 23 21:51:30 2017

Clean-up forgotten reference images for gpu pixel tests

Several tests were marked for rebaselining a while ago and seem to
have been forgotten (associated bugs closed).

BUG= 615325 ,  721727 ,  713632 

TBR=dongseong.hwang@intel.com, zakerinasab@chromium.org, vmiura@chromium.org

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: I0cc24618c7a4647a64ec3ed56318aee18dc9ea72
Reviewed-on: https://chromium-review.googlesource.com/624522
Commit-Queue: Justin Novosad <junov@chromium.org>
Reviewed-by: Mohammad Reza Zakerinasab <zakerinasab@chromium.org>
Reviewed-by: Justin Novosad <junov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#496820}
[modify] https://crrev.com/5f0a7fa2b08349306dd1f7cc0e039b73c14d259a/content/test/gpu/gpu_tests/pixel_expectations.py
[modify] https://crrev.com/5f0a7fa2b08349306dd1f7cc0e039b73c14d259a/content/test/gpu/gpu_tests/pixel_test_pages.py

Blocking: 634542

Sign in to add a comment