Skip to content

fix: compute pixel ratio based on image size in case of oopif - #1332

Open
shadowusr wants to merge 1 commit into
testplane@8from
users/shadowusr/users/shadowusr/INFRADUTY-30514.fix-v3-t8
Open

shadowusr wants to merge 1 commit into
testplane@8from
users/shadowusr/users/shadowusr/INFRADUTY-30514.fix-v3-t8

Conversation

@shadowusr

Copy link
Copy Markdown
Member

Backport to v8 of this PR: #1331

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-17T23:35:59.930597Z 07e460f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 07e460f461

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return;
}

const pixelRatio = imageSize.width / page.viewportSizeInCss.width;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Match full-page images against document dimensions

When pixel-ratio validation runs with screenshotMode: "fullpage" (or auto detects a full-page bitmap), capturedImage.uncroppedSize contains the entire document because Camera.captureViewportImage records it before cropping. Dividing that width by the CSS viewport width therefore interprets document extent as DPR; depending on the document aspect ratio, this either throws at the following check or reparses the page with a grossly inflated ratio, breaking assertView for this supported configuration. The calculation must use dimensions corresponding to the captured image or retain whether the source bitmap was full-page.

Useful? React with 👍 / 👎.

Comment on lines +73 to +75
const pixelRatio = imageSize.width / page.viewportSizeInCss.width;
if (Math.abs(imageSize.height - page.viewportSizeInCss.height * pixelRatio) > 1) {
throw new Error("Screenshot dimensions do not match the viewport at a consistent pixel ratio");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Account for independent fractional-DPR rounding

When the actual screenshot DPR is fractional and differs from the prepared estimate, bitmap width and height are rounded independently, so deriving an exact ratio from width and allowing only one pixel of height error rejects valid images. For example, the repository's Rect.scale rounding maps a 101×201 CSS viewport at DPR 2.625 to 266×528; this code infers 266 / 101 and predicts a height of about 529.37, causing the valid screenshot to throw instead of triggering re-preparation. Compare compatible DPR intervals from both axes or otherwise include the maximum rounding error induced by the viewport aspect ratio.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant