cesium-unity icon indicating copy to clipboard operation
cesium-unity copied to clipboard

Investigate "Release of invalid GC handle" errors

Open csciguy8 opened this issue 2 years ago • 2 comments

Install Unity Hub 3.4.2 and Unity 2021.3.25f1.

Follow the 'Cesium for Unity Quickstart" guide, https://cesium.com/learn/unity/unity-quickstart/

  1. Create a new project, use the "3D Sample Scene (HDRP)" template.
  2. Add the Cesium scoped registry to the Project Settings
  3. Install Cesium from the Package Manager (Cesium for Unity, Version 1.2.0 - May 09, 2023) Note a warning in the console:
The package cache was invalidated and rebuilt because the following immutable asset(s) were unexpectedly altered:
	  Packages/com.unity.render-pipelines.highdefinition/Runtime/RenderPipelineResources/HDRenderPipelineRuntimeResources.asset
	  Packages/com.cesium.unity/Runtime/Resources/CesiumDefaultTilesetMaterial.mat
	  Packages/com.cesium.unity/Runtime/Resources/CesiumUnlitTilesetMaterial.mat
  1. From the main menu, select Cesium -> Cesium to bring up the Cesium window (opens next to hierarchy)
  2. Close Unity
  3. Open your project again.

You'll see two console errors on startup. Release of invalid GC handle. The handle is from a previous domain. The release operation is skipped.

The error persists every time you open your project and the Cesium Window is present.

Note: This does not happen if using the "3D Sample Scene (URP)" template

csciguy8 avatar May 23 '23 16:05 csciguy8

This is an old issue, but I'm repurposing it for a recent trend of these memory-related errors.

On the forum, a user noticed this error come up while viewing 02_CesiumMelbourne in cesium-unity-samples. I could see the same error come up in that level after entering / exiting play mode.

Additionally, other users on this forum thread have posted that their system memory keeps climbing in the Unity editor. One user reports:

Hi, I have encountered this before. It has something to do with Cesium updating in the editor. Just untick the “Update in Editor” and that should fix the problem for now. Not really a fix, but eliminates that problem.

This makes me suspect that the two are related. Maybe we aren't properly handling the life cycle in Edit mode, somehow, and the memory leaks are accumulating over time. Just a hunch though, this warrants more thorough investigating.

j9liu avatar Apr 24 '24 14:04 j9liu