Hi,
I’m trying to create a custom lens flare for my game. It is a thread safe plugin and i followed the guide from here: CustomLensFlare
In editor everything works fine, and i can see my custom lensflare working properly. But, when i package it, the game crash.
Here the code where it crash:
if( PostProcessAsset->Gradient != nullptr )
{
UE_LOG(LogTemp, Log, TEXT("PostProcessThreadSage::RenderLensFlare - Gradient %s"), *PostProcessAsset->Gradient->GetName());
const FTextureResource* TextureResource = PostProcessAsset->Gradient->GetResource();
if (TextureResource && TextureResource->IsInitialized())
{
UE_LOG(LogTemp, Log, TEXT("PostProcessThreadSage::RenderLensFlare - TextureResource found"));
const FTextureRHIRef TextureRHI = TextureResource->TextureRHI;
if (TextureRHI)
{
UE_LOG(LogTemp, Log, TEXT("PostProcessThreadSage::RenderLensFlare - TextureRHI %s"), *TextureRHI->GetName().ToString());
PassParameters->GradientTexture = TextureRHI;
}
else
{
UE_LOG(LogTemp, Error, TEXT("PostProcessThreadSage::RenderLensFlare - TextureRHI is null"));
}
}
else
{
UE_LOG(LogTemp, Error, TEXT("PostProcessThreadSage::RenderLensFlare - TextureResource is null"));
}
}
else
{
UE_LOG(LogTemp, Error, TEXT("PostProcessThreadSage::RenderLensFlare - Gradient is null"));
}
and here the crash log:
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: === Critical error: ===
[2023.03.04-09.16.50:436][ 0]LogWindows: Error:
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: Fatal error!
[2023.03.04-09.16.50:436][ 0]LogWindows: Error:
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0xffffffffffffffff
[2023.03.04-09.16.50:436][ 0]LogWindows: Error:
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: [Callstack] 0x00007ff714a3fecf MyProject.exe!PostProcessThreadSafe::RenderLensFlare() [D:\Documents\Unreal Projects\MyProject\Plugins\LensFlarePostProcess\Source\LensFlarePostProcess\Private\PostProcessThreadSafe.cpp:541]
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: [Callstack] 0x00007ff714a39b77 MyProject.exe!TBaseFunctorDelegateInstance<void __cdecl(FRDGBuilder &,FViewInfo const &,FLensFlareInputs const &,FLensFlareOutputsData &),FDefaultDelegateUserPolicy,<lambda_acb714239592ecf6c573c053c89744b7> >::ExecuteIfSafe() [Y:\Engines\UnrealEngine\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:847]
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: [Callstack] 0x00007ff7196ed8ef MyProject.exe!TMulticastDelegateBase<FDefaultDelegateUserPolicy>::Broadcast<IBaseDelegateInstance<void __cdecl(FRDGBuilder &,FViewInfo const &,FLensFlareInputs const &,FLensFlareOutputsData &),FDefaultDelegateUserPolicy>,TDelegate<void __cdecl(FRDGBuilder &,FViewInfo const &,FLensFlareInputs const &,FLensFlareOutputsData &),FDefaultDelegateUserPolicy>,FRDGBuilder &,FViewInfo const &,FLensFlareInputs const &,FLensFlareOutputsData &>() [Y:\Engines\UnrealEngine\Engine\Source\Runtime\Core\Public\Delegates\MulticastDelegateBase.h:178]
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: [Callstack] 0x00007ff7196f0bf5 MyProject.exe!AddLensFlaresPass() [Y:\Engines\UnrealEngine\Engine\Source\Runtime\Renderer\Private\PostProcess\PostProcessLensFlares.cpp:441]
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: [Callstack] 0x00007ff7196e8eb3 MyProject.exe!AddPostProcessingPasses() [Y:\Engines\UnrealEngine\Engine\Source\Runtime\Renderer\Private\PostProcess\PostProcessing.cpp:934]
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: [Callstack] 0x00007ff7188ebc75 MyProject.exe!FDeferredShadingSceneRenderer::Render() [Y:\Engines\UnrealEngine\Engine\Source\Runtime\Renderer\Private\DeferredShadingRenderer.cpp:3902]
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: [Callstack] 0x00007ff71936cc4a MyProject.exe!RenderViewFamilies_RenderThread() [Y:\Engines\UnrealEngine\Engine\Source\Runtime\Renderer\Private\SceneRendering.cpp:4390]
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: [Callstack] 0x00007ff7193401aa MyProject.exe!<lambda_d825e7d5a738e0bb6b7e834ee381bd9e>::operator()() [Y:\Engines\UnrealEngine\Engine\Source\Runtime\Renderer\Private\SceneRendering.cpp:4668]
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: [Callstack] 0x00007ff71935c83e MyProject.exe!TGraphTask<TEnqueueUniqueRenderCommandType<`FRendererModule::BeginRenderingViewFamilies'::`87'::FDrawSceneCommandName,<lambda_d825e7d5a738e0bb6b7e834ee381bd9e> > >::ExecuteTask() [Y:\Engines\UnrealEngine\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:1349]
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: [Callstack] 0x00007ff716eb3a84 MyProject.exe!FNamedTaskThread::ProcessTasksNamedThread() [Y:\Engines\UnrealEngine\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:760]
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: [Callstack] 0x00007ff716eb3f9e MyProject.exe!FNamedTaskThread::ProcessTasksUntilQuit() [Y:\Engines\UnrealEngine\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:649]
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: [Callstack] 0x00007ff71a6934b5 MyProject.exe!RenderingThreadMain() [Y:\Engines\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderingThread.cpp:416]
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: [Callstack] 0x00007ff71a696959 MyProject.exe!FRenderingThread::Run() [Y:\Engines\UnrealEngine\Engine\Source\Runtime\RenderCore\Private\RenderingThread.cpp:541]
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: [Callstack] 0x00007ff71753c422 MyProject.exe!FRunnableThreadWin::Run() [Y:\Engines\UnrealEngine\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:149]
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: [Callstack] 0x00007ff717534220 MyProject.exe!FRunnableThreadWin::GuardedRun() [Y:\Engines\UnrealEngine\Engine\Source\Runtime\Core\Private\Windows\WindowsRunnableThread.cpp:79]
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: [Callstack] 0x00007fface9926bd KERNEL32.DLL!UnknownFunction []
[2023.03.04-09.16.50:436][ 0]LogWindows: Error: [Callstack] 0x00007ffad046dfb8 ntdll.dll!UnknownFunction []
[2023.03.04-09.16.50:436][ 0]LogWindows: Error:
The game crash due GetResource(). The texture is not null and i check if the GetResource() output is not null.
Why is it crashing?
Thanks