[1121] VRAM Leak when using VRC_CustomRendererBehaviour/RendererExtensions.updateGIMaterials()
complete
Temporal
As of the update to Unity 2019, there appears to be a case of VRAM leaks when VRC_CustomRendererBehaviour (sdk2) or RendererExtensions.updateGIMaterials() (sdk3) is used in conjunction with a world baked with enlighten and real time global illumination, to have dynamic emissive materials that require the emissive texture to be updated, such as video player emissions.
This appears to happen in both worlds that are still on Unity 2018, as well as worlds that have been updated to unity 2019, that make use of the above mentioned features. It also appears to happen in the unity editor, as you can see in this webm: https://nyanpa.su/f/492U1utH.webm
I can confirm this does not happen in editor in Unity 2018.
The VRAM continues to rise indefinitely, and stops when VRC_CustomRendererBehaviour/UpdateGIMaterials is disabled.
When VRAM is capped, depending on your set up, small amounts of stuttering can be observed, and large stutters whem vram needs to be freed up for other assets to be loaded, such as people joining the instance, changing avatars, toggling of assets and mirrors especially, and depending on the amount needed, this seems to cause the infamous 11 fps bug, and i've also managed to cause my vr compositor to hang doing so.
Reproduction steps:
- Turn on a gpu monitoring tool such as GPU-Z
- Go to a world that makes use of real time gi with dynamic texture emissives such as video player emissions
- Observe VRAM rising indefinitely, and stops when video emissions are disabled.
- When VRAM is capped, micro stutters can be observed, and large stutters when avatars load in, mirrors toggled on, or anything that requires VRAM to be freed up.
Worlds:
- Bedroom Theatre (unity 2018 ver): wrld_fff5d510-fc53-4e88-9d4e-1e0e45a17aff
- Bedroom Theatre (unity 2019 ver): wrld_68526515-f76a-4ded-a53c-6436bbd84e04
- Dynamic Theater (UDON): wrld_f8f1cedf-8789-49e8-b846-1a58d30c42ea
(do note that jetdog's world only has updateGIMaterials() running when a video is playing, can also emulate the effect by dragging the video screen emission slider back and forth)
As enlighten and realtime global illumination is considered as depreciated by unity in 2019, this seems more likely it is a unity issue rather than VRChat specifically, but I'm opening this canny here for now in case anyone else has observed similar behaviour, and if someone more well informed of this issue could contribute.
Log In
Tupper - VRChat Head of Community
complete
Fixed in Unity 2019.4.30f1, which we swapped to in VRChat 2021.3.4.
Skuld
Tupper - VRChat Head of Community: ty tupper
Tupper - VRChat Head of Community
tracked
This is a Unity bug. They know about it and apparently a fix is lined up for 2019.4.30. Once it is out, we'll have to evaluate and test that version before we upgrade, as it is very likely something else has changed or potentially broken between 29 and 30.
Asovrix
Unity fixed that in 2019.4.30f1.
Tupper - VRChat Head of Community
Asovrix: "will fix". It isn't out yet!
Skuld
I created a test in VRChat and standalone for the version of 2019 that VRChat uses. No matter what, if Realtime GI updates are triggered, memory leaks. Even if Unity is triggering it for some other reason (Animation or Skybox color change). It does appear to definitely be internal to Unity with no work around.
owlboy
I think this is the issue I have been seeing. When it occurs, the video/theater screen stops rendering at certain angles. Almost like a culling issue.
When things break, the menus and UI stop rendering some thumbnails and other dynamic assets.
Ariexe
This may be a problem I am also encountering in my new world Terrarium. I also use RTGI and multiple people have reported crashing as if their HMD freezes and stutters before the game eventually gives out. My logs suggestion it freezes around when avatars are initialized.
Temporal
Ariexe: Probably a separate issue, I don't observe this happening in your map, and it doesn't look like you're using video emissions? The above problem requires both RTGI to be enabled, AND the use of RendererExtensions.updateGIMaterials() being called for it to happen.
Ariexe
Temporal: The latest public version's video player emission doesn't have an updater attached to it, so its not appearing so but the world did in the past, and I still have RTGI enabled in enlightened. I don't know enough about the intricacies of unity to say whether or not it could be, but this issue has had me grasping at straws.
Thank you for testing eitherway.
Eternal Ohm
Saw this being talked about in the VRChat discord and tried it myself. Can confirm that it just kept rising indefinitely, until it reached 11 GB, then I stopped it.
ville672
This is causing some serious graphics issues. Avatars disappear, whole pc freezes randomly or it kills the graphics driver.
Temporal
I've reproduced the issue on a vanilla unity 2019.4.29f1 project and submitted a bug report to unity.
Temporal
Their response:
---
Hi,
Thanks for reporting this issue, after some investigation we have found that it's already fixed in Unity 2020.3.0f1 and above.
Please reach out to me if I can be of further help.
---
And ticket was closed. Guess we'll have to wait till 2020? RIP
Skuld
Temporal: This could still be possibly fixed by VRC by work around. Perhaps a method to update GI for us that also resets the Emission environment and freeing up VRAM.
owlboy
Temporal: Just to make sure I am understanding:
You created a standalone Unity project, no VRC involved, and confirmed the issue? Or do you mean just a fresh VRC world?
It seems some people think this issue only occurs when loading a Unity 2018 world in the current Unity 2019 client. And that contradicts this canny.
T
TCL
Temporal: Was this a report on their public issue tracker? Can you link the closed issue?
owlboy
TCL: Already sent you this, just posting it here for the record/others:
I think this is the one:
Temporal
owlboy: Correct, I created a standalone unity project in 2019.4.29f1 with nothing from VRC involved, with a C# script to call RendererExtensions.updateGIMaterials() with a scene baked with realtime gi on a realtime emissive object, and the VRAM leak happens.
Thanks for linking the issue tracker, I'm not familiar with the process for unity bug reports and only had the link to the fogbugz ticket.
Dj Lukis․LT
Ouch, normally such issue would get backported but i guess they flexing the "deprecated on 2019.*"... Theres still hope to trigger backport if VRC asks via enterprise support (like they did for other issues)