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

Issue 602103 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Jul 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

Canvas nearest-neighbour filtering (optimize-contrast) no longer works in Chromium v51

Project Member Reported by flo...@gmail.com, Apr 10 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.0 Safari/537.36

Steps to reproduce the problem:
1. in Chrome Canary v51, on a Mac with Retina display, open this demo and note how the text appears blurred: http://floooh.github.io/oryol/asmjs/ImGuiDemo.html
2. now do the same in Chrome stable (v49) or Firefox, and not how the text is crisp and sharp (do not bother to try in Safari, the text is always blurry there)

What is the expected behavior?
The WebGL canvas should be composed with no filtering (nearest neighbour) so that the result is crisp an all resolutions.

I'm using the following CSS statement on the canvas to switch off filtering across browsers, may be Chromium has introduced some new CSS attribute? 

.game {
    padding: 0px;
    margin-left: auto;
    margin-right: auto;
    border: 0px none;
    display: block;
    image-rendering: optimizeSpeed;
    image-rendering: -moz-crisp-edges;
    image-rendering: -o-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    -ms-interpolation-mode: nearest-neighbor;
}

What went wrong?
Chromium should not apply any image filtering when composing the canvas.

Did this work before? Yes Chrome v49, and also more recent Canaries, it seems to have been introduced very recently (at most 1 or 2 weeks before)?

Chrome version: 51.0.2704.0  Channel: canary
OS Version: OS X 10.11.5
Flash Version: Shockwave Flash 21.0 r0

It would be nice to have a single, clear standardized setting to control the image filtering mode. I don't want to have any filter applied which on lower-end platform may also introduce performance problems. You should look at what filter modes are used by 3D APIs and expose those directly, or at least provide a better way to switch all filtering off (I mean, what does "optimize-contrast" or "crisp-edges" even mean?
 

Comment 1 by flo...@gmail.com, Apr 10 2016

PS: this could be related to the following ticket?

https://bugs.chromium.org/p/chromium/issues/detail?id=562162

Comment 2 by flo...@gmail.com, Apr 10 2016

PPS: attached 2 screenshots (bad_v51 and good_v49)

bad_v51.png
10.9 KB View Download
good_v49.png
7.6 KB View Download

Comment 3 by flo...@gmail.com, Apr 10 2016

...you need to click on the screenshot to really see the difference, the scaled-down preview adds some additional blurring.

Comment 4 by flo...@gmail.com, Apr 11 2016

more info: Chromium Windows7 does not seem to be affected (I tested on a 1080p display with and without changing the Windows DPI scaling). I'll try to get ahold of an actual HighDPI Windows laptop next to confirm.
Owner: ccameron@chromium.org
Status: Assigned (was: Unconfirmed)
To ccameron@ for a look.

Comment 6 by flo...@gmail.com, Apr 12 2016

PS: Windows10 laptop with true HighDPI display the bug is also not present. Uneven upscaling factors don't look that nice, but at least it's not blurred, so it seems to be an OSX-only problem (haven't tested Linux though).


Cc: ccameron@chromium.org
Owner: erikc...@chromium.org
I thought I commented on this yesterday, but the ether must have eaten it.

This is because canvas is now being promoted to CALayer, and we don't correctly plumb through the filtering preferences from cc::TextureDrawQuad::nearest_neighbor down to the CALayer min/mag filtering properties. We need to send this down through the command buffer, over to the GPU process.

Erik, do you want to grab this, or should I?

Comment 8 by flo...@gmail.com, Apr 12 2016

Funny, I just fixed the exact same thing recently in the native Metal renderer of my engine where the same artefact happened since CALayer has linear filtering by default :) Thanks for looking into this!
I'll take this.
Project Member

Comment 10 by bugdroid1@chromium.org, Apr 19 2016

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

commit e028bfb3fb300437b56f0b377e4bd9f922d8df04
Author: erikchen <erikchen@chromium.org>
Date: Tue Apr 19 18:47:47 2016

Add plumbing to command buffer for CALayer min and mag filter.

This CL has no intended behavior change.

BUG= 602103 
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

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

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

[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/cc/output/gl_renderer.cc
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_schedule_ca_layer.txt
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/GLES2/gl2extchromium.h
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/command_buffer/build_gles2_cmd_buffer.py
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/command_buffer/client/gles2_c_lib_autogen.h
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/command_buffer/client/gles2_implementation.cc
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/command_buffer/client/gles2_implementation_autogen.h
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/command_buffer/client/gles2_interface_autogen.h
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/command_buffer/client/gles2_interface_stub_autogen.h
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/command_buffer/client/gles2_trace_implementation_autogen.h
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/command_buffer/cmd_buffer_functions.txt
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/command_buffer/common/gles2_cmd_format_autogen.h
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/command_buffer/service/gles2_cmd_decoder.cc
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/ipc/service/image_transport_surface_overlay_mac.h
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/gpu/ipc/service/image_transport_surface_overlay_mac.mm
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/mojo/gpu/mojo_gles2_impl_autogen.cc
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/mojo/gpu/mojo_gles2_impl_autogen.h
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/mojo/public/c/gles2/gles2_call_visitor_chromium_extension_autogen.h
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/ui/gl/gl_surface.cc
[modify] https://crrev.com/e028bfb3fb300437b56f0b377e4bd9f922d8df04/ui/gl/gl_surface.h

Labels: Merge-Request-51
There have been many refactors since M-51 branched, and the fix will be unpleasant to land. Better to just turn off the CA compositor for canvases with nearest-neighbor filtering.

TPMs: Permission to land a simple patch only on M51, but not on trunk?

Comment 12 by tin...@google.com, Apr 20 2016

Labels: -Merge-Request-51 Merge-Approved-51 Hotlist-Merge-Approved
Your change meets the bar and is auto-approved for M51 (branch: 2704)
Regarding c#11, what's the long term plan here? Do we have any ideas as to what's going on, so we can fix and turn this back on for M51, or do we plan on keeping it off?
I've got a fix rolling down the line for M52+, but there's been a lot of refactoring, so it would be unpleasant to try to merge it to M51.
Cc: sshru...@google.com
So, if I understand correctly, this will remain off on M51? What are the implications of that?
Prior to M51, Canvas always use the old compositing path.

In the currently M51 tree, Canvas uses IOSurfaces for filter=GL_LINEAR and filter=GL_NEAREST.

filter=GL_NEAREST doesn't work properly, so my CL would make Canvas use IOSurfaces for filter=GL_LINEAR in M51.

In M52, Canvas will use IOSurfaces for both filter types. 
Sounds good, thank you!
Project Member

Comment 19 by bugdroid1@chromium.org, Apr 25 2016

Labels: -merge-approved-51 merge-merged-2704
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e30f1306478b7b7076df7a681afb912e31a3b8b5

commit e30f1306478b7b7076df7a681afb912e31a3b8b5
Author: erikchen <erikchen@chromium.org>
Date: Mon Apr 25 21:53:59 2016

[Merge to 2704] Disable nearest_neighbors quads for CoreAnimation compositor.

The filter has not yet been plumbed through.

BUG= 602103 
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
NOTRY=true
NOPRESUBMIT=true

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

Cr-Commit-Position: refs/branch-heads/2704@{#233}
Cr-Branched-From: 6e53600def8f60d8c632fadc70d7c1939ccea347-refs/heads/master@{#386251}

[modify] https://crrev.com/e30f1306478b7b7076df7a681afb912e31a3b8b5/cc/output/ca_layer_overlay.cc

Project Member

Comment 21 by bugdroid1@chromium.org, Jul 18 2016

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

commit c32640c475b6df0e715edfbc16dd9a335e186625
Author: erikchen <erikchen@chromium.org>
Date: Mon Jul 18 23:53:21 2016

Finish plumbing for CALayerOverlay filter.

BUG= 602103 
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

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

[modify] https://crrev.com/c32640c475b6df0e715edfbc16dd9a335e186625/cc/output/gl_renderer.cc

Labels: -Hotlist-Merge-Approved -merge-merged-2704 Merge-Request-53
Status: Fixed (was: Assigned)

Comment 23 by dimu@google.com, Jul 19 2016

Labels: -Merge-Request-53 Merge-Approved-53 Hotlist-Merge-Approved
Your change meets the bar and is auto-approved for M53 (branch: 2785)
Project Member

Comment 24 by bugdroid1@chromium.org, Jul 19 2016

Labels: -merge-approved-53 merge-merged-2785
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d5a6beda14949b43926ef1a1d762da01647b85ac

commit d5a6beda14949b43926ef1a1d762da01647b85ac
Author: erikchen <erikchen@chromium.org>
Date: Tue Jul 19 23:15:26 2016

[Merge to 2785] Finish plumbing for CALayerOverlay filter.

BUG= 602103 
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review-Url: https://codereview.chromium.org/2162713002
Cr-Commit-Position: refs/heads/master@{#406154}
(cherry picked from commit c32640c475b6df0e715edfbc16dd9a335e186625)

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

Cr-Commit-Position: refs/branch-heads/2785@{#229}
Cr-Branched-From: 68623971be0cfc492a2cb0427d7f478e7b214c24-refs/heads/master@{#403382}

[modify] https://crrev.com/d5a6beda14949b43926ef1a1d762da01647b85ac/cc/output/gl_renderer.cc

Sign in to add a comment