dataarts / dat.gui

Lightweight controller library for JavaScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

listen() causes excessive animation requests

Ristovski opened this issue · comments

Adding .listen() to any controller calls updateDisplays GUI.js#L865 which in turn calls requestAnimationFrame GUI.js#L1400 at what seems to be the polling interval.

This means that adding .listen() to any controller will constantly poll for any value change and constantly call requestAnimationFrame, causing repaints which causes high CPU usage, all for nothing - even when the value has not changed.

It would be nice if there was either a way for requestAnimationFrame to get called only on a value change or to be able to throttle the polling interval for .listen() (maybe something like listen(interval))

DevTools performance dump with a single Controller listener:
image

I'm I having the same behavior and the main issue is even after I call gui.destroy() these animation frames are still being called.