Random Editor bugs and eventual crashes in Unity 6
What happened?
It seems that in my unity projects that use Cesium, the Unity Editor runs into Errors that eventually make the UI unusable or crash.
Here is my scene view window after these bugs have started appearing:
This is unfortunately hard to reproduce, as the bugs seem to accumulate over time after reloading scripts and entring play mode a couple of times.
It happens on Unity 6.1, 6.2, and 6.3.
Environment
Cesium for Unity version: 1.18.1 Unity Editor Version: 6000.2.9f1 Operating System: Windows 11 24h2
Reproduction steps
- Add Cesium Unity to project
- Work as normal (edit code, trigger domain reloads, enter play mode etc...)
- Wait for crash or UI changes ...
Supporting evidence
The first bug to appear is usually
Resolve of invalid GC handle. The handle is from a previous domain. The resolve operation is skipped.
Another is
InvalidCastException: Specified cast is not valid.
UnityEngine.ResourcesAPIInternal.FindShaderByName (System.String name) (at <038ae34513ab4db49caf29025be8f045>:0)
UnityEngine.ResourcesAPI.FindShaderByName (System.String name) (at <038ae34513ab4db49caf29025be8f045>:0)
UnityEngine.Shader.Find (System.String name) (at <038ae34513ab4db49caf29025be8f045>:0)
UnityEngine.TextCore.Text.TextShaderUtilities.get_ShaderRef_Sprite () (at <0f74564c596a49edb2bcc1f63ade93f3>:0)
UnityEngine.TextCore.Text.FontAsset.CreateFontAssetInstance (UnityEngine.Font font, System.Int32 atlasPadding, UnityEngine.TextCore.LowLevel.GlyphRenderMode renderMode, System.Int32 atlasWidth, System.Int32 atlasHeight, UnityEngine.TextCore.Text.AtlasPopulationMode atlasPopulationMode, System.Boolean enableMultiAtlasSupport) (at <0f74564c596a49edb2bcc1f63ade93f3>:0)
UnityEngine.TextCore.Text.FontAsset.CreateFontAsset (System.String fontFilePath, System.Int32 faceIndex, System.Int32 samplingPointSize, System.Int32 atlasPadding, UnityEngine.TextCore.LowLevel.GlyphRenderMode renderMode, System.Int32 atlasWidth, System.Int32 atlasHeight, UnityEngine.TextCore.Text.AtlasPopulationMode atlasPopulationMode, System.Boolean enableMultiAtlasSupport) (at <0f74564c596a49edb2bcc1f63ade93f3>:0)
UnityEngine.TextCore.Text.FontAsset.CreateFontAssetFromFamilyName (System.String familyName, System.Int32 pointSize) (at <0f74564c596a49edb2bcc1f63ade93f3>:0)
UnityEngine.TextCore.Text.FontAsset.CreateFontAssetOSFallbackList (System.String[] fallbacksFamilyNames, System.Int32 pointSize) (at <0f74564c596a49edb2bcc1f63ade93f3>:0)
UnityEngine.TextCore.Text.TextSettings.GetOSFontAssetList () (at <0f74564c596a49edb2bcc1f63ade93f3>:0)
UnityEngine.TextCore.Text.TextSettings.get_fallbackOSFontAssets () (at <0f74564c596a49edb2bcc1f63ade93f3>:0)
UnityEngine.UIElements.UITKTextJobSystem.GenerateTextJobified (UnityEngine.UIElements.MeshGenerationContext mgc, System.Object _) (at <8966e118d0054112ab94138b090bd323>:0)
UnityEngine.UIElements.UIR.MeshGenerationDeferrer.Invoke (UnityEngine.UIElements.UIR.MeshGenerationDeferrer+CallbackInfo ci, UnityEngine.UIElements.MeshGenerationContext mgc) (at <8966e118d0054112ab94138b090bd323>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
or
UnityException: get_pixelsPerPoint can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
UnityEngine.UIElements.VisualElement.get_scaledPixelsPerPoint () (at <8966e118d0054112ab94138b090bd323>:0)
UnityEngine.UIElements.UITKTextHandle.GetPixelsPerPoint () (at <8966e118d0054112ab94138b090bd323>:0)
UnityEngine.UIElements.UITKTextHandle.ConvertUssToTextGenerationSettings (System.Boolean populateScreenRect, System.Nullable`1[T] fontsize) (at <8966e118d0054112ab94138b090bd323>:0)
UnityEngine.UIElements.UITKTextJobSystem+PrepareTextJobData.Execute (System.Int32 index) (at <8966e118d0054112ab94138b090bd323>:0)
Unity.Jobs.IJobParallelForExtensions+ParallelForJobStruct`1[T].Execute (T& jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at <038ae34513ab4db49caf29025be8f045>:0)
Hi @Thane5, thanks for the bug report. Indeed we're seeing a lot of instability with the plugin in Unity 6. We're going to have someone look into it to figure this out.
Hey @Thane5, I just realized you listed using v1.18.1 in your description. Do you see an improvement if you switch to v1.19.0?
In my short tests i haven't had a crash yet, but after a couple of script changes the Editor still glitches out when i enter play mode
When exiting play mode it becomes more usable again, but still has some broken UI elements.