Multiple Scenes in Hierarchy Break Cesium

Hello Cesium team,

I hope you are all doing well.

After updating from 1.15.3 to 1.23.0, I encountered a new issue: when multiple scenes are present in the hierarchy, entering play mode triggers unexpected errors that prevent Cesium from loading.

Even if all additional scenes are unloaded (leaving only the entry-point scene active), their mere presence in the hierarchy appears to cause the problem.

Once this state occurs, the temporary workaround is to remove all scenes except the entry-point one and restart Unity, which is disruptive to our workflow.

Please let me know if you’d like me to open a GitHub issue as well.

Thank you!

--

image

--

ArgumentException: The scene is not loaded.
Reinterop.ReinteropInitializer+AssemblyReloadCallbackNativeFunction.Invoke () (at ./Library/PackageCache/com.cesium.unity@04d259c6404d/Source/generated/Reinterop.RoslynSourceGenerator/ReinteropInitializer.cs:30467)
UnityEditor.AssemblyReloadEvents.OnBeforeAssemblyReload () (at <0e08e1d2ec124b208901fdb811cdf9c2>:0)

Exception while loading Cesium ion app data: Request was canceled because the Unity AppDomain is reloading.
UnityEngine.Debug:LogError (object)
Reinterop.ReinteropInitializer:UnityEngine_Debug_CallLogError_FA05wu8x__otZNsgdHTnU9A (intptr,intptr*) (at ./Library/PackageCache/com.cesium.unity@04d259c6404d/Source/generated/Reinterop.RoslynSourceGenerator/ReinteropInitializer.cs:32766)
CesiumForUnity.CesiumIonSession:Tick () (at ./Library/PackageCache/com.cesium.unity@04d259c6404d/Source/generated/Reinterop.RoslynSourceGenerator/CesiumIonSession-generated.cs:295)
CesiumForUnity.CesiumEditorUtility:UpdateIonSession () (at ./Library/PackageCache/com.cesium.unity@04d259c6404d/Source/Editor/CesiumEditorUtility.cs:27)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

Exception while resuming Cesium ion connection: Failed to obtain _appData, can’t resume connection
UnityEngine.Debug:LogError (object)
Reinterop.ReinteropInitializer:UnityEngine_Debug_CallLogError_FA05wu8x__otZNsgdHTnU9A (intptr,intptr*) (at ./Library/PackageCache/com.cesium.unity@04d259c6404d/Source/generated/Reinterop.RoslynSourceGenerator/ReinteropInitializer.cs:32766)
CesiumForUnity.CesiumIonSession:Tick () (at ./Library/PackageCache/com.cesium.unity@04d259c6404d/Source/generated/Reinterop.RoslynSourceGenerator/CesiumIonSession-generated.cs:295)
CesiumForUnity.CesiumEditorUtility:UpdateIonSession () (at ./Library/PackageCache/com.cesium.unity@04d259c6404d/Source/Editor/CesiumEditorUtility.cs:27)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

Hi @jqntn ,

Thank you for the detailed report — the stack trace is really helpful here.

Just to confirm my understanding: after upgrading to 1.23.0, having any additional scenes present in the Build Settings hierarchy (even fully unloaded ones) causes errors when entering play mode, and the only workaround is to physically remove those scenes and restart Unity. Is that right?

The stack trace points to an assembly reload callback in Reinterop (OnBeforeAssemblyReload) that appears to be iterating over scenes and hitting one that isn’t loaded:

ArgumentException: The scene is not loaded.
ReinteropInitializer+AssemblyReloadCallbackNativeFunction.Invoke()

This then causes CesiumIonSession to lose its app data and fail to resume the ion connection. The root cause looks like a scope issue in how the assembly reload callback handles unloaded scenes — this appears to be a regression introduced somewhere between 1.15.3 and 1.23.0.

A couple of questions to help us narrow it down:

  • Which version of Unity are you using?

  • Can you reproduce this with a minimal project (two empty scenes in Build Settings, Cesium in only the first)?

  • Do you know if this started in a specific intermediate version (e.g., does 1.16.0 work)?

I’d like to open a GitHub issue to track this — it looks like something the engineering team should investigate. Happy to do that once we confirm the reproduction steps.