-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
blurry canvas if deviceScaleFactor > 1 #2755
Comments
@iwan-uschka I don't really see any blurriness; however, I didn't quite understand what do I compare it against in your step (2). The link However, I have one advice that might help: try emulating viewport before navigating page to the url. const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({
width: 800,
height: 600,
deviceScaleFactor: 3
});
await page.goto('https://www.google.de/maps/@52.5197103,13.4068538,16.11z');
await page.waitFor(5000);
await page.screenshot({path: 'screenshot.png'});
await browser.close(); This is important because canvas is usually set up with page dpi in mind, so page queries its DPI right away. Check out this hidpi canvas write-up for details. Let me know if it helps. |
@aslushnikov Thanks a lot. It actually did help to set the viewport before loading the page, even if it's a web application and not a static page and the canvas gets loaded a few steps after opening the page. Sorry for mixing up the google maps example with the openstreetmaps example. I am using puppeteer to create app screenshots to use them within store presentations. Screenshots with different pixel ratios needs to be captured (@2x default, @3x for 5.5-Inch Retina). Doing it this way is not the right way regarding your advice because the page should be reloaded completely after switching viewports. It would take nearly twice the time capturing all views and change the viewport after it than capturing a view with all viewports and change the view after it. |
FYI if anyone else ends up here with a related issue, I was going to report that our iframes changed their rendering quality in a recent upgrade of puppeteer, but moving |
@bbugh can this be closed then? |
I think it is a bug. It was working fine for us on a previous puppeteer version (1.8.0) with As far as a solution, I think one or all of:
|
@bbugh Calling
There's no behavior change; calling
Fair enough: #4319 |
That looks great to me! We actually got caught on |
Just to be clear, if a canvas does not listen for DPI changes, that is a bug in the canvas. This can happen in the real world for example if a window is dragged between two monitors or the zoom is changed (on desktop). So while setting the viewport before the page is loaded might "fix" the problem, it is actually just avoiding a bug in the website. |
Steps to reproduce
Tell us about your environment:
What steps will reproduce the problem?
What is the expected result?
Sharp canvas.
What happens instead?
Blurry canvas.
The text was updated successfully, but these errors were encountered: