4.3.85: Freeze after multiple scans

Hello Aron,

another bug I found in the newest version - it can happen that the game/editor freezes during scanning. This happens after I “loaded” a scene the second time - but not every time, and not for every scene. It just so happens exactly in this case when I enter a room twice.

(Scanning of the last room has already finished, I run that as a coroutine and only show the game when scanning is finished)

See the video… Unity somehow seems to still “run” from what I can see in the task manager… but nothing happens anymore.

Let me know what else you need to know :slight_smile:

Thanks, Greetings,
Denzi

Hi

Is there anything interesting in the log?

Nope, no new entries in the console when it happens… and no crash in the editor.log file…

It feels like some kind of infinite loop … game sound keeps on playing - but that does not have to say anything :smiley:

Hi

Do you think you could try with 4.3.86?

Hi Aron :slight_smile:

Unfortunately the new version didn’t change anything … same issue still remains…

Greetings,
Denzi

Can you replicate this?

Checked it with 4.3.87 … no changes, same issue still appears…

I noticed that it has nothing to do with “multiple scans” but rather with specific levels… if I start the editor from these certain levels, nothing will happen but the unity editor loader “Hold on… Application.EnterPlayMode”. So it will not start these levels either.

If there’s anything you could do to try to figure out why those particular levels cause a crash, that would be immensely helpful.
Or use debug mode (also disable the burst compiler) and try to pause the execution while it’s running to see where it got stuck.

1 Like

Ok will try to do so … give me some time :slight_smile:

Hello Aron,

took me some time to get behind what is happening… I have a script that rotates objects (like rocks etc) randomly on Start(). These GameObjects often have RecastMeshObj’s on them.

Since some versions, A* shows errors for this script, as it is not allowed to rotate “non-dynamic” objects (even if I want to rotate them only once in Start). So I developed this workaround, which worked for some time: I disable the RecastMeshObj before rotation, then re-enable it afterwards.

private void Start()
{
    var recastMeshObj = GetComponent<RecastMeshObj>();
    if (recastMeshObj != null)
    {
		recastMeshObj.enabled = false;
    }

    // HERE, RANDOM ROTATION CODE IS EXECUTED
    //  ...
    //  ...
    //  ...


    // afterwards, reset dynamic setting.
	if (recastMeshObj != null)
	{
		recastMeshObj.enabled = true;
	}
}

Then I noticed that this crashed randomly. Not in every level, but if, then it was reproducable in that level every time… I guess disabling and enabling RecastMeshObj’s does f*** up the A* pathfinding scan process in the background, or something?

In the end, I had to put the whole thing inside Awake() - that should be before the A* scanning process, at least for my setup -, and instead of disabling/enabling the RecastMeshObj, I cache the original “dynamic” value, set dynamic = true, do the random rotation, and then reset “dynamic”:

private void Awake()
{
    // cache dynamic setting and enable.
    var isDynamic = false;
    var recastMeshObj = GetComponent<RecastMeshObj>();
    if (recastMeshObj != null)
    {
        isDynamic = recastMeshObj.dynamic;
		recastMeshObj.dynamic = true;
    }

    // HERE, RANDOM ROTATION CODE IS EXECUTED
    //  ...
    //  ...
    //  ...



    // afterwards, reset dynamic setting.
	if (recastMeshObj != null)
	{
		recastMeshObj.dynamic = isDynamic;
	}
}

Problem of the “Crash-Freeze on pressing Play” fixed :slight_smile:

But now the next problem shows up :slight_smile:

What I noticed is: there seems to be something like “too many RecastMeshObj’s” in a level. In my “Main Map” level, there are ~500 RecastMeshObj’s. If I try to “reload” that Main Map inside the game (meaning reload that exact Unity scene), Unity crash-freezes when I set up the A* pathfinding for the loaded scene, when I call “SnapForceBoundsToScene” for all RecastGraphs.

If I remove most of the RecastMeshObj’s and let there be ~50, the level can be re-loaded - nothing crashes anymore…

I’ve managed to replicate this. It was indeed caused by having a lot of recastmeshobj components.
I’ll include a fix in the next beta update.

1 Like

Aaaaand it works :+1:
Good work! Thanks :grinning:

Have some nice vacation days! Merry christmas :smiley:

1 Like