ayumax / WindowCapture2D

Library for capturing and displaying windows in real time with UnrealEngine
MIT License
63 stars 22 forks source link

Plugin cleanup UCaptureMachine::Close() is not thread safe #2

Closed jimsimonz closed 4 years ago

jimsimonz commented 4 years ago

The texture target is deleted at a time when the docapture is running in another thread during close.

This causes crashes in the renderer as the texture gets killed during render. As it's multithreaded this is occasional.

Changing the close order to below is better as it kills the thread before destroying the texture. Also the texture needed nulling.

```

if (CaptureThread) { CaptureThread->Kill(true); CaptureThread->WaitForCompletion();

    delete CaptureThread;
    CaptureThread = nullptr;
}
if (TextureTarget)
{
    TextureTarget->ReleaseResource();
    TextureTarget = nullptr;
}
jimsimonz commented 4 years ago

Thanks for the plugin though it's great :)

ayumax commented 4 years ago

Thank you for the suggestion.

After applying the proposed correction, I will confirm the operation.

ayumax commented 4 years ago

Thank you for the report. I've fixed it in the lateset version: https://github.com/ayumax/WindowCapture2D/releases/tag/v1.0.1

jimsimonz commented 4 years ago

Great thanks.