question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Next/future/image safari border fix make all lazy loaded images bordered

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 19.6.0: Mon Apr 18 21:50:40 PDT 2022; root:xnu-6153.141.62~1/RELEASE_X86_64
Binaries:
  Node: 16.15.0
  npm: 8.3.0
  Yarn: 3.2.1
  pnpm: 7.1.7
Relevant packages:
  next: 12.3.1-canary.2
  eslint-config-next: 12.2.5
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

Safari 15.5

How are you deploying your application? (if relevant)

No response

Describe the Bug

I used next future image

<Image
    className="w-full h-auto"
    src={item.th}
    alt=""
    width={240}
    height={240}
    placeholder = "blur"
    blurDataURL ="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP88R8AAvUB+VkkrXoAAAAASUVORK5CYII="
    quality={100}
  />

I used hack to fix border on Safari 15+ when images which use loading=“lazy” has white border while loading.

@media not all and (min-resolution:.001dpcm) {
  img[loading="lazy"] {
    clip-path: inset(0.5px);
  }
}

Now I see in Safari 15 and ALL images which not have priority have 0.5px transparent (white if light background and black if dark) aka border.

image

Expected Behavior

Expected behavior - css hack needed to be applied only for images in loading state. Without this css styles lazy loaded images shown correctly image

Link to reproduction

https://codesandbox.io/p/github/7iomka/effector-react-form-flow/draft/sweet-goldberg?file=%2Fsrc%2Fapp%2Fui-provider%2Fapp-global-styles.tsx&selection=[{"endColumn"%3A11%2C"endLineNumber"%3A14%2C"startColumn"%3A11%2C"startLineNumber"%3A14}]

To Reproduce

Open Demo in Safari You can see white border on images loaded in thumbs carousel image

You can disable fix from styles (src/app/ui-provider/app-global-styles.tsx) to show that this fix caused issue.

Of course, I can use priority, but, if my images is located below the fold, this is not a solution, and it can’t be applied to all images.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alextescommented, Nov 12, 2022

Built a code sandbox with the proposed workaround, still getting the borders in Safari.

Did anyone else find a workaround or able to spot what I did wrong?

https://codesandbox.io/p/sandbox/pensive-babbage-mfmhn2?file=%2Fpages%2Findex.tsx

https://user-images.githubusercontent.com/2011351/201447149-ab091cbc-aae7-4b79-8ea1-9f156eef5228.mov

0reactions
nandorojocommented, Dec 16, 2022

I see the same border issue on Chrome for iOS for what it’s worth.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to remove white border on lazy loaded images in Safari
It appears to be the same thing that happens if an image fails to load, and can be replicated by disabling images using...
Read more >
Images with loading="lazy" have uncontrollable gray border ...
You need to log in before you can comment on or make changes to this bug. ... This border disappears once the image...
Read more >
Preventing Content Reflow From Lazy-Loaded Images
It prevents the browser from loading images until those images are in (or nearly in) the browser's viewport. There are a plethora of...
Read more >
Native lazy-loading of images with zero Javascript
Cost reduction - A lazy loaded image may never need to load because the user never reaches the image's position on the page....
Read more >
Images sometimes don't load in Safari [#3279316] | Drupal.org
Problem/Motivation We are experiencing an issue where images don't always appear in safari (almost 75% of the time they're missing).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found