I am calling FindPathAsync periodically every 0.5 seconds to find and draw a path from a player to his destination location. Every so often my game crashes at DetourNavMeshQuery.cpp line 1156.
if (filter->passFilter(ref, tile, &tile->polys[node->i]) && passLinkFilter(tile, node->i))
This is a snippet of code I use to call FindPathAsync:
FVector location;
if (getDestinationLocation(location))
{
DestinationLocation = location;
FNavAgentProperties navAgentProperties;
navAgentProperties.AgentHeight = 100;
navAgentProperties.AgentRadius = 10;
navAgentProperties.bCanWalk = true;
navAgentProperties.bCanFly = false;
FPathFindingQuery navParams;
navParams.EndLocation = location;
navParams.StartLocation = GetOwner()->GetActorLocation();
ANavigationData* navData = GetWorld()->GetNavigationSystem()->MainNavData;
navParams.QueryFilter = UNavigationQueryFilter::GetQueryFilter<UNavigationQueryFilter>(navData);
navParams.NavData = navData;
FNavPathQueryDelegate del;
del.BindUObject(this, &UPathDisplayComponent::PathToObjectiveFound);
GetWorld()->GetNavigationSystem()->FindPathAsync(navAgentProperties, navParams, del, EPathFindingMode::Regular);
Please help
Hey Davor-
Where do you have this code executing in your project (what class/function/how it is called)? If there is more setup needed to reproduce the crash other than copying this code into a class, can you provide the setup steps that lead to the crash? Additionally, can you provide the callstack and log files from the crash?
Hello and thank you for aquick repy!
Function is a part of a custom ActorComponent attached to a player controlled character. It is called from another c++ class first time, and then by timer set to repeat every 0.5 seconds. No actors are destroyed or even moved when the crash happens. I am submiting a crash log. If there is any other information I can provide please tell me.
I have managed to work around the crash by using the synchronous method FindPathToLocationSynchronously() instead for now, but I will need the async version sooner or later.
EDIT: sorry, I forgot to answer one point, I made a new component that just calls FindPathAsync to location 0, 0, 0 in a loop and it does not crash. If it helps, I will investigate what is the minimum I need to do to make it crash as soon as I am able.
There are a number of “Failed import” and “array out of bounds” errors appearing in the log. For more detailed information, can you provide your machine ID? You can get this easily from the black Crash Reporter window that appears after the crash occurs.
I have been reducing my code to see what is the minimum needed to reproduce the crash. This is a fresh class that is not dependent on anything custom made and that crashes in the same way. Just to provide a context, It’s a part of a system that draws a path from player to his objective. It’s reworked here to seek a path to 0, 0, 0. Every time FindPathAsync is called, it’s callback should delete existing particles and then create new ones through the nodes returned by the pathfinder.
As for the failed to import errors, as I understand, those are created because I have been adding properties to classes who’s instances were already been placed on a level, so they are missing data. Array out of bounds is an error our level artist made somewhere in the blueprints. Both should be benign, right?
BTW. my machineId:AC4FD33F4F1B958515BFDBBD1918B548
I created an ActorComponent class and copied the code you provided into it. Upon compile there were errors with the #include "Enums.h"
line. Is this a custom class and if so, what is inside it? Can you provide the full system you’re using as well as steps so that I can setup a reproduction case locally?
Oh, I’m sorry, I forgot to erase enums.h form the inclues section. It is just a file that holds some common custom enums I use. It is not needed for the code I provided, so you can just delete that include.
Steps are as follow:
-
Create a new project
-
Import one beam type particle effect
-
Copy in the class I have provided (you only need to edit precompiled header file to suit the project name if I remember correctly)
-
Create a new blank level
-
Put one sphere actor (don’t put it at 0, 0, 0)
-
Add my class to it
-
Add any shape between actor and just so it’s not a straight path (0, 0, 0) (might not be needed)
-
Run the PIE for a minute or so.
I tried following the steps provided but I’m slightly confused by step 7. I tried pulling in a basic cube object, however I’m not sure if it is supposed to be positioned in a specific location. What exactly do you mean by “add any shape between actor and…”?
Sorry, I deleted part of the sentence by mistake. It should say “between actor and 0, 0,0 location”. Just block a straight path from the test actor to 0,0,0 so the pathfinder does not return a straight line. I’m not sure if it’s a necesaary step, but it was a part of my test scenario so I put it in.
I am still not getting a crash on my end. If you’re able to reproduce this in a new project, could you provide the sample project for me to test directly?
https://we.tl/tiB3B8QTVm
here is a zipped sample project. Just open the untitled map and run. It should crash after a while.
I’m running the sample project provided. Do you have an idea how long it will take for the crash to occur?
It usually crashes within a minute or so for me. Longest I’ve seen it run was about 5 minutes. Sometimes editor just closes.
Hey Davor-
I opened the project in 4.10.4 and encountered the crash as you described. However when I opened the project in 4.11.2 from the Launcher I did not get any crash after letting the project run for about 10-15 minutes. Can you confirm if this crash occurs for you in the latest engine?
Hello!
It seems to work on version 4.11. Problem is we are probably stuck on 4.10 for a bit more, so I was hoping you could tell me what exactly causes the crash and how to avoid it until we migrate to 4.11.
Hey Davor-
Looking at the log files after the crash, it appears to be a crash in runnable thread TaskGraphThread. Unfortunately I cannot find a reference to this specific crash internally, so it is likely that the fix for another issue in 4.11 fixed this crash. This is as much information I was able to gather from the project provided.
Cheers
Thank you very much for your time!
I’ve just had this same crash occur on 4.10, although in my case I’m calling FindPathAsync from inside a BTTask, and I’m using the two-parameter version of UNavigationQueryFilter::GetQueryFilter but passing null as the second parameter.
The cause appears to be caused when UPathFollowingComponent::OnPathFinished calls UPathFollowingComponnet::Reset() and this calls Path.Reset(). Inside FNavigationPath::~FNavigationPath() it seems that the FNavigationPath::Filter pointer is also being destroyed & in my case this is only ever ARecastNavMesh’s default query filter.
So I think something is messing with the shared pointer internal counters or something?!
Hey byakhee-
Do you get the same crash in 4.11 or 4.12? As I mentioned, it appears that this has been fixed as I was unable to reproduce it with the project Davor provided (which did reproduce in 4.10 as you stated).
we’re going to 4.11 in a month or so I think, so I’ll give it a try then.