Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug iOS runtime crash in Unity.Entities.Conversion.MultiList of ConvertGameObjectToEntitySystem

Discussion in 'Entity Component System' started by nicolasgramlich, Dec 22, 2020.

  1. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    Hello everyone & Happy Holidays (aka time to work on our games... :D ),

    I have a small
    IConvertGameObjectToEntity
    class doing the following:

    Code (CSharp):
    1.     public class PrefabRegistryEntryAuthoring : MonoBehaviour, IConvertGameObjectToEntity {
    2.         public PrefabRegistryIdentifier PrefabRegistryIdentifier;
    3.  
    4.         public void Convert(Entity entity, EntityManager entityManager, GameObjectConversionSystem gameObjectConversionSystem) {
    5.             if (TryGetComponent<TrailRenderer>(out var trailRenderer)) {
    6.                 gameObjectConversionSystem.AddHybridComponent(trailRenderer);
    7.             }
    8.             if (TryGetComponent<ParticleSystem>(out var particleSystem)) {
    9.                 gameObjectConversionSystem.AddHybridComponent(particleSystem);
    10.                 if (TryGetComponent<ParticleSystemRenderer>(out var particleSystemRenderer)) {
    11.                     gameObjectConversionSystem.AddHybridComponent(particleSystemRenderer);
    12.                 }
    13.             }
    14.         }
    15.     }
    While Android builds run perfectly fine, on iOS it results in the following runtime crash(es):

    Code (CSharp):
    1. ArgumentOutOfRangeException: Value has to be >= 0. Parameter name: length
    2.  
    3. System.Array.Copy (System.Array sourceArray, System.Int32 sourceIndex, System.Array destinationArray, System.Int32 destinationIndex, System.Int32 length) (at <00000000000000000000000000000000>:0)
    4. System.Array.Resize[T] (T[]& array, System.Int32 newSize) (at <00000000000000000000000000000000>:0)
    5. Unity.Entities.Conversion.MultiList`2[T,I].Resize (Unity.Collections.NativeArray`1[System.Int32]& data, System.Int32 size) (at <00000000000000000000000000000000>:0)
    6. Unity.Entities.Conversion.MultiList`2[T,I].Resize (Unity.Collections.NativeArray`1[System.Int32]& data, System.Int32 size) (at <00000000000000000000000000000000>:0)
    7. Unity.Entities.Conversion.MultiList`2[T,I].Resize (Unity.Collections.NativeArray`1[System.Int32]& data, System.Int32 size) (at <00000000000000000000000000000000>:0)
    8. Unity.Entities.Conversion.MultiList.CalcExpandCapacity (System.Int32 current, System.Int32& needed) (at <00000000000000000000000000000000>:0)
    9. Game.Systems.Conversion.PrefabRegistryEntryAuthoring.Convert (Unity.Entities.Entity entity, Unity.Entities.EntityManager entityManager, GameObjectConversionSystem gameObjectConversionSystem) (at <00000000000000000000000000000000>:0)
    10. Unity.Entities.Conversion.ConvertGameObjectToEntitySystem.Convert (UnityEngine.Transform transform, System.Collections.Generic.List`1[T] convertibles) (at <00000000000000000000000000000000>:0)
    11. Unity.Entities.EntityQueryBuilder+F_C`1[T0].Invoke (T0 c0) (at <00000000000000000000000000000000>:0)
    12. Unity.Entities.EntityManagerManagedComponentExtensions.SetComponentData[T] (Unity.Entities.EntityManager manager, Unity.Entities.Entity entity, T componentData) (at <00000000000000000000000000000000>:0)
    13. Unity.Entities.Conversion.ConvertGameObjectToEntitySystem.OnUpdate () (at <00000000000000000000000000000000>:0)
    14. Unity.Entities.ComponentSystem.Update () (at <00000000000000000000000000000000>:0)
    15. Unity.Entities.ComponentSystemGroup.UpdateAllSystems () (at <00000000000000000000000000000000>:0)
    16. Unity.Entities.ComponentSystem.Update () (at <00000000000000000000000000000000>:0)
    17. Unity.Entities.GameObjectConversionUtility.Convert (Unity.Entities.World conversionWorld) (at <00000000000000000000000000000000>:0)
    18. Unity.Entities.ConvertToEntitySystem.Convert () (at <00000000000000000000000000000000>:0)
    19. Unity.Entities.ComponentSystem.Update () (at <00000000000000000000000000000000>:0)
    20. Unity.Entities.ComponentSystemGroup.UpdateAllSystems () (at <00000000000000000000000000000000>:0)
    21. Unity.Entities.ComponentSystem.Update () (at <00000000000000000000000000000000>:0)
    22. UnityEngine.LowLevel.PlayerLoopSystem+UpdateFunction.Invoke () (at <00000000000000000000000000000000>:0)
    23. Unity.Entities.Conversion.ConvertGameObjectToEntitySystem:Convert(Transform, List`1)
    24. Unity.Entities.F_C`1:Invoke(T0)
    25. Unity.Entities.EntityManagerManagedComponentExtensions:SetComponentData(EntityManager, Entity, T)
    26. Unity.Entities.Conversion.ConvertGameObjectToEntitySystem:OnUpdate()
    27. Unity.Entities.ComponentSystem:Update()
    28. Unity.Entities.ComponentSystemGroup:UpdateAllSystems()
    29. Unity.Entities.ComponentSystem:Update()
    30. Unity.Entities.GameObjectConversionUtility:Convert(World)
    31. Unity.Entities.ConvertToEntitySystem:Convert()
    32. Unity.Entities.ComponentSystem:Update()
    33. Unity.Entities.ComponentSystemGroup:UpdateAllSystems()
    34. Unity.Entities.ComponentSystem:Update()
    35. UnityEngine.LowLevel.UpdateFunction:Invoke()
    Here's another one: (Btw, mysteriously
    Facebook.Unity.MethodCall
    shows up at the top of this stack trace, but that's possibly just due to various crash loggers hooking all over the place :eek:
    )
    Code (CSharp):
    1. IndexOutOfRangeException: Index was outside the bounds of the array.
    2.  
    3. Facebook.Unity.MethodCall`1[T].set_Parameters (Facebook.Unity.MethodArguments value) (at <00000000000000000000000000000000>:0)
    4. Unity.Entities.Conversion.MultiList`2[T,I].Resize (Unity.Collections.NativeArray`1[System.Int32]& data, System.Int32 size) (at <00000000000000000000000000000000>:0)
    5. Unity.Entities.Conversion.MultiList.CalcExpandCapacity (System.Int32 current, System.Int32& needed) (at <00000000000000000000000000000000>:0)
    6. Unity.Entities.Conversion.MultiList.CalcExpandCapacity (System.Int32 current, System.Int32& needed) (at <00000000000000000000000000000000>:0)
    7. Unity.Entities.Conversion.JournalingUnityLogger.LogException (System.Exception exception, UnityEngine.Object context) (at <00000000000000000000000000000000>:0)
    8. Unity.Entities.ComponentSystemGroup.UpdateAllSystems () (at <00000000000000000000000000000000>:0)
    9. Unity.Entities.ComponentSystem.Update () (at <00000000000000000000000000000000>:0)
    10. Unity.Entities.GameObjectConversionUtility.Convert (Unity.Entities.World conversionWorld) (at <00000000000000000000000000000000>:0)
    11. Unity.Entities.ConvertToEntitySystem.Convert () (at <00000000000000000000000000000000>:0)
    12. Unity.Entities.ComponentSystem.Update () (at <00000000000000000000000000000000>:0)
    13. Unity.Entities.ComponentSystemGroup.UpdateAllSystems () (at <00000000000000000000000000000000>:0)
    14. Unity.Entities.ComponentSystem.Update () (at <00000000000000000000000000000000>:0)
    15. UnityEngine.LowLevel.PlayerLoopSystem+UpdateFunction.Invoke () (at <00000000000000000000000000000000>:0)
    16. Unity.Entities.ComponentSystemGroup:UpdateAllSystems()
    17. Unity.Entities.ComponentSystem:Update()
    18. UnityEngine.LowLevel.UpdateFunction:Invoke()
    I have not yet worked on a MVP to reproduce this bug outside of my game, but I'm wondering if this is a known issue.

    My package.json is as follows:

    Code (CSharp):
    1. {
    2.   "dependencies": {
    3.     "com.e7.notch-solution": "git://github.com/5argon/NotchSolution.git",
    4.     "com.google.external-dependency-manager": "1.2.163",
    5.     "com.google.firebase.analytics": "7.0.2",
    6.     "com.google.firebase.auth": "7.0.2",
    7.     "com.google.firebase.crashlytics": "7.0.2",
    8.     "com.google.firebase.installations": "7.0.2",
    9.     "com.google.firebase.messaging": "7.0.2",
    10.     "com.google.firebase.remote-config": "7.0.2",
    11.     "com.unity.2d.sprite": "1.0.0",
    12.     "com.unity.addressables": "1.16.15",
    13.     "com.unity.analytics": "3.5.3",
    14.     "com.unity.animation": "0.8.0-preview.4",
    15.     "com.unity.device-simulator": "2.2.3-preview",
    16.     "com.unity.dots.editor": "0.11.0-preview.3",
    17.     "com.unity.entities": "0.16.0-preview.21",
    18.     "com.unity.ide.rider": "3.0.3",
    19.     "com.unity.inputsystem": "1.0.1",
    20.     "com.unity.localization": "0.9.0-preview",
    21.     "com.unity.mobile.notifications": "1.3.2",
    22.     "com.unity.nuget.newtonsoft-json": "2.0.0",
    23.     "com.unity.performance.profile-analyzer": "1.0.3",
    24.     "com.unity.platforms.android": "0.9.0-preview.9",
    25.     "com.unity.platforms.ios": "0.9.0-preview.9",
    26.     "com.unity.platforms.macos": "0.9.0-preview.9",
    27.     "com.unity.polybrush": "1.0.2",
    28.     "com.unity.physics": "0.5.1-preview.2",
    29.     "com.unity.probuilder": "4.4.0",
    30.     "com.unity.progrids": "3.0.3-preview.6",
    31.     "com.unity.properties": "1.3.0-preview",
    32.     "com.unity.properties.ui": "1.6.0-preview",
    33.     "com.unity.purchasing": "2.2.1",
    34.     "com.unity.purchasing.udp": "2.1.4",
    35.     "com.unity.quicksearch": "2.0.2",
    36.     "com.unity.render-pipelines.universal": "9.0.0-preview.72",
    37.     "com.unity.rendering.hybrid": "0.10.0-preview.21",
    38.     "com.unity.serialization": "1.6.1-preview",
    39.     "com.unity.test-framework": "1.1.19",
    40.     "com.unity.test-framework.performance": "2.2.0-preview",
    41.     "com.unity.timeline": "1.3.6",
    42.     "com.unity.ugui": "1.0.0",
    43.     "com.unity.uiextensions": "2.2.2",
    44.     "com.unity.modules.ai": "1.0.0",
    45.     "com.unity.modules.androidjni": "1.0.0",
    46.     "com.unity.modules.animation": "1.0.0",
    47.     "com.unity.modules.assetbundle": "1.0.0",
    48.     "com.unity.modules.audio": "1.0.0",
    49.     "com.unity.modules.cloth": "1.0.0",
    50.     "com.unity.modules.director": "1.0.0",
    51.     "com.unity.modules.imageconversion": "1.0.0",
    52.     "com.unity.modules.imgui": "1.0.0",
    53.     "com.unity.modules.jsonserialize": "1.0.0",
    54.     "com.unity.modules.particlesystem": "1.0.0",
    55.     "com.unity.modules.physics": "1.0.0",
    56.     "com.unity.modules.physics2d": "1.0.0",
    57.     "com.unity.modules.screencapture": "1.0.0",
    58.     "com.unity.modules.terrain": "1.0.0",
    59.     "com.unity.modules.terrainphysics": "1.0.0",
    60.     "com.unity.modules.tilemap": "1.0.0",
    61.     "com.unity.modules.ui": "1.0.0",
    62.     "com.unity.modules.uielements": "1.0.0",
    63.     "com.unity.modules.umbra": "1.0.0",
    64.     "com.unity.modules.unityanalytics": "1.0.0",
    65.     "com.unity.modules.unitywebrequest": "1.0.0",
    66.     "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
    67.     "com.unity.modules.unitywebrequestaudio": "1.0.0",
    68.     "com.unity.modules.unitywebrequesttexture": "1.0.0",
    69.     "com.unity.modules.unitywebrequestwww": "1.0.0",
    70.     "com.unity.modules.vehicles": "1.0.0",
    71.     "com.unity.modules.video": "1.0.0",
    72.     "com.unity.modules.vr": "1.0.0",
    73.     "com.unity.modules.wind": "1.0.0",
    74.     "com.unity.modules.xr": "1.0.0"
    75.   },
    76.   "scopedRegistries": [
    77.     {
    78.       "name": "Game Package Registry by Google",
    79.       "url": "https://unityregistry-pa.googleapis.com",
    80.       "scopes": [
    81.         "com.google"
    82.       ]
    83.     },
    84.     {
    85.       "name": "npmjs",
    86.       "url": "https://registry.npmjs.org/",
    87.       "scopes": [
    88.         "com.unity.uiextensions"
    89.       ]
    90.     }
    91.   ]
    92. }
    I'm using Unity
    2020.1.17f1
    , Xcode
    12.2 (12B45b)
    ,
    iPhone11,8
    ,
    iOS 14.0
    ,
    arm64e
    ,
    if that matters.

    The exact same
    IConvertGameObjectToEntity
    has worked on older entities package
    0.11.2-preview.1
    just fine on iOS. And as I mentioned it works just fine on Android and iOS.

    Does anyone have an idea what's going wrong here?

    Thanks,
    Nicolas
     
    Last edited: Dec 23, 2020
  2. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    Could this be an IL2CPP build requesting generic API TryGetComponent<T> problem? With code striping managed to remove the required function.
    I was using this and it works on ios android and pc standalone.

    Code (CSharp):
    1.    [DisallowMultipleComponent]
    2.     public class HybridComponent : MonoBehaviour, IConvertGameObjectToEntity
    3.     {
    4.         [SerializeField, NaughtyAttributes.ReorderableList] protected List<UnityEngine.Component> Components = new List<Component>();
    5.  
    6.         public virtual bool IsNativeSupported(Component comp) =>
    7.             comp is Transform ||
    8.             comp is MeshRenderer ||
    9.             comp is MeshFilter ||
    10.             comp is SpriteRenderer ||
    11.             comp is UnityEngine.VFX.VisualEffect ||
    12.             comp is IConvertGameObjectToEntity ||
    13.             comp is ConvertToEntity ||
    14.             comp.GetType().Name.Contains("Authoring");
    15.  
    16.         protected virtual void Reset()
    17.         {
    18.             Components.Clear();
    19.             foreach (var comp in gameObject.GetComponents<Component>())
    20.             {
    21.                 if (IsNativeSupported(comp)) continue;
    22.                 else Components.Add(comp);
    23.             }
    24.         }
    25.  
    26.         private void OnValidate()
    27.         {
    28.             if (Components.Any(c => c is ParticleSystem) && Components.All(c => !(c is ParticleSystemRenderer)))
    29.             {
    30.                 var renderer = GetComponent<ParticleSystemRenderer>();
    31.                 if (renderer != null) Components.Add(renderer);
    32.                 else Debug.LogError("ParticleSystem referenced but ParticleSystemRenderer is missing!");
    33.             }
    34.         }
    35.  
    36.         public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    37.         {
    38.             foreach (var comp in Components)
    39.             {
    40.                 if (!comp) continue;
    41.                 conversionSystem.AddHybridComponent(comp);
    42.                 if (comp is SkinnedMeshRenderer)
    43.                 {
    44.                     var animator = transform.GetComponentInParent<Animator>();
    45.                     var animatorEntity = conversionSystem.GetPrimaryEntity(animator);
    46.                     dstManager.AddComponentObject(entity, new HybridSkinnedMeshHackSystem.TempAnimatorBind() { animator = animatorEntity });
    47.                     conversionSystem.AddHybridComponent(animator);
    48.                 }
    49.             }
    50.         }
    51.     }
     
  3. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    I got it to crash with the XCode debugger attached:

    upload_2020-12-21_23-26-57.png

    Here are the relevant snapshots of the call stack:

    Screen Shot 2020-12-21 at 11.30.35 PM.png
    Screen Shot 2020-12-21 at 11.30.26 PM.png

    Screen Shot 2020-12-21 at 11.30.13 PM.png

    Screen Shot 2020-12-21 at 11.30.04 PM.png

    continued...
     
  4. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    ... continuing

    Screen Shot 2020-12-21 at 11.29.42 PM.png

    Screen Shot 2020-12-21 at 11.29.33 PM.png

    Screen Shot 2020-12-21 at 11.29.26 PM.png

    Screen Shot 2020-12-21 at 11.28.22 PM.png
     
  5. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    Hm, I don't think so. When running from Xcode it occasionally works (maybe when the MultiList/Array stuff is seems to be doing internally for some reason doesn't need to be resized??!?). So if it sometimes works, I'd assume it's not a code stripping issue?! :confused:
     
  6. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    @Lieene-Guo btw, what Unity/Entities version are you using?
     
  7. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    Here's another one

    upload_2020-12-21_23-47-20.png
     
  8. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    Same as yours 0.16.0p21
     
    nicolasgramlich likes this.
  9. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    And another one:

    Code (CSharp):
    1. RankException: Only single dimension arrays are supported here.
    2.   at System.Array.Copy (System.Array sourceArray, System.Int32 sourceIndex, System.Array destinationArray, System.Int32 destinationIndex, System.Int32 length) [0x00000] in <00000000000000000000000000000000>:0
    3.   at System.Array.Resize[T] (T[]& array, System.Int32 newSize) [0x00000] in <00000000000000000000000000000000>:0
    4.   at Unity.Entities.Conversion.MultiList`2[T,I].Resize (Unity.Collections.NativeArray`1[System.Int32]& data, System.Int32 size) [0x00000] in <00000000000000000000000000000000>:0
    5.   at Unity.Entities.Conversion.MultiList`2[T,I].Resize (Unity.Collections.NativeArray`1[System.Int32]& data, System.Int32 size) [0x00000] in <00000000000000000000000000000000>:0
    6.   at Unity.Entities.Conversion.MultiList`2[T,I].Resize (Unity.Collections.NativeArray`1[System.Int32]& data, System.Int32 size) [0x00000] in <00000000000000000000000000000000>:0
    7.   at Unity.Entities.Conversion.MultiList.CalcExpandCapacity (System.Int32 current, System.Int32& needed) [0x00000] in <00000000000000000000000000000000>:0
    8.   at Game.Systems.Conversion.PrefabRegistryEntryAuthoring.Convert (Unity.Entities.Entity entity, Unity.Entities.EntityManager entityManager, GameObjectConversionSystem gameObjectConversionSystem) [0x00000] in <00000000000000000000000000000000>:0
    9.   at Unity.Entities.Conversion.ConvertGameObjectToEntitySystem.Convert (UnityEngine.Transform transform, System.Collections.Generic.List`1[T] convertibles) [0x00000] in <00000000000000000000000000000000>:0
    10.   at Unity.Entities.EntityQueryBuilder+F_C`1[T0].Invoke (T0 c0) [0x00000] in <00000000000000000000000000000000>:0
    11.   at Unity.Entities.EntityManagerManagedComponentExtensions.SetComponentData[T] (Unity.Entities.EntityManager manager, Unity.Entities.Entity entity, T componentData) [0x00000] in <00000000000000000000000000000000>:0
    12.   at Unity.Entities.Conversion.ConvertGameObjectToEntitySystem.OnUpdate () [0x00000] in <00000000000000000000000000000000>:0
    13.   at Unity.Entities.ComponentSystem.Update () [0x00000] in <00000000000000000000000000000000>:0
    14.   at Unity.Entities.ComponentSystemGroup.UpdateAllSystems () [0x00000] in <00000000000000000000000000000000>:0
    15.   at Unity.Entities.ComponentSystem.Update () [0x00000] in <00000000000000000000000000000000>:0
    16.   at Unity.Entities.GameObjectConversionUtility.Convert (Unity.Entities.World conversionWorld) [0x00000] in <00000000000000000000000000000000>:0
    17.   at Unity.Entities.ConvertToEntitySystem.Convert () [0x00000] in <00000000000000000000000000000000>:0
    18.   at Unity.Entities.ComponentSystem.Update () [0x00000] in <00000000000000000000000000000000>:0
    19.   at Unity.Entities.ComponentSystemGroup.UpdateAllSystems () [0x00000] in <00000000000000000000000000000000>:0
    20.   at Unity.Entities.ComponentSystem.Update () [0x00000] in <00000000000000000000000000000000>:0
    21.   at UnityEngine.LowLevel.PlayerLoopSystem+UpdateFunction.Invoke () [0x00000] in <00000000000000000000000000000000>:0
    22. Unity.Entities.Conversion.ConvertGameObjectToEntitySystem:Convert(Transform, List`1)
    23. Unity.Entities.F_C`1:Invoke(T0)
    24. Unity.Entities.EntityManagerManagedComponentExtensions:SetComponentData(EntityManager, Entity, T)
    25. Unity.Entities.Conversion.ConvertGameObjectToEntitySystem:OnUpdate()
    26. Unity.Entities.ComponentSystem:Update()
    27. Unity.Entities.ComponentSystemGroup:UpdateAllSystems()
    28. Unity.Entities.ComponentSystem:Update()
    29. Unity.Entities.GameObjectConversionUtility:Convert(World)
    30. Unity.Entities.ConvertToEntitySystem:Convert()
    31. Unity.Entities.ComponentSystem:Update()
    32. Unity.Entities.ComponentSystemGroup:UpdateAllSystems()
    33. Unity.Entities.ComponentSystem:Update()
    34. UnityEngine.LowLevel.UpdateFunction:Invoke()

    The weird thing is that the errors aren't always quite the same, but very very similar. Almost feels like garbage data is passed down into the MultiList and it's basically random what happens from there.... :eek::eek::eek:
     
  10. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    I'm going to try a build that has all this Hybrid stuff disabled entirely and see how that goes. Wouldn't be the first time Hybrid components are broken on one platform (back a few months ago it was Android only iirc)...
     
  11. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    If you got SubScene working. You can try not to do and runtime conversion by exporting the Entity scene directly.
    I also found some issues when converting on a mobile platform runtime with il2cpp.
     
  12. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    Wow, hope it's not a wild pointer not guarded by safetyHandle.
     
  13. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    Yeah, that's on editor-time pre-conversion of all my prefabs is on the todo list. But don't want to mess with that before Christmas... :oops:

    So I ust commented out the AddHybridComponent stuff for ParticleSystem/Renderer like so:
    upload_2020-12-22_0-7-16.png

    and particlesystems are STILL working...

    Oddly I need to keep TrailRenderer in there for the trails to show up, but it appears it's not necessary anymore for ParticleSystems? Am I going crazy? Do you get the same behavior?

    I just double checked the entities changelog and couldn't find anything there about ParticleSystems being converted automatically and I'm 100% sure this used to be necessary previously :eek::confused::eek:
     
  14. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    Oh, yes that's the new hybrid renderer update. I forget that.
     
    nicolasgramlich likes this.
  15. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    this is added to HybridEntitiesConversion
    Code (CSharp):
    1.            Entities.ForEach((ParticleSystem ps, ParticleSystemRenderer ren) =>
    2.             {
    3.                 AddHybridComponent(ps);
    4.                 AddHybridComponent(ren);
    5.             });
     
    nicolasgramlich likes this.
  16. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    Yikes, makes me wonder if all my ParticleSystems are updating (or even rendering) twice rn... :confused:

    I'll give it a shot tomorrow and see if that fixes things :rolleyes:
     
  17. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    Tried it with ParticleSystem stuff commented out (aka no double HybridComponent) and that doesn't seem to make a difference. Now trying this completely without the system.
     
  18. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    Another expression of the same bug:

    Code (CSharp):
    1. ArrayTypeMismatchException: Attempted to access an element as a type incompatible with the array.
    2.  
    3. Unity.Entities.Conversion.MultiList`2[T,I].Resize (Unity.Collections.NativeArray`1[System.Int32]& data, System.Int32 size) (at <00000000000000000000000000000000>:0)
    4. ...
    Posting all these for visibility, jic someone else runs into the same issue :(
     
  19. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    So I just removed my
    IConvertGameObjectToEntity
    entirely and it's still crashing (slightly less often) in the general
    ConvertToEntitySystem
    (other keywords:
    GameObjectConversionMappingSystem
    CreateCompanionGameObjects
    ,
    GameObjectConversionUtility
    ) call stack:

    Screen Shot 2020-12-22 at 4.04.35 PM.png

    Screen Shot 2020-12-22 at 4.04.49 PM.png Screen Shot 2020-12-22 at 4.05.02 PM.png
    Screen Shot 2020-12-22 at 4.05.11 PM.png
    Screen Shot 2020-12-22 at 4.05.24 PM.png
     
    Last edited: Dec 23, 2020
  20. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    You might have had the right intuition here.

    If I'm reading the crash stack trace right, it's crashing here:

    Code (CSharp):
    1. foreach (var component in gameObject.GetComponents<UnityComponent>())
    2. {
    3.     if (component == null)
    4.         continue;
    5.     var type = component.GetType();
    6.     if (!components.Contains(type)) <-- crash inside of here
    upload_2020-12-22_16-28-9.png

    Something must be wrong with the type info :eek:

    I was going to try to remove stripping but... I guess that's not possible with IL2CPP... :(:(:(

    upload_2020-12-22_16-36-32.png
     
  21. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    Alright, tried it with
    Strip Engine Code
    disabled and in debug il2cpp mode and still getting a related error:

    Code (CSharp):
    1. IndexOutOfRangeException: Index was outside the bounds of the array.
    2.  
    3. Unity.Entities.Conversion.MultiListArrayData`1[T].Unity.Entities.Conversion.IMultiListDataImpl<T>.Set (System.Int32 idx, T& data) (at <00000000000000000000000000000000>:0)
    4. Unity.Entities.Conversion.MultiList`2[T,I].Add (System.Int32 headIdIndex, T& data) (at <00000000000000000000000000000000>:0)
    5. Unity.Entities.Conversion.ConversionJournalData.AddHybridComponent (UnityEngine.GameObject gameObject, System.Type type) (at <00000000000000000000000000000000>:0)
    6. Unity.Entities.Conversion.GameObjectConversionMappingSystem.AddHybridComponent (UnityEngine.Component component) (at <00000000000000000000000000000000>:0)
    7. GameObjectConversionSystem.AddHybridComponent (UnityEngine.Component component) (at <00000000000000000000000000000000>:0)
    8. Game.Systems.Conversion.PrefabRegistryEntryAuthoring.Convert (Unity.Entities.Entity entity, Unity.Entities.EntityManager entityManager, GameObjectConversionSystem gameObjectConversionSystem) (at <00000000000000000000000000000000>:0)
    9. Unity.Entities.Conversion.ConvertGameObjectToEntitySystem.Convert (UnityEngine.Transform transform, System.Collections.Generic.List`1[T] convertibles) (at <00000000000000000000000000000000>:0)
    10. Unity.Entities.Conversion.ConvertGameObjectToEntitySystem+<>c__DisplayClass1_0.<OnUpdate>b__0 (UnityEngine.Transform transform) (at <00000000000000000000000000000000>:0)
    11. Unity.Entities.EntityQueryBuilder.ForEach[T0] (Unity.Entities.EntityQueryBuilder+F_C`1[T0] action) (at <00000000000000000000000000000000>:0)
    12. Unity.Entities.Conversion.ConvertGameObjectToEntitySystem.OnUpdate () (at <00000000000000000000000000000000>:0)
    13. Unity.Entities.ComponentSystem.Update () (at <00000000000000000000000000000000>:0)
    14. Unity.Entities.ComponentSystemGroup.UpdateAllSystems () (at <00000000000000000000000000000000>:0)
    15. Unity.Entities.ComponentSystemGroup.OnUpdate () (at <00000000000000000000000000000000>:0)
    16. Unity.Entities.ComponentSystem.Update () (at <00000000000000000000000000000000>:0)
    17. Unity.Entities.GameObjectConversionUtility.Convert (Unity.Entities.World conversionWorld) (at <00000000000000000000000000000000>:0)
    18. Unity.Entities.ConvertToEntitySystem.Convert () (at <00000000000000000000000000000000>:0)
    19. Unity.Entities.ConvertToEntitySystem.OnUpdate () (at <00000000000000000000000000000000>:0)
    20. Unity.Entities.ComponentSystem.Update () (at <00000000000000000000000000000000>:0)
    21. Unity.Entities.ComponentSystemGroup.UpdateAllSystems () (at <00000000000000000000000000000000>:0)
    22. Unity.Entities.ComponentSystemGroup.OnUpdate () (at <00000000000000000000000000000000>:0)
    23. Unity.Entities.ComponentSystem.Update () (at <00000000000000000000000000000000>:0)
    24. Unity.Entities.ScriptBehaviourUpdateOrder+DummyDelegateWrapper.TriggerUpdate () (at <00000000000000000000000000000000>:0)

    I'm officially out of ideas besides praying for the next entities package :(

    I can't downgrade because animations package depends on
    0.16.0-preview.21
    ...

    (Was considering updating burst, but burst shouldn't be messing with these conversion systems :confused:)
     
  22. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    Maybe you can try my approach:
    Code (CSharp):
    1.  
    2.     [DisallowMultipleComponent]
    3.     public class HybridComponent : MonoBehaviour, IConvertGameObjectToEntity
    4.     {
    5.         [SerializeField] protected List<UnityEngine.Component> Components = new List<Component>();
    6.         public virtual bool IsNativeSupported(Component comp) =>
    7.             comp is Transform ||
    8.             comp is MeshRenderer ||
    9.             comp is MeshFilter ||
    10.             comp is SpriteRenderer ||
    11.             comp is UnityEngine.VFX.VisualEffect ||
    12.             comp is IConvertGameObjectToEntity ||
    13.             comp is ConvertToEntity ||
    14.             comp is ParticleSystemRenderer ||
    15.             comp is ParticleSystem ||
    16.             comp.GetType().Name.Contains("Authoring");
    17.  
    18.         protected virtual void Reset()
    19.         {
    20.             Components.Clear();
    21.             foreach (var comp in gameObject.GetComponents<Component>())
    22.             {
    23.                 if (IsNativeSupported(comp)) continue;
    24.                 else Components.Add(comp);
    25.             }
    26.         }
    27.  
    28.         public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    29.         {
    30.             foreach (var comp in Components)
    31.             {
    32.                 if (!comp) continue;
    33.             }
    34.         }
    35.     }
    36.  
    So HybridComponents a stored in a list and Serialized. So you don't need to GetComponet/TryGetComponent at conversion.
    This script works fine in my IOS/Android build even with runtime conversion.
    And you can choose which component goes Hybrid in editor.
     
  23. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    Well, even if I remove my own system completely, I do get the same bug in a slightly different spot. So (unless I'm misunderstanding something) your system wouldn't help, would it? It seems more like an internal bug.
     
  24. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    Okay, It looks like a time bomb to me. MultiList source code looks fine. I can not figure out what's wrong nether.
    I will try to avoid runtime conversion whenever I can.
     
    nicolasgramlich likes this.