-
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
docs(api): document appMode #1954
Conversation
I had to find out about this the hard way. It would be useful to be able to not set a default viewport size and still be able to have |
I think one of the issues we see is that that users have to remember to override the viewport in the first place. It's a source of confusion and easy to forget. It would also be nice to not have to make an API call for every page. |
@ebidel I think this would always be the case: If we don't override the viewport by default, it's size will be unpredictable. |
@aslushnikov For me, the appMode is confusing because it does too many things: And then In summary, setting
In my case, I just want the viewport (in headful) to always be set to the resolution that I expect. @ebidel In your example you have:
Which doesn't agree with the docs you wrote (correct version):
|
@alixaxel that's true. I'm not sure I understand if the |
@aslushnikov I don't know what's the behavior/idea of If |
Guess I'm unclear why we set a viewport. Chrome seems to be fine without setting one viewport: const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({appMode: true});
const page = await browser.newPage();
await page.goto('https://www.facebook.com/');
await page.screenshot({path: 'screenshot.png'});
await browser.close();
})(); That produces a screenshot where the page/viewport take up the full window dimensions. That feels like the right behavior over pptr setting one for users. It's also more like the rest of the API (less magic, you opt-in to things). Does chrome not launch with the same dimensions across platforms? |
It doesn't launch with the same dimensions across headful/headless. I can't imagine its the same across platform. |
Can we make a decision on this? TLDR: we need some way to prevent pptr from setting a default viewport. It would be nice if that was a flag and not an explicit API call. The default 800x600 is a source of gotcha/bugs for us. BTW, does |
I'm not sure I follow this. Would it be better if there are random numbers instead?
It doesn't. Closing this in favor of #1910 |
No, it would be better if pptr didn't set a default viewport at all for users. Seems to work just fine. People run into issues with responsiveness: e.g. site not matching selectors, page layout being different for mobile, etc. It's usually b/c they don't realize we're setting a small viewport at launch. |
We discussed this more offline. Many sites are clipped when screenshotted by puppeteer in a user's first hello world script. There's a proposal for changing the default viewport width from it's current 800x600. A fresh profile headful Chrome launches at 1200px wide, so we think that's a good new width. (height TBD, not as big a deal) This will require a major version bump, so it should go onto a list of things to change at the 2.0. :) |
I've found
appMode
useful when using pptr with lighthouse.Background:
Both Lighthouse and Puppeteer emulate a viewport when you run the tools, but they use different sizes. This causes lighthouse's perf audits to fail because screenshots end up changing sizes during an audit. During an audit session, Lighthouse reloads the page several times.
example - inject a stylesheet into the page before each lighthouse runs.