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

Conversion into multi images/PPTX takes only the first slide if using Chromium >= v89 #325

Closed
yhatt opened this issue Feb 14, 2021 · 1 comment · Fixed by #329
Closed
Labels
bug Something isn't working

Comments

@yhatt
Copy link
Member

yhatt commented Feb 14, 2021

Originally reported in marp-team/marp-vscode#202.

Marp CLI has updated Puppeteer to v7.x in #319. It has a breaking change for page.screenshot(). Marp CLI uses this for taking a image of slides while multi-image conversion and PPTX conversion.

⚠ BREAKING CHANGES

  • page.screenshot makes a screenshot with the clip dimensions, not cutting it by the ViewPort size.
  • chromium: - page.screenshot cuts screenshot content by the ViewPort size, not ViewPort position.

-- https://github.com/puppeteer/puppeteer/releases/tag/v7.0.0

We have taken screenshots by scrolling contents with fixed viewport position, but this change means that way is no longer working in the latest Chromium.

marp-cli/src/converter.ts

Lines 260 to 278 in 1ffcdf5

await page.setViewport(tpl.rendered.size)
await page.goto(uri, { waitUntil: ['domcontentloaded', 'networkidle0'] })
await page.emulateMediaType('print')
const screenshot = async (pageNumber?: number) => {
await page.evaluate(
`window.scrollTo(0,${
((pageNumber || 1) - 1) * tpl.rendered.size.height
})`
)
if (opts.type === ConvertType.jpeg)
return (await page.screenshot({
quality: opts.quality,
type: 'jpeg',
})) as Buffer
return (await page.screenshot({ type: 'png' })) as Buffer
}

If trying to take screenshots through the latest Google Chrome Canary (>= v90), every slide pages will have only the first slide.

w:256 imagew:256 image

-- marp-team/marp-vscode#202 (reported by @jehunseo)

@yhatt yhatt added the bug Something isn't working label Feb 14, 2021
@yhatt yhatt changed the title Conversion into multi images/PPTX takes only the first slide if using Chromium >= v90 Conversion into multi images/PPTX takes only the first slide if using Chromium >= v89 Mar 13, 2021
@yhatt
Copy link
Member Author

yhatt commented Mar 13, 2021

I've confirmed this bug in Chromium r843427, the current stable Chrome 89 (for Puppeteer >= v6.0.0). It can fix by simply following Puppeteer's breaking change: Remove window.scrollTo() and add clip option to Page.screenshot().

However, screenshots may break in a previous Chrome 88 (Chromium r818858 / Puppeteer v5.5.0) if took screenshots with clip option. The outdated version of Chrome might be used by some users (e.g. Chrome Enterprise).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant