gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.28k stars 10.31k forks source link

Content is not sized correctly for the viewport #9190

Closed sarahannnicholson closed 5 years ago

sarahannnicholson commented 6 years ago

Description

I ran a Lighthouse audit on my site and on the Gatsby site. I noticed the same note appearing in the "Progressive Web App" section. Content is not oversized for the viewport. image

Steps to reproduce

  1. Go to the Gatsby website https://www.gatsbyjs.org/docs/
  2. Open the chrome dev tools
  3. Run a Lighthouse audit.
  4. Notice "Content is not sized correctly for the viewport" in the progressive web app section

Expected result

Viewport size shouldn't appear in the Lighthouse audit

Actual result

Notice "Content is not sized correctly for the viewport" in the progressive web app section

Investigation

The Lighthouse audit docs state The audit passes if window.innerWidth === window.outerWidth. docs I went into the source of the Gatbsy site in the dev tools and put a breakpoint in the layout.js on line 63 let isModal = false When i refreshed the page, my breakpoint was hit. In the console I was able to type window.innerWidth and window.outerWidth image

Moving to the HTML tab (with my breakpoint still hit), you can see that none of the page content has loaded yet. So the problem isn't my website or the Gatsby website is doing, content wise. image

pieh commented 6 years ago

@fk Any clues? I'm not really familiar with gatsbyjs.org code so not even sure where to look

fk commented 6 years ago

No clues yet, but will take a look! πŸ”

Thanks so much @sarahannnicholson for my "today I learned" πŸ™ β€” I have to admit I never ever saw "Content is not sized correctly for the viewport" anywhere yet. Apparently it's been some time since I did a Lighthouse audit on www. :-/

Also πŸ‘πŸ™ for the super detailed issue description and investigation!

fk commented 6 years ago

Ah, hold on. Clearly not able to … read … today/night anymore. :/

I ran a Lighthouse audit on my site and on the Gatsby site. I noticed the same note appearing in the "Progressive Web App" section. Content is not oversized for the viewport.

Do I understand this correctly and you are seeing the same warning for your website, too?

(I first thought "OK, it's that modal and how it renders", which doesn't make much sense if @sarahannnicholson's website doesn't contain one… πŸ€¦β€β™‚οΈπŸ€“)

sarahannnicholson commented 6 years ago

Hey @fk Im glad to have been some help!

Yes I am seeing it on my website as well as the Gatsby website. Which makes me believe its a Gatsby issue. So to test that theory I added a breakpoint in the layout.js before the content had loaded, but after window had been initialized. That way I could test and confirm that the window.innerWidth and window.outerWidth were in fact not the same, and that the issue is somewhere in Gatsby's init.

fk commented 6 years ago

Whoa that was fast @sarahannnicholson! Thanks for the clarification/validating that I can still read/process if I take a little more time. ;-)

Im glad to have been some help!

πŸ’―!

Hmmmm. (My guts) Thinking out loud β€” maybe it's something that happens in relation to reach router handling focus?

fk commented 6 years ago

Hey @sarahannnicholson β€” I tried to reproduce your findings but fail to do so. Screenshot is taken at ~1600px viewport width though:

image

Am I missing something? @pieh did you try reproducing?

Edit: Here's the Lighthouse settings I tested with:

image

pieh commented 6 years ago

I didn't check it yet - I don't really understand how/why window.innerWidth and window.outerWidth would not match :)

sarahannnicholson commented 6 years ago

@fk I ran it again to double check :/ got the same image

Audit settings

Device: Desktop Audits: All Throttling: Simulated Fast 3G, 4x CPU Slowdown Clear storage: checked

craftedsystems commented 6 years ago

Lighthouse 3.0.3 (Chrome Stable 70.0.3538.77) seems to have the following bug: When you dock the Dev Tools to the right, you get the false viewport width alert. Detaching or docking the Dev Tools to the bottom solves this for me.

Desktop or mobile does not matter because the PWA test will always test for mobile-friendy.

GuskiS commented 5 years ago

Just noticed this in my page. Weirdly that it happens only when gatsby build && gatsby serve, cause when I'm doing gatsby develop everything is fine. I also noticed that when I turn on mobile view within chrome, I can scroll x/y, however if I do manual screen resize everything is fine.

GuskiS commented 5 years ago

Ok, I solved my issue. I had body { width: 100vw; } in my css. Removing that solved the overflow/scrolling issue.

The weirdest thing is that it was only happening in gatsby production mode. In gatsby develop it wasn't an issue. :thinking:

fk commented 5 years ago

@sarahannnicholson Maybe the comments by @craftedsystems and @GuskiS could help?

GuskiS commented 5 years ago

Could this be related to

<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>

having the shrink-to-fit=no part? Here is some description of what it does - https://stackoverflow.com/questions/33767533/what-does-the-shrink-to-fit-viewport-meta-attribute-do

I have always used only these width=device-width, initial-scale=1.

gatsbot[bot] commented 5 years ago

Hiya!

This issue has gone quiet. Spooky quiet. πŸ‘»

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

Thanks for being a part of the Gatsby community! πŸ’ͺπŸ’œ

gatsbot[bot] commented 5 years ago

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

Thanks again for being part of the Gatsby community!

piotrekwitkowski commented 5 years ago

This is solved in Chrome 78 (currently in Beta)! https://github.com/GoogleChrome/lighthouse/issues/5558

fk commented 5 years ago

Whoa! Thanks @piotrekwitkowski! πŸ™ @sarahannnicholson, are you still with us? ;-)

sarahannnicholson commented 5 years ago

Hey @fk, I'm still here! :P

Thanks @piotrekwitkowski! Looks like it wasn't Gatsby after all! Thanks everyone for the investigations :)

fk commented 5 years ago

Hey @sarahannnicholson! πŸŽ‰ Good to see you around! πŸ€—

It took us a looong time, but thanks to @piotrekwitkowski πŸ™, the mystery is solved! πŸ˜‰