Search Unity

RAM leak and very long Application.UpdateScene

Discussion in 'Cinemachine' started by mardulis, Aug 15, 2020.

  1. mardulis

    mardulis

    Joined:
    Jul 31, 2019
    Posts:
    30
    Hi,

    I guess i'm missing something , but i manage to work with 2 VCAMS (track and dolly) smoothly.

    Usually , things become very slow when i add the third VCAM - When i try to scrub / play and cache the timeline, i get more and more frequent Application.UpdateScene alerts which can last for minutes, and the RAM usage in the Task Manager gradually goes up from 4GB to 55 GB , at that stage i end the task.

    The scene i'm working with is a very big terrain but its very responsive until i start the cinemachine process.

    I could not trace the exact moment the problem starts but it seems i'm messing things up...

    Any help is highly appriciated.

    thanks.
     

    Attached Files:

  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    Thanks for this report. We have not internally seen any such behaviour. If you can send me a project that reproduces this problem, it would greatly help in tracking it down. In the meantime, you can try disabling the Scrubbing Cache (click on a CM clip in the timeline, there is a checkbox in the inspector to disable the cache).

    What version of CM are you using?
     
  3. mardulis

    mardulis

    Joined:
    Jul 31, 2019
    Posts:
    30
    I'm on version 2.6, i've unchecked USE SCRUB BUBBLE, thats the closest to CACHE i've found - is that it ?.

    It still persists with the very long update and RAM usage - i'll try to reduce project size to be able to send it.

    thank you.
     
    Last edited: Aug 17, 2020
  4. mardulis

    mardulis

    Joined:
    Jul 31, 2019
    Posts:
    30
    I hope it's usable - i've attached a project file without all the big assets - only the cameras, and an object which i'm following.
    thanks
     

    Attached Files:

  5. mardulis

    mardulis

    Joined:
    Jul 31, 2019
    Posts:
    30
    The transition between VCAMs (scrubbing or just clicking on the timeline) is the moment things start to go out of control. As long as i stay in the same VCAM it's ok, which is not ok...
     
  6. PXLArtificer

    PXLArtificer

    Joined:
    Jan 12, 2017
    Posts:
    2
    I'm also having a similar issue. When I switch between cameras clicking on the timeline for example I can see Unity freezing for a few seconds and memory usage spiking (CPU use is low). The more I switch between cameras the more I see the memory usage grow and Unity becoming unresponsive for a longer time. After a while, I need to kill unity and reopen it again.
     
    mardulis likes this.
  7. mardulis

    mardulis

    Joined:
    Jul 31, 2019
    Posts:
    30
    Very comforting... couldn't find anything similar on google so far.

    And the repetition issue is the same, more switching - longer update times, more RAM.
     
    PXLArtificer likes this.
  8. PXLArtificer

    PXLArtificer

    Joined:
    Jan 12, 2017
    Posts:
    2
    Yes exactly. My project in Unity is using around 3GB RAM, and until I stay on the same camera in the timeline it stays that way. If I switch too much it goes up, more and more until Unity becomes unresponsive.
    I'm using 3 cameras in cinemachine, but it's a quite standard project with nothing out of the ordinary. For testing I've also disabled the bubble scrub.

    What kind of cameras are you using in your project? The only particular thing I have is a very long dolly track (it's for a car chase, around 60 points) and I'm using the Recomposer extension (I think this is only in the latest version?) but that's it.
     
    Last edited: Aug 17, 2020
  9. mardulis

    mardulis

    Joined:
    Jul 31, 2019
    Posts:
    30
    I'm using one regular vcam and one dolly, the third vcam went down after a fight of about 20 end-task escalations...

    At some point I thought that what messes things up is the fact that I'm adding more timeline animation constraints on the vcams. But that's not the issue apparently..
     
    PXLArtificer likes this.
  10. mardulis

    mardulis

    Joined:
    Jul 31, 2019
    Posts:
    30
    Hi Gregory,

    any ideas?

    thanks.
     
    PXLArtificer likes this.
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    Unfortunately I'm unable to see anything with this. The best way to test it yourself is to create a new project, add the assets you sent me, and see if you can repro the problem. If not, keep adding stuff until you can.

    If you prefer, you can upload the whole project somewhere and PM me with a link to it. If you give me detailed repro steps, I can try to repro the problem.
     
  12. connectorone

    connectorone

    Joined:
    Apr 11, 2017
    Posts:
    14
    gaborkb and mardulis like this.
  13. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    @connectorone Clearly there is something very wrong. We have tried to reproduce this so far without success. Can you send me your project?
     
    gaborkb, connectorone and mardulis like this.
  14. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    Hey @mardulis @PXLArtificer @connectorone,

    @connectorone's movie gave me the clue: PostProcessing! I can repro this now. The massive leak is somewhere in the PostProcessing package. CM calls PostProcessLayer.ResetHistory() on camera cuts, and that's where the leak is happening. I will reach out to the PostProcessing team.

    Thanks to all of you for reporting this.
     
    gaborkb, connectorone and mardulis like this.
  15. mardulis

    mardulis

    Joined:
    Jul 31, 2019
    Posts:
    30
    @connectorone - I didn't get the chance to repro this on a clean project and your movie was a thrill to watch. thanks

    @Gregoryl thanks. please update us as things advance !
     
    connectorone likes this.
  16. connectorone

    connectorone

    Joined:
    Apr 11, 2017
    Posts:
    14
    Thank you @Gregoryl . Do you still need my project to check? If yes, please send me your email adress here:
    przemyslaw@showstorm.co.uk
     
  17. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    Hi again @mardulis @PXLArtificer @connectorone,

    It turns out that I was wrong in my previous diagnosis: it's not PostProcessing, it's Cinemachine after all, in the part that invokes PostProcessing's ResetHistory. It's a regression introduced in CM 2.6.0. We are rushing to put out a patch release, which will be 2.6.2.

    Because that can take some time to work its way through our system, I'm attaching here a patched version of CinemachinePostProcessing.cs. You can use it to directly patch the version in your project, and the leak will go away.

    Many thanks for your patience and help in spotting this problem.

    @connectorone I don't need your project any more, thanks.
     

    Attached Files:

    gaborkb likes this.
  18. connectorone

    connectorone

    Joined:
    Apr 11, 2017
    Posts:
    14
    @Gregoryl thank you for your assistance. Unfortunately it doesn't help at all. Still the same problem.

    Waiting for more info.
     

    Attached Files:

  19. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    How did you install the file I sent?
     
  20. mardulis

    mardulis

    Joined:
    Jul 31, 2019
    Posts:
    30
    I've replaced the previous version in the APPDATA LOCAL folder - this method didn't help.

    How should I install the file ?
     
  21. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    That was one correct place, but Unity caches the packages inside the project as well, and that cache also needs to be patched. If you do this:

    upload_2020-8-28_14-53-45.png

    You will find the actual location of the script being compiled into your project.

    However, we've been able to fast-track the patch release, so sometime today you'll have 2.6.2-preview.1 to import. Maybe you don't need to do this manual patching.
     
    mardulis likes this.
  22. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    Cinemachine 2.6.2-preview.1 is now available in the package manager. It contains a fix for the PostProcessing memory leak.
     
    SamRock and mardulis like this.
  23. mardulis

    mardulis

    Joined:
    Jul 31, 2019
    Posts:
    30
    Gregory thanks!

    Can we have our names engraved in the package-release-credits-plaque ? or at least @connectorone because he made the movie..
     
    Gregoryl and connectorone like this.
  24. mardulis

    mardulis

    Joined:
    Jul 31, 2019
    Posts:
    30
    I've updated the CM package to 2.6.1 via the PACKAGE MANAGER.

    RAM still leaks after a few scrubbs - Should i make any extra manual updates in an existing project?
     
  25. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    You need 2.6.2-preview.1
     
  26. mardulis

    mardulis

    Joined:
    Jul 31, 2019
    Posts:
    30
    Thanks.
     
  27. connectorone

    connectorone

    Joined:
    Apr 11, 2017
    Posts:
    14
    Hi @Gregoryl I replaced the file here in project folder - "unity\The Pursuit\Library\PackageCache\com.unity.cinemachine@2.6.1\Runtime\PostProcessing"

    The 2.6.2-preview.1 is not available yet in Package Manager.
     
  28. mardulis

    mardulis

    Joined:
    Jul 31, 2019
    Posts:
    30
    Open the stack, the PREVIEW version is there
    upload_2020-8-31_12-10-21.png
     
  29. connectorone

    connectorone

    Joined:
    Apr 11, 2017
    Posts:
    14
    Thank you @mardulis I had preview packages disabled in options :)
     
  30. connectorone

    connectorone

    Joined:
    Apr 11, 2017
    Posts:
    14
    Gregoryl likes this.
  31. divyanshjoshi405

    divyanshjoshi405

    Joined:
    Sep 1, 2020
    Posts:
    4
    Hello, I am an Indian Unity Learner Divyansh Joshi, when I am clicking play button in Unity Editor or select main camera or select the game tab to playtest my game, Unity freezes for almost 5 seconds then shows the Application.UpdateScene loading window for almost 20 seconds then Unity closes and the bug reporter opens, I can't test my game, not set my camera nor see a single picture of my game arrangement. Please help me.Mr. Gregoryl.
    I requested you because you're online. Please help me.
     
  32. divyanshjoshi405

    divyanshjoshi405

    Joined:
    Sep 1, 2020
    Posts:
    4
    please reply sir
     
  33. ZeroThreeZero

    ZeroThreeZero

    Joined:
    Jul 12, 2020
    Posts:
    9
    @divyanshjoshi405 You're not giving us any information to work with, how are we supposed to help you without knowing your setup. I can't tell if your issue is directly related to the Cinemachine package, did you rule out other all other possibilities?

    To give you a starting point: try to start with a new (clean) project and see if the issue still occurs. If so, consider creating a new post with more detailed information.
     
  34. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    504
    Well I don't know about you guys but I have 2.62 installed and I'm still having issues with the editor seizing up a long time when I scrub and when I check the task manager unity is suddenly using over 13GB of ram.
     
  35. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    The bug was definitely fixed. Do you have the same setup? (i.e. PostProcessing in the vcams, and camera cuts)
    Have you tried re-importing your project?
     
  36. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    504
    OMG I just doubled checked my setup and I have version 2.6.1 installed. When I checked it yesterday I could have sworn it read 2.6.2! :eek::confused: So I upgraded to 2.6.2 and of course the issue is gone! Thank you and sorry for steering the thread.
     
    Last edited: Sep 10, 2020
    Gregoryl likes this.