简体   繁体   English

Gatsby Image Chrome 在 Windows 10 上闪烁

[英]Gatsby Image Chrome flicker on Windows 10

I have a React Gatsby web app and I have a component that renders answer cards with an image on each card.我有一个 React Gatsby web 应用程序,我有一个组件,可以在每张卡片上呈现带有图像的答题卡。 I know there is a known issue with windows 10 and chrome which is fixed by disabling hardware acceleration, but my site is the only one that I have such bad flickering.我知道 windows 10 和 chrome 存在一个已知问题,该问题通过禁用硬件加速来修复,但我的网站是唯一一个闪烁如此糟糕的网站。 I have tried to refactor everything to have the best performance but the issue persists.我试图重构一切以获得最佳性能,但问题仍然存在。

在此处输入图像描述

I know that this Google Chrome Flicker Unable to Find Cause solves the issue, but users will not do this since even for me this is the only site that this happens.我知道这个Google Chrome Flicker Unable to Find Cause解决了这个问题,但用户不会这样做,因为即使对我来说,这也是唯一发生这种情况的网站。

My components look something like this.我的组件看起来像这样。

<div className="flex flex-wrap justify-center py-10 px-8">
  {answers.map((e) => (
    <Field key={e.id} type="radio" name={id} value={e.answerId}>
      {() => {
        return (
          <div
            onClick={onClick}
            className="flex flex-col justify-around w-32 h-44 2k:w-48 2k:h-72 shadow-3xl rounded-md mx-2 my-3 cursor-pointer transform transition-transform"
          >
            <div className="flex-1" />
            <div className="inline-block px-2 m-3">
              <img src="https://w7.pngwing.com/pngs/247/929/png-transparent-potato-food-anime-potato-food-manga-cartoon.png" />
            </div>
          </div>
         );
      }}
    </Field>
  ))}
</div>

I have tried almost everything.我几乎尝试了一切。 Removing flex does not fix the issue.删除 flex 并不能解决问题。 If I remove the image the issue is fixed.如果我删除图像,问题就解决了。 Any help appreciated.任何帮助表示赞赏。

Found it.找到了。 Although in general the flickering issue with Chrome + Windows is fixed, it seems that there are cases where hardware acceleration is still struggling.虽然 Chrome + Windows 的闪烁问题总体上已得到修复,但似乎有些情况下硬件加速仍在苦苦挣扎。

In my case I had a div element with filter grayscale CSS and both box-shadow applied (for the card unselected state above).在我的例子中,我有一个带有过滤器灰度 CSS 的 div 元素,并应用了两个盒子阴影(对于上面未选择的卡 state)。 Probably chrome renderer had issues applying the filter to the box-shadow element so that caused the flickering.可能 chrome 渲染器在将过滤器应用于 box-shadow 元素时出现问题,从而导致闪烁。 I moved the filter to the inside image element (which makes more sense either way) and the issue was fixed.我将过滤器移动到内部图像元素(无论哪种方式都更有意义),问题得到解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM