使用GPU在画布上绘制时性能受到影响

时间:2021-09-30 16:54:09

Using Chrome 12 my game is drawing smoothly. But Chrome 14, which appears to use the GPU for drawing, has an enormous negative impact on the performance of my game.

使用Chrome 12,我的游戏顺利进行。但Chrome 14似乎使用GPU进行绘图,对我的游戏性能产生了巨大的负面影响。

I made a jsFiddle to see when exactly it happens and this simple code is already running into problems: http://jsfiddle.net/eGjak/48/.

我做了一个jsFiddle,看看到底发生了什么,这个简单的代码已经遇到了问题:http://jsfiddle.net/eGjak/48/。

  • On Chrome 12, the FPS is 62, which is even more than my screen frequency.
  • 在Chrome 12上,FPS为62,甚至超过了我的屏幕频率。
  • On Chrome 14, the FPS is ~25.
  • 在Chrome 14上,FPS约为25。

25 FPS is quite acceptable, but in my game I'm drawing even more and it is running down to ~8 FPS there, which definitely is not acceptable. I've never had any performance problems but the GPU update for canvas is a bottleneck for me.

25 FPS是完全可以接受的,但是在我的游戏中我画的更多,并且它在那里运行到~8 FPS,这绝对是不可接受的。我从来没有遇到任何性能问题但是画布的GPU更新对我来说是一个瓶颈。

  • Why is some simple drawing on canvas so much slower using the GPU?
  • 为什么使用GPU时画布上的一些简单绘图会慢得多?
  • Can I disable Chrome from using the GPU through JavaScript? (Or is there another solution for this?)
  • 我可以禁用Chrome通过JavaScript使用GPU吗? (或者还有其他解决方案吗?)

Edit: Filed a bug at http://code.google.com/p/chromium/issues/detail?id=89540

编辑:在http://code.google.com/p/chromium/issues/detail?id=89540上提交了一个错误

2 个解决方案

#1


2  

I'm getting 60fps in Chrome 14 just fine.

我在Chrome 14中获得60fps就好了。

I can almost guarantee this is due to hardware acceleration being on by default in Chrome 14 and not in 12. Specifically the waiting for vertical sync, which didn't happen before.

我几乎可以保证这是由于硬件加速在默认情况下在Chrome 14中打开而不在12中。特别是等待垂直同步,这在之前没有发生过。

In Chrome 14 and beyond GPU accel (of Canvas) is no longer a flag you can turn on and off - it is a default. Sorry.

在Chrome 14及更高版本GPU中,accel(Canvas)不再是一个可以打开和关闭的标志 - 这是默认设置。抱歉。

You can however still disable GPU Vsync in Chrome 14 if you go to chrome://flags/. This will almost certainly give you more frames.

但是,如果你转到chrome:// flags /,你仍然可以在Chrome 14中禁用GPU Vsync。这几乎肯定会给你更多的帧。

However it is not something you can make your users do.

但是,这不是您可以让用户做的事情。

#2


0  

I just installed Chromium 14.0.831.0 build 93677 (as opposed to 14.0.917.0 build 91952) and things were fine again. It's now just under 60 FPS instead of ~62, but oh well...

我刚刚安装了Chromium 14.0.831.0 build 93677(而不是14.0.917.0 build 91952),事情又好了。它现在只有不到60 FPS而不是〜62,但是很好......

I guess the main point is that things come and go too fast with nightly builds. My game is running fine again (and since today the latest nightly build uses the new WebSocket protocol which is a great as well).

我想主要的一点是,随着夜间构建,事情变得过快。我的游戏再次正常运行(从今天开始,最新的每晚构建使用新的WebSocket协议,这也很棒)。

I hope I'm not getting too fired up of this as it might just slow down next week again, but I'll see.

我希望我不会对此感到太过激动,因为它可能会在下周再次减速,但我会看到。

#1


2  

I'm getting 60fps in Chrome 14 just fine.

我在Chrome 14中获得60fps就好了。

I can almost guarantee this is due to hardware acceleration being on by default in Chrome 14 and not in 12. Specifically the waiting for vertical sync, which didn't happen before.

我几乎可以保证这是由于硬件加速在默认情况下在Chrome 14中打开而不在12中。特别是等待垂直同步,这在之前没有发生过。

In Chrome 14 and beyond GPU accel (of Canvas) is no longer a flag you can turn on and off - it is a default. Sorry.

在Chrome 14及更高版本GPU中,accel(Canvas)不再是一个可以打开和关闭的标志 - 这是默认设置。抱歉。

You can however still disable GPU Vsync in Chrome 14 if you go to chrome://flags/. This will almost certainly give you more frames.

但是,如果你转到chrome:// flags /,你仍然可以在Chrome 14中禁用GPU Vsync。这几乎肯定会给你更多的帧。

However it is not something you can make your users do.

但是,这不是您可以让用户做的事情。

#2


0  

I just installed Chromium 14.0.831.0 build 93677 (as opposed to 14.0.917.0 build 91952) and things were fine again. It's now just under 60 FPS instead of ~62, but oh well...

我刚刚安装了Chromium 14.0.831.0 build 93677(而不是14.0.917.0 build 91952),事情又好了。它现在只有不到60 FPS而不是〜62,但是很好......

I guess the main point is that things come and go too fast with nightly builds. My game is running fine again (and since today the latest nightly build uses the new WebSocket protocol which is a great as well).

我想主要的一点是,随着夜间构建,事情变得过快。我的游戏再次正常运行(从今天开始,最新的每晚构建使用新的WebSocket协议,这也很棒)。

I hope I'm not getting too fired up of this as it might just slow down next week again, but I'll see.

我希望我不会对此感到太过激动,因为它可能会在下周再次减速,但我会看到。