Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Bug HybridV2Culling.cs | IndexOutOfRangeException Index is out of range of Length, stops rendering

Discussion in 'Graphics for ECS' started by BigRookGames, Dec 22, 2020.

  1. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    331
    I am having an issue on LOD entities when removing them which creates the following error:

    IndexOutOfRangeException: Index 7 is out of range of '6' Length.
    Unity.Collections.NativeArray`1[T].FailOutOfRangeError (System.Int32 index) (at <e414e10bfe5f45729ff122f3359de21b>:0)
    Unity.Collections.NativeArray`1[T].CheckElementReadAccess (System.Int32 index) (at <e414e10bfe5f45729ff122f3359de21b>:0)
    Unity.Collections.NativeArray`1[T].get_Item (System.Int32 index) (at <e414e10bfe5f45729ff122f3359de21b>:0)
    Unity.Rendering.SimpleCullingJob.Execute (Unity.Entities.ArchetypeChunk archetypeChunk, System.Int32 chunkIndex, System.Int32 firstEntityIndex) (at Library/PackageCache/com.unity.rendering.hybrid@0.10.0-preview.21/Unity.Rendering.Hybrid/HybridV2Culling.cs:344)

    When this happens everything that is being rendered through Hybrid V2 stops rendering until switching between the game window and the Scene window or executing DOTS>Hybrid Renderer> Recreate all batches.

    (you can see all the drones disappear at once)
    https://i.gyazo.com/1d0448afd5bc48345f009f6d801205a9.gif



    It occurs at like 344 in the HybridV2Culling.cs class :
    upload_2020-12-22_15-46-57.png
    obviously trying to use an index that no longer exists. When putting an if finalIndex < length it works, but since it is managed it gets reset each time it rebuilds after.

    Is there a workaround for this?
     
  2. nijnstein

    nijnstein

    Joined:
    Feb 6, 2021
    Posts:
    78
    anyone? i have the exact same problem
     
  3. VincentBreysse

    VincentBreysse

    Unity Technologies

    Joined:
    May 31, 2021
    Posts:
    28
    Hello! If you can still repro the issue, please submit a bug report with a repro case so that we can investigate it.
    Also make sure that the bug is actually reproducible using the latest Hybrid Renderer package version, which is currently 0.11.0-preview.44.
    Thanks!
     
  4. nijnstein

    nijnstein

    Joined:
    Feb 6, 2021
    Posts:
    78
    it went away while changing code that removed and added many entities with renderers, it was on the latest build but i cant repo it and still dont really know what was wrong.
     
  5. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    132
    Hi there. I got the same issue. I'm using the current 0.11.0-preview.44 Version.

    It looks like it is happening, when one mesh of the group leaving the visible area.
    In the time where the bug appears, there were no entities created or destroyed, but they might get some components.
    I don't get this code there... Couldn't an easy check help there?


    Update: I could reproduce it with a simple scene: Create 2 Entities with LOD Groups and renderer below and a camera moving away from them, so just 1 of the entity is visible. Also add a system that randomly add or removes a component, so the entities changing the chunk. When 1 box become visible, the exception occurs.

    => Happens when the entities changing the chunk.

    I couldn't create a new project for that. Didn't do that for years and seems the entities package and stuff is not there. Here all the needed files.

    TestScene:
    https://filetransfer.io/manage-package/7GNHWik3#

    Needed Script:
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using Unity.Entities;
    4. using Unity.Jobs;
    5. public class AnimateGameObject : MonoBehaviour {
    6.     public Vector3 speed = Vector3.left;
    7.     void Update() {
    8.         transform.localPosition += Time.deltaTime * speed;
    9.     }
    10. }
    11. public class TestSystem : JobComponentSystem {
    12.     protected override JobHandle OnUpdate(JobHandle inputDeps) {
    13.         var entities = EntityManager.GetAllEntities(Unity.Collections.Allocator.Temp);
    14.         foreach (var e in entities) {
    15.             if (Random.value > 0.5f) {
    16.                 if (EntityManager.HasComponent<Dirty>(e))
    17.                     EntityManager.RemoveComponent<Dirty>(e);
    18.                 else
    19.                     EntityManager.AddComponentData(e, new Dirty());
    20.             }
    21.         }
    22.         entities.Dispose();
    23.         return inputDeps;
    24.     }
    25. }
    Another update:
    Partial good News: I tested it in the compiled version and it looks fine so far. So i guess its just happening in the editor. I have BURST OFF in the Editor. Maybe it has something to do with that?
     
    Last edited: Jan 10, 2022
    nijnstein likes this.
  6. nijnstein

    nijnstein

    Joined:
    Feb 6, 2021
    Posts:
    78
    when i had this issue it was indeed with objects having lod groups on the border of being in view/out of view
     
  7. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    132
    Still no reply from Unity? Very sad... I spend another time effort for debugging and even creating an easy reproduction project for this bug.

    I guess its my last try spend effort on this kind of researches... being already ignored sooo many times now... :(
     
  8. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,137
    It's better to use bug report tool at Unity editor so you can get reply from Unity.
     
  9. joelv

    joelv

    Unity Technologies

    Joined:
    Mar 20, 2015
    Posts:
    203
    We have a report for something similar to this already and will try to look at it shortly.
    But please report errors using the bug reporter, it's much easier to ensure everything is getting tracked that way.
     
  10. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    132
    Ok, thanks.
    @optimise: I tried that already, but i would take a long time to setup a project for that simple file, to configure everything it has to be. I tried it, but after 1h to figure out the packages (that are not shown sometimes, due to preview) try to setup i stopped with it...
    I did that for another report and spend also half a day on it, but this failed processing, due to its not a "run and broken".
    It sometimes looks like we have to do 99% of the developer work, before they even consider to start to looking at it.

    Sry, i can't spend half my working day to report a bug in that way. I already spend a day to analyse the unity code that caused the problem and added the scripts needed to reproduce...
     
    nijnstein likes this.
  11. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    132
    Any updates on this Topic? I experience now more and more issues with that topic. Also rendering bugs of Meshes that should not be shown anymore, related to that bug and LOD Levels and ALSO in the compiled version...
     
  12. joelv

    joelv

    Unity Technologies

    Joined:
    Mar 20, 2015
    Posts:
    203
    I am scheduled to investigate it this sprint (at least the reported bug on this that we have). Can't guarantee anything though.
     
  13. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    132
    Ok, thanks. Can you link it here, so we can see it?

    Maybe you can also check that short script, it takes 1min to try it out i guess...
     
  14. joelv

    joelv

    Unity Technologies

    Joined:
    Mar 20, 2015
    Posts:
    203
    It might not be the same bug even if the callstacks looks similar. And I see if I can get it to repo.

    I would suggest you report it as a bug through the regular bug tracking system to be honest, it makes is much easier for both you and us to track things.
     
  15. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    132
    As i said, last time i spend a lot of time to do that and the result was, that it was not even going to the developers... This time i also tried to setup a new game to make it work, but it wasn't possible, due to the packages were not shown and i needed to setup all of the experimental packages again to get it work in a clean environment... If you have an EASY and fast way, that not cost hours to report a bug, i can try that again.

    Again: For me it takes half a day to set it up, to save you 1 min of copy paste the 3 files and press a button... This will not going to happen... I'm happy to help you, but not spending hours to save you a minute of work... So my only way for me is to hope, that a bigger customer gets to use this technology and pushes your management to fix that....


    For the bug: I ment the bug you work in this sprint, just link it >>HERE<<, so we know, what bug you mean and see when its fixed to retest :)
     
  16. joelv

    joelv

    Unity Technologies

    Joined:
    Mar 20, 2015
    Posts:
    203
    The bug is internal and not visible in the public issue tracker.

    It's not about wasting time. It's about tracking what needs to be done, prioritization and backports of fixes.
    But I will try to test your example during this work
     
  17. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    132
    Ah Ok, thank you very much.
     
  18. joelv

    joelv

    Unity Technologies

    Joined:
    Mar 20, 2015
    Posts:
    203
    @StefanWo The link to the test scene above does no longer work. Would you be able to upload it again?
     
  19. joelv

    joelv

    Unity Technologies

    Joined:
    Mar 20, 2015
    Posts:
    203
    @StefanWo Ping again. Do you happen to have the test scene locally so you can upload it again?

    I have been looking at another LOD group problem but it's specific to Live Link only and so far I have no reproduction cases where an exception like this happens when modifying things from code.
     
  20. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    132
    Hi, sry, didn't see it.

    No, don't have it anymore. But it is actually just:
    the TestSystem above run
    add 2 rendered similar entities with LOD Groups
    than move the camera from "both visible" to "only one" visible, to trigger the "Partial visible" culling mode.
     
  21. joelv

    joelv

    Unity Technologies

    Joined:
    Mar 20, 2015
    Posts:
    203
    Right. I will see if I am able to set it up. I have some test scenes with LOD Group from the other repro already.
    The important thing here is where structural changes happens. It cannot happen in the presentation group since the hybrid renderer works in several steps and changing the structure somewhere in the middle will break things. I will see if this is the case with this repro. And we will try to add an error message if structural changes happens somewhere the hybrid renderer expects none to happen.

    Update from the other investigation:
    It was a repro based on entities getting moved while Live Link was enabled. This changes some internal state in a way that impossible to track at the moment, giving us this error. It is not something that we can fix for 0.50 stream I think but there is two workarounds if it is really needed: Turn off Live Link, or force the movement grace to always update (this require code change).
     
  22. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    132
    Year, the TestSystem just works in the default group (so simulation i guess), so that shouldn't be a problem. My guess was more, that it stores something over a frame, but had no clear idea.
    Keep in mind, that it just happens in the editor, i never had that error or related problems in the compiled version! Maybe it helps to detect the problem :\

    I never used livelink, just simply in the unity editor, and later compiling to pc version only.

    I still use the 0.11.0-preview.44. I wanted to update, but my 2021.2.15f1 is not supported yet :(
     
  23. joelv

    joelv

    Unity Technologies

    Joined:
    Mar 20, 2015
    Posts:
    203
    Good news. I have a fix for this.

    Another good news is that the fix is already in 0.50 but for some reason it had regressed to our working branch.

    If you need to fix this in your existing package you can look at
    UpdateAllHybridChunksJob.Execute and after the line

    HybridChunkUpdater.ProcessChunk(chunkInfo, chunk, chunkBounds);


    you add

    hybridChunkInfos[i] = chunkInfo;


    You also need to remove
    [ReadOnly]
    tag on the HybridChunkInfo component handle and the place where this is set up from the scheduling code.

    Thank you for the script as it made it possible for us to fix this and not regress upcoming releases.
     
    Last edited: Mar 29, 2022
    apkdev likes this.
  24. apkdev

    apkdev

    Joined:
    Dec 12, 2015
    Posts:
    308
    Hey, testing this right now, for the code to compile I think you need to do :
    Code (CSharp):
    1. HybridChunkUpdater.ProcessChunk(chunkInfo, chunk, chunkBounds);
    2. hybridChunkInfos[i] = chunkInfo;
     
  25. joelv

    joelv

    Unity Technologies

    Joined:
    Mar 20, 2015
    Posts:
    203
    Thank you. I fixed the typo in my post above
     
  26. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    132
    Thank you very much :)

    I will wait for the 0.50 due to its just a annoying in the editor. As i read its planned for the next months for my version. Hope the migration goes well :\