Skip to content
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

core(full-page-screenshot): use dpr 1 #11688

Merged
merged 7 commits into from
Nov 24, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions lighthouse-core/gather/gatherers/full-page-screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class FullPageScreenshot extends Gatherer {
async _takeScreenshot(passContext, maxScreenshotHeight) {
const driver = passContext.driver;
const metrics = await driver.sendCommand('Page.getLayoutMetrics');
const deviceScaleFactor = await driver.evaluateAsync('window.devicePixelRatio');

// Width should match emulated width, without considering content overhang.
// Both layoutViewport and visualViewport capture this. visualViewport accounts
Expand All @@ -45,13 +44,9 @@ class FullPageScreenshot extends Gatherer {
await driver.sendCommand('Emulation.setDeviceMetricsOverride', {
mobile: passContext.baseArtifacts.TestedAsMobileDevice,
height,
screenHeight: height,
width,
screenWidth: width,
deviceScaleFactor,
deviceScaleFactor: 1,
scale: 1,
positionX: 0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing all of this is necessary? IIRC you suggested I add all the parameters in the original PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i was being overly cautious back then. i looked and neither CDT nor PPTR uses these props.
i tested this heavily after these changes and feel good that they aren't important.

positionY: 0,
screenOrientation: {angle: 0, type: 'portraitPrimary'},
});

Expand All @@ -77,9 +72,7 @@ class FullPageScreenshot extends Gatherer {
* @return {Promise<LH.Artifacts.FullPageScreenshot | null>}
*/
async afterPass_(passContext) {
const deviceScaleFactor = await passContext.driver.evaluateAsync('window.devicePixelRatio');
const maxScreenshotHeight = Math.floor(MAX_SCREENSHOT_HEIGHT / deviceScaleFactor);
let screenshot = await this._takeScreenshot(passContext, maxScreenshotHeight);
let screenshot = await this._takeScreenshot(passContext, MAX_SCREENSHOT_HEIGHT);

if (screenshot.data.length > MAX_DATA_URL_SIZE) {
// Hitting the data URL size limit is rare, it only happens for pages on tall
Expand Down