-
Notifications
You must be signed in to change notification settings - Fork 9k
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
"Non-deterministic" screenshots after viewport resize #1751
Comments
It’s hacks, but you could try evaluating and awaiting a requestAnimationFrame inside the page. I’m not sure what we wait on to decide the viewport had been resized. |
So you mean after awaiting for the viewport resize I add a dummy And one last thing, browser rendering is deterministic right? If I wait long enough after rendering the same code should render identically right? (assuming code doesn't do stuff over time) |
@inakianduaga did requestAnimationFrame hack work for you? |
@dowsanjack async function setViewport(page: puppeteer.Page, viewport: { width: number; height: number }) {
const watchDog = page
.mainFrame()
.waitForFunction(`window.innerWidth === ${viewport.width} && window.innerHeight === ${viewport.height} `)
await page.setViewport(viewport)
await watchDog
} using this for changing the viewport, plus running the whole thing in a dockerized container (to prevent local macOS / CI linux differences in font rendering and what not) FROM node:8.5.0
RUN apt-get update
RUN apt-get install -y \
gconf-service \
libasound2 \
libatk1.0-0 \
libc6 \
libcairo2 \
libcups2 \
libdbus-1-3 \
libexpat1 \
libfontconfig1 \
libgcc1 \
libgconf-2-4 \
libgdk-pixbuf2.0-0 \
libglib2.0-0 \
libgtk-3-0 \
libnspr4 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libstdc++6 \
libx11-6 \
libx11-xcb1 \
libxcb1 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxi6 \
libxrandr2 \
libxrender1 \
libxss1 \
libxtst6 \
ca-certificates \
fonts-liberation \
libappindicator1 \
libnss3 \
lsb-release \
xdg-utils \
wget |
@JoelEinbinder Could this be the same issue I'm seeing in #1910? If so, wouldn't it then make sense to have the |
I had the same problem. In my case, await page.setViewport({
width,
height,
})
await page.evaluate(() => {
return new Promise((resolve) => {
window.requestAnimationFrame(resolve)
})
})
await page.screenshot({
path: filePath,
fullPage: true,
})
|
We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days. |
We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it! |
Steps to reproduce
Tell us about your environment:
What steps will reproduce the problem?
What is the expected result?
Snapshots shouldn't change between runs since the html / JS is fixed (so test should pass)
What happens instead?
Tests sometime fail, due to snapshots differing slightly for some viewports, assumption is that the
screenshot
call comes before chrome has had time to fully render the content.Is there any hook to find out that chrome has finished rendering that I could add after the viewport resize and before the snapshot?
The text was updated successfully, but these errors were encountered: