question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No way to determine native DPR of device

See original GitHub issue

The following code doesn’t allow someone to use the device’s native DPR by setting await page.setViewport({deviceScaleFactor: 0,...}):

https://github.com/GoogleChrome/puppeteer/blob/master/lib/Page.js#L729 https://github.com/GoogleChrome/puppeteer/blob/294f33b75c5a7c87d447816218438f56c2d56f0e/lib/EmulationManager.js

That makes it impossible to determine the real DPR of the device:

await page.evaluate('window.devicePixelRatio'); 

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ebidelcommented, Apr 12, 2018

You want to know this information for taking high quality screenshots.

For my particular case, I’m running an app in both mac and linux. So I want to use the correct DPR per the device without hard coding numbers.

0reactions
aslushnikovcommented, Apr 26, 2018

Let’s introduce a viewport option to the launcher as a part of #1183. One of the values could be null to disable viewport override altogether.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Window.devicePixelRatio - Web APIs | MDN
You can use window. matchMedia() to check if the value of devicePixelRatio changes (which can happen, for example, if the user drags the...
Read more >
in iPhone App How to detect the screen resolution of the device
Now if you want to get the pixel width & height of the iOS device screen you just need to do one simple...
Read more >
Chrome Developer Tools/Device mode doesn't emulate ...
(3) Open the Device mode (mobile/tablet 2nd icon in upper left corner of the Chrome Developer Tools panel/window). (4) In mobile emulator ...
Read more >
rexxars/use-device-pixel-ratio: React hook for getting ... - GitHub
useDevicePixelRatio() is a React hook (and utility) that will tell you what the current device has as its Device Pixel Ratio (DPR).
Read more >
device-pixel-ratio - npm search
A command line tool to measure responsive image efficiency across viewport sizes and device pixel ratios. responsive-images · img · zachleat. published 1.0.0...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found