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

Images don't appear the first time the user loads a page on gatsbyjs.org #9174

Closed
calcsam opened this issue Oct 17, 2018 · 10 comments
Closed
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@calcsam
Copy link
Contributor

calcsam commented Oct 17, 2018

Description

Images don't appear the first time a site is loaded on gatsbyjs.org.

Seems like an offline-plugin issue -- perhaps @davidbailey00 could take a look?

Steps to reproduce

Visit a post you haven't visited before, that has images, such as https://www.gatsbyjs.org/blog/2018-10-04-journey-to-the-content-mesh/, that has images.

Expected result

image

Actual result

image

Environment

iPhone XS, Chrome
2015 Macbook Pro, Chrome incognito

@calcsam calcsam added the type: bug An issue or pull request relating to a bug in Gatsby label Oct 17, 2018
@calcsam calcsam changed the title Images don't appear the first time a site is loaded on gatsbyjs.org Images don't appear the first time the user loads a page on gatsbyjs.org Oct 17, 2018
@KyleAMathews
Copy link
Contributor

It happens in an incognito window so it's not an offline problem.

@gpetrioli
Copy link

Additional info:

The problem manifests in https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-remark-images/src/index.js#L181-L183.
When the image is not cached this somehow breaks and renders as

  style="...;background-image: url('data:image/png;background-size:cover;display:block;}"

So inside the background-image the url is abruptly/wrongfully ended and it results in wrong css where the background-size and display:block are not getting applied causing the container to have 0 dimensions and thus the nested image does not appear.

So the actual problem seems to be with what gets returned by fluidResult.base64 which is the result of fluid from gatsby-plugin-sharp plugin.

@pieh
Copy link
Contributor

pieh commented Oct 17, 2018

This is more nuanced - building locally or on netlify we don't get this issue - it only show up when we build on our custom build runner

@gpetrioli
Copy link

gpetrioli commented Oct 17, 2018

More info: This is the same as [gatsby-remark-images] new images 404 or end up being 0x0 pixels and is explained in detail in Rewrite parseStyle parser to correctly transform parenthesis and quotes.

Locally (the developer build) works correctly but the live site (gatsbyjs.org) still has the problem.

Not sure if the live version is built with the latest versions, or if a different version of the hast-to-hyperscript is used.

A quick fix/hack (temporary as it only works around the actual problem) would be to move the background-position: ... as the last property in the code so that when it breaks it will not affect the following properties (namely display:block and background-size:cover)

@pieh
Copy link
Contributor

pieh commented Oct 17, 2018

That's interesting and really looks like the same issue, but www uses rehype-react@^3.0.3 which should contain hast-to-hyperscript version with the fix ( rehypejs/rehype-react@106ffb5 ). Maybe there is more going on there and there is some dependency weirdness happening that make build runner use older version?

@gpetrioli
Copy link

Not very well versed in build systems and yarn, but i see in the root yarn.lock https://github.com/gatsbyjs/gatsby/blob/master/yarn.lock#L9238-L9249) that it references 3.1.0 version of hast-to-hyperscript.
Could that be an issue ?

@pieh
Copy link
Contributor

pieh commented Oct 18, 2018

@gpetrioli Yeah, seems like transitive dependency of gatsby-transformer-remark there, so my bad here - let's hope #9219 will fix it

@pieh
Copy link
Contributor

pieh commented Oct 18, 2018

It seems like it was fixed with this upgrade. Thanks @gpetrioli for providing context for that! I owe you!

I'm still baffled why it wasn't manifesting locally for me

@danielhusar
Copy link
Contributor

Im having the same issue, has the fix been released?

@calcsam
Copy link
Contributor Author

calcsam commented Nov 29, 2018

Yep! Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

5 participants