Closed powderek closed 1 year ago
Are you able to reproduce the issue by changing the same value through the inspector?
Yes, the issue still occurs when changing values through the inspector.
I actually found the problem in the code. In FFTCompute.cs
there is method GenerateDisplacements
. This method is checking if new values are different from previous values and if they are it is creating new generator with new render textures, without removing the old one. Memory allocation is piling up pretty quick and is leading to imminent crash. I fixed it for my case by changing some conditions but it would be good to see a generic global solution.
Strange. I wasn't able to reproduce and if it does affect the UI as well then I would definitely have hit this. That method will only create a new generator if resolution or loop period has changed otherwise it repurposes the existing generator.
Is it reproducible in the main scene?
The problem doesn't exist in the main scene. I compared the setup and it turns out the problem happens only if Spectrum field on ShapeFFT component is left empty. If it is assigned then memory leaks doesn't happen.
Thank you for narrowing that down. Fixed with above commit.
Is there an existing issue for this?
Have you checked the documentation to resolve your problem?
Current Behavior
Changing waves fields in runtime produces a lot of RenderTexture garbage e.g. ShapeWaves._waveDirectionHeadingAngle, ShapeWaves._windSpeed as shown in profiler below. Updating wind direction during gameplay is not possible because of this issue.
ShapeWaves._weight doesn't produce garbage.
Expected Behavior
No response
Steps To Reproduce
Unity Version
2021.3.11
Crest Version
4.17.3
Render Pipeline
Built-In
Editor or Standalone
Editor (Play Mode), Standalone
Environment
Anything else?
No response