RVOSim causing Unity to hang after 5-15 minutes in 2021.3, only a small player base is affected

Since upgrading to Unity 2021, I’ve had a small set of my player bases having Unity hang (no error) after 5-15 minutes. The faster the framerate, the quicker it generally ends up in this non-responding state.

This does not happen on either of my computers, but I was able to get a file dump of the hung process from someone it was affecting. After digging into the file dump of a hung process, it appears the main thread has the following callstack:
GameAssembly!RVOSimulator.Update
GameAssembly!Simulator.Update
GameAssembly!Worker.Execute
→ runFlag.Set()

I’m on the most recent version (4.2.17). I don’t know if this is a new problem with Unity’s version of IL2CPP shipped with 2021, or a problem with A*PP that is now just more likely to happen.

Any thoughts on this issue? I’m next panning to try the beta version, but clearly I’m worried about shipping an update with a beta version if it does fix. I’ll report back if it fixes regardless.

Hi

Do try the beta version. The threading part of the RVO simulation has been completely rewritten in the beta.

It looks like there are no more crashes with the Beta version. Testing is ongoing, but looking very promising.

FYI - I do have someone at Unity investigating if they think it is related to their IL2CPP generated code or the underlying logic in place.

A few questions:

  1. How “ready” is the beta version for production? I basically have the game completely stalled while this is being resolved, I would need to decide on falling back go 2020 and all the new functionality that was added from the 2021 patch, or moving forward with this beta version.

  2. With the current way of getting the beta package, is there a way to edit the source code? I’ve had to make a few edits for my game. Simply coping the contents of “\Library\PackageCache\com.arongranberg.astar@4.3.48” directory to the “\Assets\AstarPathfindingProject” doesn’t seem to work, it’s like the project is not being included, my scripts can’t reference any of the classes. I’ve spent an hour trying to get it working.

As an FYI some of the edits I have are:

  1. Upping the infinite loop limit in Path.cs

  2. Adding a StartPathWithPartial() functions to AIBase.cs and Seeker.cs to allow a version of StartPath that sets the constructed path.pPathEnableTags = true, and passes in a custom set of enabledTags

  3. Functions to AIPath to allow zeroing velocity2d & verticalVelocity (used by my emergency fix placment logic when an AI rarely falls off the map)

1 Like

For most use cases it is probably more robust than the official version. It has more bugfixes.

If you are using .asmdef files, make sure to reference the A* Pathfinding Project, otherwise it will not work.

However, at least for edit (2) and (3) you could do that by subclassing the AIPath component instead of editing the code.

Very good point, I could do that but that does leave one thing I must have changed in my game. Long term: making that infinite loop check upper bounds a setting would be great. In my tower defence, mazes can get quite long.

I will give another attempt of setting up an “asset” version of the beta version. I’m not using an asmdef file.

Edit: My attempt worked this time, I made a temporary asmdef file to reference A*PP. Then after it downloaded the updated required dependicies, removed the reference. It’s compiling now, full speed ahead.

I’ll let you know if I hear anything from Unity reguading the base blocking problem.

Really, you need to search more than 1000000 nodes per path? Are you sure that’s correct? How big is your graph?

The Trace() infinite check limit was 2048. I then updated it to 16384. (more than double I’d ever need)

Ah. Yeah that is actually a bit on the small side. I’ll bump it to 16384 in the next beta update.