vasturiano / three-globe

WebGL Globe Data Visualization as a ThreeJS reusable 3D object
https://vasturiano.github.io/three-globe/example/links/
MIT License
1.19k stars 145 forks source link

Bug: destructor cleanup #75

Open Andrewknackstedt opened 1 year ago

Andrewknackstedt commented 1 year ago

Follow-up of #72 and #74 Already seeing much better cleanup and far less CPU is used after the destructor is called, getting much closer to being done :)

There is still some FrameTicker straggler that isn't being cleaned up, though I'm not 100% sure why or where it's coming from. It looks like we need this._isRunning set to false to fully kill FrameTicker. It's a bit surprising that FrameTicker's destructor wouldn't take care of that.

This animation isn't being stopped: https://github.com/vasturiano/three-globe/blob/75fb07404926b207d136628ca2b0c16723423eb5/src/globe-kapsule.js#L363

This animation seems to not be cleaned up? https://github.com/vasturiano/globe.gl/blob/805f2c018c89c2bcb3a9a4951b686960e0c0b213/src/globe.js#L249

vasturiano commented 1 year ago

It looks like we need this._isRunning set to false to fully kill FrameTicker. It's a bit surprising that FrameTicker's destructor wouldn't take care of that.

Maybe it's worth taking that up to the frame-ticker repo?

This animation isn't being stopped: three-globe/src/globe-kapsule.js

It is on the recent version: https://github.com/vasturiano/three-globe/blob/20afa71f3a1a972984067d5febd87fbb20cbc7e9/src/globe-kapsule.js#L294

This animation seems to not be cleaned up? https://github.com/vasturiano/globe.gl/blob/805f2c018c89c2bcb3a9a4951b686960e0c0b213/src/globe.js#L249

Should be, as part of pauseAnimation: https://github.com/vasturiano/globe.gl/blob/805f2c018c89c2bcb3a9a4951b686960e0c0b213/src/globe.js#L304

Andrewknackstedt commented 1 year ago

I believe I fixed the logic and opened a PR on FrameTicker https://github.com/knackstedt/frame-ticker

I used the latest version and was still seeing some loops around those areas, but I might have been following a red herring due to FrameTicker not ensuring the animation got stopped