darbycostello / Nav3D

3D Pathfinding and cover system plugin for UE4, using Sparse Voxel Octrees.
MIT License
118 stars 31 forks source link

Crash in PIE is back... #8

Closed dom452 closed 3 years ago

dom452 commented 3 years ago

Conditions: Flying AI units (pawns) fly around and do stuff. I shoot the pawns, deduct health. On tick, it checks if their HP is below zero, if so, it marks them as ToDestroy, it then checks if it CanDestroy - if true, it destroys the pawn.

The methods precediing the Nav3D FindPath calls set CanDestroy to false before firing FindPath, and set CanDestroy to True when the delegate is called. This is to prevent the pawn from destroying itself at any time an async task is currently in operation.

Funny thing is, even with this, some of the pawns get stuck in a grey zone where the FindPath has been called, but the delegate hasn't fired, and doesn't fire for a good long while.

I suspect it's getting caught in an infinite loop somewhere in the DoWork? but I have no idea...

Here's the crash info:

LoginId:6a1bbb5d4653cd5d3ad216bf32d6f7e6 EpicAccountId:06717951032a464eafe83530c299cadb

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x000000000000009b

UE4Editor_Nav3D!UNav3DComponent::AddPathStartLocation() [C:\battletide_repo\Battletide\Plugins\Nav3D-main\Source\Nav3D\Private\Nav3DComponent.cpp:679] UE4Editor_Nav3D!FNav3DFindPathTask::DoWork() [C:\battletide_repo\Battletide\Plugins\Nav3D-main\Source\Nav3D\Public\Nav3DFindPathTask.h:51] UE4Editor_Nav3D!FAutoDeleteAsyncTask::DoWork() [C:\Program Files\Epic Games\UE_4.26\Engine\Source\Runtime\Core\Public\Async\AsyncWork.h:100] UE4Editor_Core!FQueuedThread::Run() [D:\Build++UE4\Sync\Engine\Source\Runtime\Core\Private\HAL\ThreadingBase.cpp:992] UE4Editor_Core!FRunnableThreadWin::Run() [D:\Build++UE4\Sync\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:86] UE4CC-Windows-C30FA15B46E35A68EAF4DDB7332C76D3_0000.zip

darbycostello commented 3 years ago

Have you checked the output result of the find path node to ensure the task was started? The return result from the node will immediately report an error before attempting the asynchronous path finding task, so you would likely need to implement your CanDestroy logic here as well as after the custom delegate event.

darbycostello commented 3 years ago

Looking at the code I can probably just add some validity checks wherever a call is made against the owning actor and bail on the function in question.

dom452 commented 3 years ago

I haven't set anything off the result. I'll do that now :) I was also wondering if there was any way to do a validity check inside the async task or the do while loop stuff - but that also makes me wonder if the async would even have access to validity info and, if so, how synced would it be with game thread?

Like, if I destroy a unit on the tick, will the async task abandon when it next cycles and finds it's owning pawn to be invalid, or will it cause the same crash by trying to call the delegate on a deleted instance of the Pawn? Is there some way to cancel or abandon the async task and not fire the delegate if the owner is destroyed?

dom452 commented 3 years ago

Thanks for being a champ about this. I just love how lean this plugin is and that it has the cover system in it. I'm using that for some pretty cool escape mechanics for these dropships.

dom452 commented 3 years ago

Have you checked the output result of the find path node to ensure the task was started? The return result from the node will immediately report an error before attempting the asynchronous path finding task, so you would likely need to implement your CanDestroy logic here as well as after the custom delegate event.

The errors I should be looking for, I assume, all the enums that are NOT call success and found line of sight?