Hi Max, I've finally had a chance to examine the SpherePoints+ performance issue you wrote about here:
http://moi3d.com/forum/index.php?webtag=MOI&msg=8682.16
quote:
4. Interactive scripts perfarmance problem. MoI v4 18.11 works much faster than with 13.11, but still
slower than MoI v3/4(Win) and v3.1(Mac).
You can check it with my SpherePoints+ script. http://moi.maxsm.net/item/2
After some testing to rule out draw performance I was able to determine that it's due to the script using window.setInterval() to look for updates. It seems that recent WebKit and Chrome browsers delay the .setInterval timers if there is other intensive activity like continuous movement of the mouse I guess. I'm not sure why it only happens in MoI on the Mac version, maybe only the Mac OS happens to have the support for it.
There's a discussion of it in Chrome here:
https://bugs.chromium.org/p/chromium/issues/detail?id=570845
I haven't found the checkin that added it to Webkit but a lot of times Webkit and Chrome copy stuff from each other since only a few years ago they were the same codebase.
It sounds like it might be possible to use a different web timer api "requestAnimationFrame" which might not get delayed like setInterval:
https://stackoverflow.com/a/43951402
but I did not test that.
For this script it would be better to not use a timer at all and instead update things when a UI event is fired, that should ensure no delaying and also not burn CPU cycles by continuous polling when nothing is being actually changed in the UI. I've attached a modified version of SpherePoints+ that does it like that and it seems to solve this Mac performance issue. If you have this same problem in other scripts that are also using window.setInterval then it's likely to be the same thing there. Please let me know if you have seen any other script performance regressions in v4 that do not involve setInterval.
Hope this helps! - Michael
EDIT: forgot attachment
|