3Dmol.js icon indicating copy to clipboard operation
3Dmol.js copied to clipboard

use less CPU for animations

Open mhellstr opened this issue 1 year ago • 3 comments

This page https://3dmol.org/doc/index.html uses 400% CPU on my machine which seems a bit excessive. The same happens for any animation, which means I'm not comfortable putting them on my website.

It would be nice if there was a way to use less CPU for animations.

mhellstr avatar May 03 '24 06:05 mhellstr

Are you sure the issue is with that page? It has close to zero cpu utilization on my laptop. What browser and operating system are you using?

dkoes avatar May 03 '24 12:05 dkoes

On Linux using chrome or brave the CPU utilization is 400% (on an 8-core machine), with Firefox it is 100%.

On Windows the CPU utilization is much smaller.

It really is that page (or any of my own custom 3dmol animations), since switching away from that tab drops the CPU usage to 0.

mhellstr avatar May 07 '24 06:05 mhellstr

The render update is consistently taking a millisecond or less while the interval is 50ms, so I am at a loss as to why there is high cpu overhead. Very open to any suggestions.

dkoes avatar May 07 '24 16:05 dkoes

Is this still an issue? I'm seeing 10% CPU utilization on Chrome/Linux now (less than firefox and not much more than it is using while I am typing this).

dkoes avatar Jul 31 '24 20:07 dkoes

I upgraded to Chromium: 127.0.6533.88 but the high CPU usage is still there on my Linux machine. (There is no high CPU usage for other types of animations like youtube or animated gifs).

If it is not reproducible for you I have no idea what the problem is.

mhellstr avatar Aug 01 '24 06:08 mhellstr

Did you upgrade 3dmol to the latest version as well?

dkoes avatar Aug 01 '24 11:08 dkoes

Also, do you see the issue with other webgl animations like https://get.webgl.org/ ?

dkoes avatar Aug 01 '24 11:08 dkoes

I just viewed the animation in the web docs with a clean cache, but the problem persists. On get.webgl.org the CPU usage is surprisingly high (50%), but not as bad as the 3dmol page (400-500%).

mhellstr avatar Aug 02 '24 07:08 mhellstr

The get.webgl.org animation is insanely simple. If it is causing 50% cpu utilization then there's definitely something unique to your setup (I assume you don't have 50% CPU with a static webpage), independent of 3dmol, that is causing the issue. Do you have any extra extensions installed? Running dev tools at the same time? Perhaps try with a clean profile.

dkoes avatar Aug 02 '24 16:08 dkoes

I have similar issue with Chrome on a Manjaro Linux with 3dmol. It is a laptop with amd 4800u. It becomes irresponsible when opening https://3dmol.csb.pitt.edu/ both using xwayland or wayland. However, I see the slowness only with Chrome based browsers, Firefox is completely fine.

I have another laptop with Intel/Nvida hardware with CachyOS Linux. It is fine with both xwayland and wayland, it is fine with both Chrome and Firefox.

lithces avatar Aug 04 '24 10:08 lithces

I tried some hacks, enabling Vulkan in Chrome on Wayland, the rendering of 3dmol is fine now.

lithces avatar Aug 04 '24 11:08 lithces

This is a good point, if you go to chrome://gpu/ and it says hardware acceleration isn't enabled, that would explain the high CPU usage.

dkoes avatar Aug 04 '24 14:08 dkoes

Thanks for the info - indeed hardware acceleration wasn't enabled. Enabling it decreases CPU usage from 400% down to 120%, which is still significant but much better.

Since this appears to be some local problem on my machine, I'll close the issue.

mhellstr avatar Aug 05 '24 07:08 mhellstr