How do you clean up three.js (or WebGL) on page refresh -


we have extensive three.js application using quite few materials, scenes, render buffers etc. refresh/restart couple of times , fail on 1 of several issues; of amounted running out of webgl resources.

i have added cleanup routine on window.onbeforeunload, calls dispose() methods on objects support it; materials, renderbuffers , geometries. i'm not convinced have caught resources; seems have been enough have been able refresh every 5 seconds half hour.

the questions are: [1] best way trigger such cleanup? window.onbeforeunload seems quite effective, maybe there reason choose alternative?

[2] best way perform such cleanup? have dispose on renderer cleaned webgl resources. (i'm not concerned javascript objects, browser seems quite capable of cleaning up.)

i have seen related questions here; eg on cleaning scenes, interested in complete cleanup. guess answer @ lower webgl level work global cleanup; might not three.js resources wouldn't able work out scope of these smaller cleanups.

generally, when web page unloaded, not page's responsibility perform kind of cleanup; resources discarded @ once. otherwise, sloppy or malicious pages cause trouble. webgl no different.

you should treat behavior you're seeing browser bug, figure out simple test page demonstrates problem, , report browser vendor(s). solve problem , reduce maintenance burden in long run.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -