Repository navigation
Fix WebGL scaling of antialising by pixel ratio - #13783
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## branch-3.5 #13783 +/- ##
===========================================
Coverage 92.65% 92.65%
===========================================
Files 326 326
Lines 20734 20734
===========================================
Hits 19211 19211
Misses 1523 1523 |
| await display(row([plot("canvas"), plot("svg"), plot("webgl")])) | ||
| }) | ||
|
|
||
| it.dpr(3)("with devicePixelRatio == 3", async () => { |
There was a problem hiding this comment.
I'm not sure if just using .dpr(N) is enough to produce a meaningful test. I think this needs scaling as well, but we don't have an API exposed for this currently, though it's possible at CDP (Chrome Devtools Protocol) level.
There was a problem hiding this comment.
There was a problem hiding this comment.
I'd happily remove the new test and save the disk space. But if we keep it we can at least identify when it changes and it will lead us back here where there are instructions for a manual test.
There was a problem hiding this comment.
I would like to keep this test, but I would also like to establish if we can make the difference more obvious. I did a little bit of exploration myself and there is a difference when comparing generated images between branch-3.5 and this PR, so this test is indeed valid, though hard on "the naked eye". I tried to enable scaling in CDP, but it doesn't seem to do anything useful. So I suppose this will have to do for now.
|
It looks to me like the test failures are unrelated. |
* Fix webgl handling of pixel ratio * Fix spelling mistake
* Fix webgl handling of pixel ratio * Fix spelling mistake
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |


Fixes #13692, the incorrect scaling of WebGL antialiasing by pixel ratio.
The
widthandheightof the canvas used for WebGL rendering is scaled bypixel_ratio:bokeh/bokehjs/src/lib/core/util/canvas.ts
Lines 71 to 72 in 78d71c2
whereas the
antialiaswidth is constant regardless ofpixel_ratio. Following this through the WebGL rendering pipeline shows that this means the rendered antialiasing scales withpixel_ratio, and so is too large forpixel_ratio > 1such as for retina screen or zooming (which is implemented in chrome dev tools using a larger pixel ratio).The fix is to scale the antialiasing by dividing by
pixel_ratio.Test code:
before the fix on a retina screen (pixel ratio 2) at zoom level 300% (so the pixel ratio seen is 6):

and after this fix:

The fix scales the antialising that is passed to the WebGL vertex shaders. It could be performed in the vertex shaders instead, but then the antialias would have to be a GLSL
attributerather thanuniform. Whilst here I realised that thepixel_ratiois passed to the shaders but only used to scale the canvas size, i.e. to remove thepixel_ratiomultiple added incanvas.tsabove. So I have moved this scaling toBaseGLGlyphinstead which means we no longer need to passpixel_ratiointo any of the shaders. It is not a big deal either way, but I think this implementation is a bit simpler and cleaner.