PMREMGenerator: instances share context across multiple renderers
See original GitHub issueDescription of the problem
Using PMREMGenerator.fromEquirectangular
in multiple simultaneous three.js renderers causes only the last renderer to have a correctly functioning texture (at least for use as an envMap)
This happens even when each renderer has its own instance of pmremGenerator
and calls dispose
after use.
Here’s a fiddle: https://jsfiddle.net/h37k2ztv/10/
I would expect that initializing a different pmremGenerator
for each renderer should be sufficient, but I had to work around it by reinstantiating and recompiling the pmremGenerator
immediately before each time it is used (uncomment lines 63 and 64 in the fiddle to do this)
Issue #18842 reports this same issue, but perhaps even without multiple renderers. This merge request may have introduced the unexpected behavior.
Three.js version
- Dev
- r115
- …
Browser
- All of them
- Chrome
- Firefox
- Internet Explorer
OS
- All of them
- Windows
- macOS
- Linux
- Android
- iOS
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top GitHub Comments
AFAICT, when
dispose()
is properly used, there should be no memory leak.This happens automatically as soon as the PR is merged. Hence, I would leave it open for now.
Thank you for verifying the PR!
@Mugen87 I tried out the fiddle with three.js built from your fork and it worked like a charm!
The merge request that I believe introduced this bug (https://github.com/mrdoob/three.js/pull/15330) intended to solve a memory leak, so I briefly attempted to recreate that test, but it’s out-of-date enough that it might not be worth the hassle. It’s a lot more reasonable in any case to fix the problem outlined in this issue, rather than a memory leak that arises from reinstantiating the loaders / generators every time that a texture is updated.
Should I close this issue now, or does it get closed when the merge request is accepted?