eidosmontreal / unreal-vdb

This repo is a non-official Unreal plugin that can read OpenVDB and NanoVDB files in Unreal.
Apache License 2.0
691 stars 109 forks source link

Level restart crash in UVdbVolumeSequence::OnChunkAvailable #79

Closed domofclarkes closed 1 year ago

domofclarkes commented 1 year ago

Hi, we've added some clouds to our level and recently created a shipping package, but are hitting a crash on level restart about 20% of the time. It's only happening on the shipping build as far as we've seen.

Callstack is

Warlock-Win64-Shipping.exe!UVdbVolumeSequence::OnChunkAvailable(unsigned int ChunkId) Line 295 C++ Warlock-Win64-Shipping.exe!FStreamingVolumeData::ProcessCompletedChunks() Line 338 C++ Warlock-Win64-Shipping.exe!FStreamingVolumeData::BlockTillAllRequestsFinished(float TimeLimit) Line 274 C++ Warlock-Win64-Shipping.exe!FStreamingVolumeData::~FStreamingVolumeData() Line 38 C++ Warlock-Win64-Shipping.exe!FVolumeStreamingManager::RemoveVolume(IInterface_StreamableVolumetricAsset Volume) Line 226 C++ Warlock-Win64-Shipping.exe!UVdbVolumeSequence::FinishDestroy() Line 206 C++ Warlock-Win64-Shipping.exe!UObject::ConditionalFinishDestroy() Line 1051 C++ Warlock-Win64-Shipping.exe!IncrementalDestroyGarbage(bool bUseTimeLimit, double TimeLimit) Line 1872 C++ Warlock-Win64-Shipping.exe!IncrementalPurgeGarbage(bool bUseTimeLimit, double TimeLimit) Line 1771 C++ Warlock-Win64-Shipping.exe!CollectGarbageInternal(EObjectFlags KeepFlags, bool bPerformFullPurge) Line 2432 C++ Warlock-Win64-Shipping.exe!CollectGarbage(EObjectFlags KeepFlags, bool bPerformFullPurge) Line 2671 C++ Warlock-Win64-Shipping.exe!UEngine::TrimMemory() Line 14943 C++ Warlock-Win64-Shipping.exe!UEngine::LoadMap(FWorldContext & WorldContext, FURL URL, UPendingNetGame Pending, FString & Error) Line 14542 C++

The reason it seems to be crashing is because VolumeRenderInfos is empty, so when it does

FVolumeRenderInfos& VolRenderInfos = VolumeRenderInfos[FrameIdx];

it returns some random memory (or asserts because the array index is out of bounds).

I can see that the VolumeRenderInfos gets cleared in UVdbVolumeSequence::ReleaseResources()

So it would appear that a new request has been added between UVdbVolumeSequence::BeginDestroy and UVdbVolumeSequence::FinishDestroy

Would that cause this issue?

Let me know if you need any more info. Thanks

thilamb commented 1 year ago

Thanks a lot for the detailed report. I've been chasing after this one for a while but I've never been able to reproduce it.

You're giving me ideas on how to try to reproduce it so I'll test it as soon as I find time to work on this.

Thanks

domofclarkes commented 1 year ago

Thanks. Actually, just to correct myself, the issue began happening before the shipping build was used, so I don't think that's necessarily a factor in any of it, other than it will have changed the timings. It used to happen using PIE, but we can't repro using that anymore, it's only happening in packaged builds atm.

thilamb commented 1 year ago

Hey sorry I'm very late but I finally took the time to try to reproduce the crash and was able to do so ! Here is the fix. Thanks a lot for reporting it.

I'll wait a couple more fixes before preparing a new Release version, unless you really want/need it soon ?