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(screenshots): fix getParsedImage of null #4189

Merged
merged 1 commit into from
Jan 9, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 7 additions & 3 deletions lighthouse-core/audits/screenshot-thumbnails.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@ class ScreenshotThumbnails extends Audit {
]).then(([speedline, ttfi, ttci]) => {
const thumbnails = [];
const analyzedFrames = speedline.frames.filter(frame => !frame.isProgressInterpolated());
const maxFrameTime =
speedline.complete ||
Copy link
Member

Choose a reason for hiding this comment

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

seems like we could just ALSO put speedline.complete in the L86 math.max(), yeah?

semantically maxFrameTime is the second half of this, but not realllly .complete.

Copy link
Member

Choose a reason for hiding this comment

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

because NaN. I see.

Math.max(...speedline.frames.map(frame => frame.getTimeStamp() - speedline.beginning));
// Find thumbnails to cover the full range of the trace (max of last visual change and time
// to interactive).
const timelineEnd = Math.max(speedline.complete, ttfi.rawValue, ttci.rawValue);
const timelineEnd = Math.max(maxFrameTime, ttfi.rawValue, ttci.rawValue);

for (let i = 1; i <= NUMBER_OF_THUMBNAILS; i++) {
const targetTimestamp = speedline.beginning + timelineEnd * i / NUMBER_OF_THUMBNAILS;
Expand All @@ -98,8 +101,9 @@ class ScreenshotThumbnails extends Audit {

const imageData = frameForTimestamp.getParsedImage();
const thumbnailImageData = ScreenshotThumbnails.scaleImageToThumbnail(imageData);
const base64Data = cachedThumbnails.get(frameForTimestamp) ||
jpeg.encode(thumbnailImageData, 90).data.toString('base64');
const base64Data =
cachedThumbnails.get(frameForTimestamp) ||
jpeg.encode(thumbnailImageData, 90).data.toString('base64');

cachedThumbnails.set(frameForTimestamp, base64Data);
thumbnails.push({
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/gather/gatherers/viewport-dimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ViewportDimensions extends Gatherer {
afterPass(options) {
const driver = options.driver;

return driver.evaluateAsync(`(${getViewportDimensions.toString()}())`)
return driver.evaluateAsync(`(${getViewportDimensions.toString()}())`, {useIsolation: true})

.then(dimensions => {
const allNumeric = Object.keys(dimensions).every(key => Number.isFinite(dimensions[key]));
Expand Down