[Major Inspector Bug U6] InvalidOperationException: EnsureRunningOnMainThread

(Inspector array bug - see end of thread)

Keep getting this error in the editor - after compiling code and selecting an object in the scene say. I have seen others report it. It is a useless error as gives no clear indication of the cause!
Are there still issues with the editor UI code?

InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread
  at UnityEngine.Object.EnsureRunningOnMainThread () [0x0000d] in <0900e0d4bb644dafbfd59eb7fd222a68>:0 
  at UnityEngine.Object.GetInstanceID () [0x00001] in <0900e0d4bb644dafbfd59eb7fd222a68>:0 
  at UnityEngine.Object.IsNativeObjectAlive (UnityEngine.Object o) [0x00035] in <0900e0d4bb644dafbfd59eb7fd222a68>:0 
  at UnityEngine.Object.CompareBaseObjects (UnityEngine.Object lhs, UnityEngine.Object rhs) [0x0001d] in <0900e0d4bb644dafbfd59eb7fd222a68>:0 
  at UnityEngine.Object.op_Equality (UnityEngine.Object x, UnityEngine.Object y) [0x00001] in <0900e0d4bb644dafbfd59eb7fd222a68>:0 
  at UnityEngine.TextCore.Text.FontAsset.get_SourceFont_EditorRef () [0x00001] in <63bf4767ce1f49bf8f363454a45e02ce>:0 
  at UnityEngine.TextCore.Text.FontAsset.LoadFontFace () [0x0009a] in <63bf4767ce1f49bf8f363454a45e02ce>:0 
  at UnityEngine.TextCore.Text.FontAsset.AddSynthesizedCharactersAndFaceMetrics () [0x00028] in <63bf4767ce1f49bf8f363454a45e02ce>:0 
  at UnityEngine.TextCore.Text.FontAsset.ReadFontAssetDefinition () [0x00013] in <63bf4767ce1f49bf8f363454a45e02ce>:0 
  at UnityEngine.TextCore.Text.FontAsset.get_characterLookupTable () [0x0000e] in <63bf4767ce1f49bf8f363454a45e02ce>:0 
  at UnityEngine.TextCore.Text.TextHandle.UpdateWithHash (System.Int32 hashCode) [0x0005f] in <63bf4767ce1f49bf8f363454a45e02ce>:0 
  at UnityEngine.UIElements.UITKTextHandle.UpdateMesh () [0x0003e] in <d59d088174d643f487a455f58c6feb55>:0 
  at UnityEngine.UIElements.UITKTextJobSystem+GenerateTextJobData.Execute (System.Int32 index) [0x00036] in <d59d088174d643f487a455f58c6feb55>:0 
  at Unity.Jobs.IJobParallelForExtensions+ParallelForJobStruct`1[T].Execute (T& jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) [0x00031] in <0900e0d4bb644dafbfd59eb7fd222a68>:0 
  at (wrapper delegate-invoke) Unity.Jobs.IJobParallelForExtensions+ParallelForJobStruct`1+ExecuteJobFunction[UnityEngine.UIElements.UITKTextJobSystem+GenerateTextJobData].invoke_void_T&_intptr_intptr_JobRanges&_int(UnityEngine.UIElements.UITKTextJobSystem/GenerateTextJobData&,intptr,intptr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,int)

I continue to get these errors randomly in Unity 6. It is currently happening on Debug.Log sometimes. There are some async calls around but they are not doing anything special or specifying background thread etc.

Once I get one i just get them all the time as if UIElements has gone wrong

A restart of the editor is required

Well, you may should file a new bug report. It was already reported over here but it says it has been fixed. Maybe this is another internal issue that has been overlooked as well. So please file a bugreport with a reproduction case. Maybe add a link to this thread or the issue I mentioned.

Yes well I am trying to find an easy way to reproduce, i.e. find out what is the cause

It may even be related to some editor window. What editor windows are open / visible when this happened?

It’s interesting you say that, because if I get the error during play mode then if I stop and de-select what is active in the hierarchy so the Inspector is empty… it then runs fine next time without an error.

Quite concerned about Unity 6 currently…

Loaded scene 'Temp/__Backupscenes/0.backup'
	Deserialize:            10.505 ms
	Integration:            217.666 ms
	Integration of assets:  0.007 ms
	Thread Wait Time:       0.004 ms
	Total Operation Time:   228.182 ms
Asset Pipeline Refresh (id=5f4131def8cb9a647b174ad1da6d4a22): Total: 0.008 seconds - Initiated by RefreshV2(NoUpdateAssetOptions)
InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread
  at UnityEngine.Object.EnsureRunningOnMainThread () [0x0000d] in <84f0d810adef4e6c8deab33e4ae93f7c>:0 
  at UnityEngine.Object.GetInstanceID () [0x00001] in <84f0d810adef4e6c8deab33e4ae93f7c>:0 
  at UnityEngine.Object.IsNativeObjectAlive (UnityEngine.Object o) [0x00035] in <84f0d810adef4e6c8deab33e4ae93f7c>:0 
  at UnityEngine.Object.CompareBaseObjects (UnityEngine.Object lhs, UnityEngine.Object rhs) [0x0001d] in <84f0d810adef4e6c8deab33e4ae93f7c>:0 
  at UnityEngine.Object.op_Equality (UnityEngine.Object x, UnityEngine.Object y) [0x00001] in <84f0d810adef4e6c8deab33e4ae93f7c>:0 
  at UnityEngine.TextCore.Text.FontAsset.get_SourceFont_EditorRef () [0x00001] in <66908d7b9c31462785bb5fbf8386f74a>:0 
  at UnityEngine.TextCore.Text.FontAsset.LoadFontFace () [0x0009a] in <66908d7b9c31462785bb5fbf8386f74a>:0 
  at UnityEngine.TextCore.Text.FontAsset.AddSynthesizedCharactersAndFaceMetrics () [0x00028] in <66908d7b9c31462785bb5fbf8386f74a>:0 
  at UnityEngine.TextCore.Text.FontAsset.ReadFontAssetDefinition () [0x00013] in <66908d7b9c31462785bb5fbf8386f74a>:0 
  at UnityEngine.TextCore.Text.FontAsset.get_characterLookupTable () [0x0000e] in <66908d7b9c31462785bb5fbf8386f74a>:0 
  at UnityEngine.TextCore.Text.TextHandle.UpdateWithHash (System.Int32 hashCode) [0x0005f] in <66908d7b9c31462785bb5fbf8386f74a>:0 
  at UnityEngine.UIElements.UITKTextHandle.UpdateMesh () [0x0003e] in <4b3569741df14432abb5f87dfb1101b0>:0 
  at UnityEngine.UIElements.UITKTextJobSystem+GenerateTextJobData.Execute (System.Int32 index) [0x00036] in <4b3569741df14432abb5f87dfb1101b0>:0 
  at Unity.Jobs.IJobParallelForExtensions+ParallelForJobStruct`1[T].Execute (T& jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) [0x00031] in <84f0d810adef4e6c8deab33e4ae93f7c>:0 
  at (wrapper delegate-invoke) Unity.Jobs.IJobParallelForExtensions+ParallelForJobStruct`1+ExecuteJobFunction[UnityEngine.UIElements.UITKTextJobSystem+GenerateTextJobData].invoke_void_T&_intptr_intptr_JobRanges&_int(UnityEngine.UIElements.UITKTextJobSystem/GenerateTextJobData&,intptr,intptr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,int)

see next post now -

Any open array in the inspector cause an issue when you press play it seems?!
Unity 6
Bug IN-93811

using System;
using UnityEngine;

public class Test : MonoBehaviour
{
	public GameObject[] modeButtons;
}
1 Like

This still occurs in 6000.0.35.
Hope it can be recognized