phetsims / scenery

Scenery is an HTML5 scene graph.
http://scenerystack.org/
MIT License
55 stars 12 forks source link

Canvas/WebGL can get fuzzy when dragged to high-DPI monitors #1585

Open jonathanolson opened 1 year ago

jonathanolson commented 1 year ago

We aren't listening for devicePixelRatio changes (and should be).

To reproduce, open up a sim that uses WebGL (natural-selection, neuron, etc.) or set ?rootRenderer=canvas, and:

  1. Load the simulation on a lower-DPI monitor
  2. Move the browser to a higher-DPI monitor
  3. The simulation's Canvas/WebGL parts will be blurrier than if you reload (or load from the start on the high-DPI monitor)

Loaded high-DPI on high-DPI:

image

Loaded low-DPI on high-DPI:

image

It looks like this is possible with matchMedia, example in https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio.

jonathanolson commented 1 year ago

Notably above, the text is rendered with SVG, but the bunnies are rendered with WebGL. The bunnies are blurrier on the bottom example.