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

I am having an issue on LOD entities when removing them which creates the following error:

Error Exception

IndexOutOfRangeException: Index 7 is out of range of ā€˜6’ Length.
Unity.Collections.NativeArray1[T].FailOutOfRangeError (System.Int32 index) (at <e414e10bfe5f45729ff122f3359de21b>:0) Unity.Collections.NativeArray1[T].CheckElementReadAccess (System.Int32 index) (at :0)
Unity.Collections.NativeArray`1[T].get_Item (System.Int32 index) (at :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)

It occurs at like 344 in the HybridV2Culling.cs class :


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?

anyone? i have the exact same problem

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!

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.

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:

Needed Script:

using UnityEngine;
using Unity.Entities;
using Unity.Jobs;
public class AnimateGameObject : MonoBehaviour {
    public Vector3 speed = Vector3.left;
    void Update() {
        transform.localPosition += Time.deltaTime * speed;
    }
}
public class TestSystem : JobComponentSystem {
    protected override JobHandle OnUpdate(JobHandle inputDeps) {
        var entities = EntityManager.GetAllEntities(Unity.Collections.Allocator.Temp);
        foreach (var e in entities) {
            if (Random.value > 0.5f) {
                if (EntityManager.HasComponent<Dirty>(e))
                    EntityManager.RemoveComponent<Dirty>(e);
                else
                    EntityManager.AddComponentData(e, new Dirty());
            }
        }
        entities.Dispose();
        return inputDeps;
    }
}

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?

1 Like

when i had this issue it was indeed with objects having lod groups on the border of being in view/out of view

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… :frowning:

It’s better to use bug report tool at Unity editor so you can get reply from Unity.

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.

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…

1 Like

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…

I am scheduled to investigate it this sprint (at least the reported bug on this that we have). Can’t guarantee anything though.

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…

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.

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 :slight_smile:

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

Ah Ok, thank you very much.

@StefanWo The link to the test scene above does no longer work. Would you be able to upload it again?

@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.

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.