New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: do not cache devicePixelRatio
#3844
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Is there a unit test we could write for this?
From Slack @lsh
Should we add a listener to |
I think that would be valuable, but do we have to worry about how that interacts with react? |
Are you concerned about the global variable or which part? Vega already has a bunch of globals so I don't see any additional concerns. I'd focus on what's best for Vega for now and then worry about compatibility with React. |
You could also listen to I think this solution would also cover cases where the browser window is dragged from a low-dpi display to a hi-dpi display. |
Co-authored-by: Dominik Moritz <domoritz@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs docs and ts typings but otherwise looks good.
Currently we cache the
devicePixelRatio
on the creation of the renderer and never check to update it again. The problem with this behavior is that zooming in or out of a page will change thedevicePixelRatio
(which can be observed viawindow.onresize
). In turn, a render will be blurry on zoom. This PR makes us recalculate thedevicePixelRatio
on resize, which is negligibly expensive.