#WindowCapture Crash in Editor Fixing .

1 messages · Page 1 of 1 (latest)

jolly flame
#

Pasting the contents of the chat where I was advised how to fix this

#
#if WITH_EDITOR
    FEditorDelegates::PrePIEEnded.AddWeakLambda(this, [this](const bool)
    {
        if (CaptureMachine)
        {
            CaptureMachine->Stop();
            CaptureMachine->Dispose();
            CaptureMachine = nullptr;
        }
    });
#endif
#

place that in the WindowCaptureWidget.cpp or other actors like it to avoid crashes

#

Note - you'll need to include UnrealEd in your build.cs and the windowcapture2d build.cs

#

It goes in the Public Section , also need to #include "Editor.h"

#

@hoary atlas sorry I know you hate threads lol but there is a new crash - the other one goes away at least - this is in the GenericPlatformMemory.h (this machine I'm using has 128 gb so It's not out of memory )

 
static FORCEINLINE void* Memcpy(void* Dest, const void* Src, SIZE_T Count)
    {
        return memcpy( Dest, Src, Count );
    }
#

vcruntime140.dll!00007ffddb0412db() Unknown

[Inline Frame] UnrealEditor-D3D12RHI.dll!FGenericPlatformMemory::Memcpy(void *) Line 564 C++
[Inline Frame] UnrealEditor-D3D12RHI.dll!FMemory::Memcpy(void *) Line 161 C++
UnrealEditor-D3D12RHI.dll!FD3D12Texture::UpdateTexture2D(FRHICommandListBase & RHICmdList, unsigned int MipIndex, const FUpdateTextureRegion2D & UpdateRegion, unsigned int SourcePitch, const unsigned char * SourceData) Line 2115 C++
UnrealEditor-D3D12RHI.dll!FD3D12DynamicRHI::RHIUpdateTexture2D(FRHICommandListBase & RHICmdList, FRHITexture * TextureRHI, unsigned int MipIndex, const FUpdateTextureRegion2D & UpdateRegion, unsigned int SourcePitch, const unsigned char * SourceData) Line 2280 C++
[Inline Frame] UnrealEditor-Engine.dll!FRHICommandListBase::UpdateTexture2D(FRHITexture *) Line 762 C++
[Inline Frame] UnrealEditor-Engine.dll!RHIUpdateTexture2D(FRHITexture *) Line 5328 C++
UnrealEditor-Engine.dll!UTexture2D::UpdateTextureRegions::__l44::<lambda_1>::operator()(FRHICommandListImmediate & RHICmdList) Line 1214 C++
UnrealEditor-Engine.dll!TEnqueueUniqueRenderCommandType<UTexture2D::UpdateTextureRegions'::44'::UpdateTextureRegionsDataName,UTexture2D::UpdateTextureRegions'::44'::<lambda_1>>::DoTask(ENamedThreads::Type CurrentThread, const TRefCountPtr<FGraphEvent> & MyCompletionGraphEvent) Line 209 C++
UnrealEditor-Engine.dll!TGraphTask<TEnqueueUniqueRenderCommandType<UTexture2D::UpdateTextureRegions'::44'::UpdateTextureRegionsDataName,UTexture2D::UpdateTextureRegions'::44'::<lambda_1>>>::ExecuteTask(TArray<FBaseGraphTask *,TSizedDefaultAllocator<32>> & NewTasks, ENamedThreads::Type CurrentThread, bool bDeleteOnCompletion) Line 1265 C++
[Inline Frame] UnrealEditor-Core.dll!FBaseGraphTask::Execute(TArray<FBaseGraphTask *,TSizedDefaultAllocator<32>> & CurrentThread, ENamedThreads::Type) Line 866 C++
UnrealEditor-Core.dll!FNamedTaskThread::ProcessTasksNamedThread(int QueueIndex, bool bAllowStall) Line 758 C++
UnrealEditor-Core.dll!FNamedTaskThread::ProcessTasksUntilQuit(int QueueIndex) Line 649 C++
UnrealEditor-RenderCore.dll!RenderingThreadMain(FEvent * TaskGraphBoundSyncEvent) Line 411 C++
UnrealEditor-RenderCore.dll!FRenderingThread::Run() Line 564 C++
UnrealEditor-Core.dll!FRunnableThreadWin::Run() Line 149 C++
UnrealEditor-Core.dll!FRunnableThreadWin::GuardedRun() Line 71 C++
[External Code]

#

.

hoary atlas
#

Haha it's ok. I'm just trying to herd cats kids atm

jolly flame
#

I'm trying to add this into the CaptureMachine.cpp because maybe that's what the system is built on?

#
#if WITH_EDITOR
    FEditorDelegates::PrePIEEnded.AddWeakLambda(this, [this](const bool)
    {
        if (CaptureMachine)
        {
            CaptureMachine->Stop();
            CaptureMachine->Dispose();
            CaptureMachine = nullptr;
        }
    });
#endif```
#
#include "CaptureMachine.h"
#include "Engine/Texture2D.h"
#include "Async/Async.h"
#include "Internationalization/Regex.h"
#include "Runtime/Core/Public/HAL/RunnableThread.h"
#include "../Private/Utils/WCWorkerThread.h"
#include "Editor.h"

#if PLATFORM_WINDOWS
#include <dwmapi.h>
#endif

UCaptureMachine::UCaptureMachine()
{
}

void UCaptureMachine::Start()
{
#if WITH_EDITOR
    FEditorDelegates::PrePIEEnded.AddWeakLambda(this, [this](const bool)
        {
            if (UCaptureMachine)
            {
                UCaptureMachine->Stop();
                UCaptureMachine->Dispose();
                UCaptureMachine = nullptr;
            }
        });
#endif

#if PLATFORM_WINDOWS
    
    CaptureWorkerThread = new FWCWorkerThread([this] { return DoCapture(); }, 1.0f / (float)Properties.FrameRate);
    CaptureThread = FRunnableThread::Create(CaptureWorkerThread, TEXT("UCaptureMachine CaptureThread"));
#endif
}```
#

when I try that, it tells me this crap, which is the fucking reason I stick to blueprint

#
1>C:\LiveSimDepotRoot\depot\Plugins\WindowCapture2D\Source\WindowCapture2D\Private\CaptureMachine.cpp(27): error C2059: syntax error: '->'
1>C:\LiveSimDepotRoot\depot\Plugins\WindowCapture2D\Source\WindowCapture2D\Private\CaptureMachine.cpp(28): error C2513: 'UCaptureMachine': no variable declared before '='
1>C:\LiveSimDepotRoot\depot\Plugins\WindowCapture2D\Source\WindowCapture2D\Private\CaptureMachine.cpp(30): error C2059: syntax error: '}'
1>C:\LiveSimDepotRoot\depot\Plugins\WindowCapture2D\Source\WindowCapture2D\Private\CaptureMachine.cpp(30): error C2143: syntax error: missing ';' before '}'```
wraith halo
#

@jolly flame Still here? I see the issue

#

Unless you have an actual pointer named 'UCaptureMachine', in case you do not have such a pointer, then you are just using the class name as a callable object, UCaptureMachine-> is wrong, and you won't be able to if () it either

#

if you want to copy your this pointer to be able to to nullptr check it that way, you'll need to assign it to a captured pointer

void UCaptureMachine::Start()
{
#if WITH_EDITOR
    FEditorDelegates::PrePIEEnded.AddWeakLambda(this, [ ThisMachine = this](const bool)
        {
            if (ThisMachine)
            {
                ThisMachine->Stop();
                ThisMachine->Dispose();
            }
        });
#endif

// ...
// ...
}

it will make it const however and if the Stop and Dispose functions are not marked const you can't do that and you will have to do as below and hope that your 'this' pointer is valid (or you could do as above but const-cast 'ThisMachine' into a non const local variable in the lambda to be able to call your intended functions via that)

void UCaptureMachine::Start()
{
#if WITH_EDITOR
    FEditorDelegates::PrePIEEnded.AddWeakLambda(this, [this](const bool)
        {
            this->Stop();
            this->Dispose();
        });
#endif

// ...
// ...
}
jolly flame
#

It's almost a bit beyond me I'm afraid...some basics like const that I never understood (at least in the context of how it would affect this)