Search Unity

Question Build error on subscene: Cannot find TypeIndex for type hash

Discussion in 'Entity Component System' started by charleshendry, Sep 22, 2020.

  1. charleshendry

    charleshendry

    Joined:
    Jan 7, 2018
    Posts:
    98
    I'm getting the following error message in a Windows build, related to the Subscene I'm loading:

    Error when processing 'AsyncLoadSceneJob(C:/Users/Charles/Desktop/MafiaWars 210920/Mafia Wars_Data/StreamingAssets/SubScenes/400b03da272004a4b960df665ee26e56.0.entities)': Cannot find TypeIndex for type hash 7456386032775506678. Ensure your runtime depends on all assemblies defining the Component types your data uses.


    I'm on 2020.2.0b2 and have Platforms Windows 0.8.0 and am using the Win64 build configuration. I'd seen this same issue on the Project Tiny FAQ, but can't find the export log file, which would give me the missing type. Also unclear on what this means:
    Ensure that the root assembly references the assembly that contains the type
    .
     
  2. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    992
    Hi, try to do a windows search from the folder "C:/Users/Charles/Desktop/MafiaWars 210920" looking for the type hash value "7456386032775506678". If your drive is indexes the files content maybe it will pick it up.
    ou can try the same thing from C drive root if you want but it may take some time.

    On my conputer with the tiny3D base project this gives me the following result :

    0x677a679757c4aaf6 - 7456386032775506678 - Unity.Transforms.Frozen

    I think the type hash used by unity are stable accross plateform so maybe you are missing the Unity.Transforms in your assembly definition.
     
    charleshendry likes this.
  3. Zec_

    Zec_

    Joined:
    Feb 9, 2017
    Posts:
    148
    If you're using the SceneSection Metadata feature, that is seemingly broken in builds in 0.14 and causes these kinds of issues. I've reported it as an issue and posted on the forums a while ago.
    https://forum.unity.com/threads/ent...es-corrupt-in-entityheaders-in-builds.956484/

    Another potential issue I've had that can cause these kinds of issues is if you have conditional fields in components which causes the built subscene to use different type structures when it's built+serialized in the editor vs when it's deserialized in the build. I can't remember if it was caused by certain specific conditionals such as UNITY_EDITOR of DEBUG, but I know I've encountered it.

    Edit: I realized the metadata error I mentioned first returns a different kind of error message (although still about missing typehashes), so that's probably not your problem.

    I also remembered that I wrote a editor script back when I had issues that could help you find which type it is that causes your error. It helped me with finding my conditional issues. Perhaps you can have a use for this:
    Code (CSharp):
    1. using System;
    2. using System.Linq;
    3. using Unity.Entities;
    4. using UnityEditor;
    5. using UnityEngine;
    6.  
    7. public static class EditorUtilities
    8. {
    9.     [MenuItem("Tools/Find Problematic TypeHash")]
    10.     public static void FindTypeHash()
    11.     {
    12.         ulong targetTypeHash = 8998326293364349710; // Add your problematic typehash here.
    13.         foreach (var type in AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()))
    14.         {
    15.             try
    16.             {
    17.                 var typeHash = TypeHash.CalculateStableTypeHash(type);
    18.                 if (typeHash == targetTypeHash)
    19.                     Debug.LogWarning($"Found {targetTypeHash}. Type: {type.FullName}");
    20.             }
    21.             catch (Exception e)
    22.             {
    23.                 // Some types aren't supported and I'm too lazy to find out which.
    24.             }
    25.         }
    26.     }
    27. }
    28.  
    Edit 2: I was somewhat in a rush when I wrote the first post, so I missed that WAYN_Group probably already found which type you were having problems with, so none of what I wrote might be useful for you :)
     
    Last edited: Sep 22, 2020
    Arnold_2013 and charleshendry like this.
  4. charleshendry

    charleshendry

    Joined:
    Jan 7, 2018
    Posts:
    98
    Still struggling with this. I have Unity.Transforms in my assembly definition.
     
  5. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    353
    I was using subscenes and all was just good, but then at some moment i have starting receive error messages in build. It is about
    ArgumentException: Cannot find TypeIndex for type hash 8075963649556656072. Ensure your runtime depends on all assemblies defining the Component types your data uses.
    (will provide full error log down below). This hash is of UnityEngine.RenderingSortingGroup type i use in my convertion. And i was using SortingGroup even before this error. To find which type is the type of the hash in log i have used Zec_ code, so thank you a lot of saving my time, because i can't find any Logs/SceneExportLog.txt in build folder.

    This page telling us about such a problem in Project Tiny, and...
    But what is root assembly? And how can i ensure that root assembly references UnityEngine.Rendering.Sorting group's assembly? I think this is not my case, but still.

    So i have defined which type causes a problem. And now what? I have fixed all serialization problem of my subscene, and it doesn't help. Please help!

    Also i have inspected all my components to be sure that i dont use conditional fields. And i think SortingGroup also has no problems with this, because it was good before.

    Full player log
    UnloadTime: 0.647600 ms
    ArgumentException: Cannot find TypeIndex for type hash 8075963649556656072. Ensure your runtime depends on all assemblies defining the Component types your data uses.
    at Unity.Entities.Serialization.SerializeUtility.ReadTypeArray (Unity.Entities.Serialization.BinaryReader reader) [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Entities.Serialization.SerializeUtility.DeserializeWorld (Unity.Entities.ExclusiveEntityTransaction manager, Unity.Entities.Serialization.BinaryReader reader, System.Object[] unityObjects) [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Scenes.AsyncLoadSceneOperation+AsyncLoadSceneJob.Execute () [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Jobs.IJobExtensions+JobStruct`1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) [0x00000] in <00000000000000000000000000000000>:0
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    UnityEngine.Logger:LogException(Exception, Object)
    UnityEngine.Debug:LogException(Exception)
    Unity.Debug:LogException(Exception)
    Unity.Scenes.SceneSectionStreamingSystem:UpdateLoadOperation(AsyncLoadSceneOperation, World, Entity)
    Unity.Scenes.SceneSectionStreamingSystem:processActiveStreams()
    Unity.Scenes.SceneSectionStreamingSystem:OnUpdate()
    Unity.Entities.ComponentSystem:Update()
    Unity.Entities.ComponentSystemGroup:UpdateAllSystems()
    Unity.Entities.ComponentSystemGroup:OnUpdate()
    Unity.Entities.ComponentSystem:Update()
    Unity.Entities.ComponentSystemGroup:UpdateAllSystems()
    Unity.Entities.ComponentSystemGroup:OnUpdate()
    Unity.Entities.ComponentSystem:Update()
    Unity.Entities.DummyDelegateWrapper:TriggerUpdate()

    Error when processing 'AsyncLoadSceneJob(D:/Builds/FantasyTavernManager/0.0.4/Fantasy Tavern Manager_Data/StreamingAssets/SubScenes/18a87bdfe66a7bb47b2a3f76c750f3f7.0.entities)': Cannot find TypeIndex for type hash 8075963649556656072. Ensure your runtime depends on all assemblies defining the Component types your data uses.
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:LogWarning(Object)
    Unity.Debug:LogWarning(Object)
    Unity.Scenes.SceneSectionStreamingSystem:UpdateLoadOperation(AsyncLoadSceneOperation, World, Entity)
    Unity.Scenes.SceneSectionStreamingSystem:processActiveStreams()
    Unity.Scenes.SceneSectionStreamingSystem:OnUpdate()
    Unity.Entities.ComponentSystem:Update()
    Unity.Entities.ComponentSystemGroup:UpdateAllSystems()
    Unity.Entities.ComponentSystemGroup:OnUpdate()
    Unity.Entities.ComponentSystem:Update()
    Unity.Entities.ComponentSystemGroup:UpdateAllSystems()
    Unity.Entities.ComponentSystemGroup:OnUpdate()
    Unity.Entities.ComponentSystem:Update()
    Unity.Entities.DummyDelegateWrapper:TriggerUpdate()

    Have you fixed this bug?

    UPD: I have deleted all my assembly defenitions to test maybe my problem have starting to appear after asmdefs was added to project. And in build i still see error but it's different:
    Could not open file D:/Builds/FantasyTavernManager/0.0.4d/Fantasy Tavern Manager_Data/StreamingAssets/SubScenes/18a87bdfe66a7bb47b2a3f76c750f3f7.entityheader for read

    DOTS Project Setup doc tells that this kind of issue can be produced by using built-in build menu, but i use recommended build workflow and i had already building project and all was good with subscenes.

    UnloadTime: 0.728400 ms
    Could not open file D:/Builds/FantasyTavernManager/0.0.4d/Fantasy Tavern Manager_Data/StreamingAssets/SubScenes/18a87bdfe66a7bb47b2a3f76c750f3f7.entityheader for read

    IOException: Failed to read from D:/Builds/FantasyTavernManager/0.0.4d/Fantasy Tavern Manager_Data/StreamingAssets/SubScenes/18a87bdfe66a7bb47b2a3f76c750f3f7.entityheader!
    at Unity.Entities.Serialization.StreamBinaryReader.ReadBytes (System.Void* data, System.Int32 bytes) [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Entities.Serialization.BinaryReaderExtensions.ReadInt (Unity.Entities.Serialization.BinaryReader reader) [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Entities.BlobAssetReference`1[T].TryRead (U binaryReader, System.Int32 version, Unity.Entities.BlobAssetReference`1[T]& result) [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Entities.BlobAssetReference`1[T].TryRead (System.String path, System.Int32 version, Unity.Entities.BlobAssetReference`1[T]& result) [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Scenes.ResolveSceneSectionUtility.ResolveSceneSections (Unity.Entities.EntityManager EntityManager, Unity.Entities.Entity sceneEntity, Unity.Entities.Hash128 sceneGUID, Unity.Entities.RequestSceneLoaded requestSceneLoaded, Unity.Entities.Hash128 artifactHash) [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Scenes.ResolveSceneReferenceSystem.<OnUpdate>b__0_0 (Unity.Entities.Entity sceneEntity, Unity.Entities.SceneReference& scene, Unity.Entities.RequestSceneLoaded& requestSceneLoaded) [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Scenes.ResolveSceneReferenceSystem+<>c__DisplayClass_OnUpdate_LambdaJob0.PerformLambda (System.Void* jobStructPtr, System.Void* runtimesPtr, Unity.Entities.Entity entity) [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Entities.CodeGeneratedJobForEach.StructuralChangeEntityProvider+PerformLambdaDelegate.Invoke (System.Void* jobStruct, System.Void* runtimes, Unity.Entities.Entity entity) [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Entities.CodeGeneratedJobForEach.StructuralChangeEntityProvider.IterateEntities (System.Void* jobStruct, System.Void* runtimes, Unity.Entities.CodeGeneratedJobForEach.StructuralChangeEntityProvider+PerformLambdaDelegate action) [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Scenes.ResolveSceneReferenceSystem+<>c__DisplayClass_OnUpdate_LambdaJob0.Execute (Unity.Entities.ComponentSystemBase componentSystem, Unity.Entities.EntityQuery query) [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Scenes.ResolveSceneReferenceSystem.OnUpdate () [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Entities.SystemBase.Update () [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Entities.ComponentSystemGroup.UpdateAllSystems () [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Entities.ComponentSystem.Update () [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Entities.ComponentSystemGroup.UpdateAllSystems () [0x00000] in <00000000000000000000000000000000>:0
    at Unity.Entities.ComponentSystem.Update () [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.Display+DisplaysUpdatedDelegate.Invoke () [0x00000] in <00000000000000000000000000000000>:0
    UnityEngine.Logger:LogException(Exception, Object)
    UnityEngine.Debug:LogException(Exception)
    Unity.Entities.ComponentSystemGroup:UpdateAllSystems()
    Unity.Entities.ComponentSystem:Update()
    Unity.Entities.ComponentSystemGroup:UpdateAllSystems()
    Unity.Entities.ComponentSystem:Update()
    UnityEngine.DisplaysUpdatedDelegate:Invoke()

    UDP: After i have reloaded editor the second error seems to be gone. And it still the 1st one. So there is no difference asmdefs pesent or not.
     
    Last edited: Jun 29, 2021
  6. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857
    any chance you are using UI toolkit? it causes this error with subscenes in 2020
     
    Tony_Max likes this.
  7. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    353
    nope :D
     
  8. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    353
    I'm on that level of despair when i try to notice every tiny message from unity to me and i have noticed that i have few warnings when start building.
    Scene 18a87bdfe66a7bb47b2a3f76c750f3f7 - Dependencies[0] has invalid GUID, path=''.

    it is not warning, just a simple Log() and it is about scene and about something that invalid, so seems like something related to the problem. I have only one subscene in my project and this is it. Any ideas? (can't search it)

    Unable to find player assembly: E:\UnityProjects\Fantasy-Tavern-Manager\Temp\StagingArea\Data\Managed\UnityEngine.TestRunner.dll

    Unable to find player assembly: E:\UnityProjects\Fantasy-Tavern-Manager\Temp\StagingArea\Data\Managed\Unity.PerformanceTesting.dll

    Have no idea what it is but seems not related to my problem
     
  9. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    353
    The story starts when i was installing Addressables to my project few days ago. I have read that to use it i need to build addressables's group. But firstly i have decided to import memory profiler and see how it works with dev build. So i started to build project with addressables but without addressables's build and i had starting to receive TypeIndex error in build. I swear, my first thought was that this is somehow because of addressables and i was commit all data to new branch and switch to main branch still without addressables. Then i had tried to build and got this error even when i had no addressables in project, but i think it all because editor was not reloaded. Conclusion: my problem resolved. Don't mess with unity's recomendations and reload editor.
     
  10. Dan-Foster

    Dan-Foster

    Joined:
    Aug 7, 2019
    Posts:
    53
    Hello Tony_Max,

    I had this start happening to me today after going backwards and forwards in source control trying to get to the bottom of an issue.

    Whilst doing this different packages would have been included and excluded from the project (I have no idea if this is relevant at all to the problem).

    To fix the issue I closed Unity, deleted the following folders in my project:
    /Library/

    /obj/

    /UserSettings/


    Then booted Unity again and made a build. The issue went away for me.

    Hope this helps!
     
    Tony_Max likes this.
  11. IAmChiagozie

    IAmChiagozie

    Joined:
    Jun 26, 2017
    Posts:
    44
    Any updates on this issue?