浏览器重绘在高分辨率下滞后数帧。

huangapple go评论70阅读模式
英文:

Browser repainting is several frames behind on high resolution

问题

I'm building a website with an infinite grid. You can move the grid by holding right-click and moving the mouse.

How it works: the grid has a position: absolute and I set the top and left CSS properties accordingly. For the background lines, I use a background-position property. I'm using requestAnimationFrom on the mouseMove event.

My problem: it works smoothly at 1080p, but the movement lags behind at 1440p. It's not an FPS problem (despite having a lower FPS than at 1080p), it's just that if I move my mouse, the grid will move 0.5s behind. Does anyone have an idea how to fix that?

Here's an example of the grid: 浏览器重绘在高分辨率下滞后数帧。

If you guys want to see it for yourself, here's a sample: https://luna-park.app/editor (Just hold right-click and move the mouse quickly)

I thought it was due to my 244Hz screen: I added a throttle to 60FPS, but no change.

I tried the CSS properties will-change and transform: translateZ(0) with no luck...

I don't think it's due to my hardware:

  • I have a Ryzen 9 7945HX (that can go up to 5.4GHz)
  • I have an RTX 4080 (laptop but still)
英文:

I'm building a website with an infinite grid. You can move the grid by holding right click and moving the mouse.

How it works: the grid has a position: absolute and I set the top and left css properties accordingly. For the background lines, I use a background-position property. I'm using requestAnimationFrom on the mouseMove event.

My problem: it works smoothly at 1080p, but the movement lag behind at 1440p. It's not a FPS problem (depite that I have a lower FPS than at 1080p), it's just that if I move my mouse, the grid will move 0.5s behind. Does anyone have an idea how to fix that?

Here's and example of the grid:
浏览器重绘在高分辨率下滞后数帧。

If you guys want to see it for yourself, here's a sample: https://luna-park.app/editor (Just hold right click and move the mouse quickely)

I though it was due to my 244Hz screen: I added a throttle to 60FPS, but no change.

I tried the CSS properties will-change and transform: translateZ(0) with no luck...

I don't think it's due to my hardware:

  • I have a Ryzen 9 7945HX (that can go up to 5.4Ghz)
  • I have a RTX4080 (laptop but still)

答案1

得分: 1

找到了!实际上,这完全是因为我的网格背景,它使用了带有许多线性渐变函数的背景图像。

这可能相当不优化,我将用画布替换它。

英文:

FOUND IT! It was actually all due to my grid background wich used a background-image with a lot of linear-gradient functions.

This must be pretty unoptimized, I'll replace it with a canvas.

huangapple
  • 本文由 发表于 2023年5月24日 22:18:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76324543.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定