英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论