question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PMREMGenerator: instances share context across multiple renderers

See original GitHub issue
Description 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Mugen87commented, Apr 1, 2020

AFAICT, when dispose() is properly used, there should be no memory leak.

Should I close this issue now, or does it get closed when the merge request is accepted?

This happens automatically as soon as the PR is merged. Hence, I would leave it open for now.

Thank you for verifying the PR!

0reactions
treyenelsoncommented, Apr 1, 2020

@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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

PMREMGenerator – three.js docs
This class generates a Prefiltered, Mipmapped Radiance Environment Map (PMREM) from a cubeMap environment texture. This allows different levels of blur to be ......
Read more >
Three.js "Context Lost" and "Multiple instances being imported"?
It seems like a memory leak to me. Anything happened inside <iframe /> stays in the memory unless it is deallocated manually or...
Read more >
Creating a game in Three.js - LogRocket Blog
Develop games using Three.js, a 3D library that provides an easy way to load models, and allows users to play the game within...
Read more >
three js map - Stylemate
How to Map Texture to a 3D Face with Three. js is a JavaScript library ... 2 months ago. js must render into...
Read more >
Building an NFT Powered Web AR Camera for the Deadmau5 ...
Two weeks ago, I published a post on Mirror which recounted the experience of minting my ... PMREMGenerator(renderer)// Precompile shader
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found