Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXCEPTION_ACCESS_VIOLATION occurs when CheckWindowSize is checked and the target window is resized repeatedly #5

Open
mechamogera opened this issue Feb 13, 2020 · 2 comments

Comments

@mechamogera
Copy link

mechamogera commented Feb 13, 2020

I found that UE4 crashes with EXCEPTION_ACCESS_VIOLATION when CheckWindowSize is checked and repeated resizing of the target window.

Reproduction steps

  1. Create New UE4.24.2 project and enable WindowCapture2D plugin
  2. Place WindowCapturePlane in the world
  3. Check CheckWindowSize and change CaptureTargetTitle on WindowCapturePlane
  4. Play the project
  5. Resize target window repeatedly

Crash message is

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x08cad000

nvwgf2umx
d3d11
UE4Editor_D3D11RHI!FD3D11DynamicRHI::RHIUpdateTexture2D() [d:\build\++ue4\sync\engine\source\runtime\windows\d3d11rhi\private\d3d11texture.cpp:1805]
UE4Editor_D3D11RHI!FD3D11DynamicRHI::UpdateTexture2D_RenderThread() [d:\build\++ue4\sync\engine\source\runtime\windows\d3d11rhi\private\d3d11texture.cpp:1830]
UE4Editor_Engine!<lambda_d3c33e5a8b9daf3a9ced0d8a29defb66>::operator()() [d:\build\++ue4\sync\engine\source\runtime\engine\private\texture2d.cpp:1417]
UE4Editor_Engine!TGraphTask<TEnqueueUniqueRenderCommandType<`UTexture2D::UpdateTextureRegions'::`34'::UpdateTextureRegionsDataName,<lambda_d3c33e5a8b9daf3a9ced0d8a29defb66> > >::ExecuteTask() [d:\build\++ue4\sync\engine\source\runtime\core\public\async\taskgraphinterfaces.h:847]
UE4Editor_Core!FNamedTaskThread::ProcessTasksNamedThread() [d:\build\++ue4\sync\engine\source\runtime\core\private\async\taskgraph.cpp:686]
UE4Editor_Core!FNamedTaskThread::ProcessTasksUntilQuit() [d:\build\++ue4\sync\engine\source\runtime\core\private\async\taskgraph.cpp:583]
UE4Editor_RenderCore!RenderingThreadMain() [d:\build\++ue4\sync\engine\source\runtime\rendercore\private\renderingthread.cpp:340]
UE4Editor_RenderCore!FRenderingThread::Run() [d:\build\++ue4\sync\engine\source\runtime\rendercore\private\renderingthread.cpp:471]
UE4Editor_Core!FRunnableThreadWin::Run() [d:\build\++ue4\sync\engine\source\runtime\core\private\windows\windowsrunnablethread.cpp:96]
@mechamogera
Copy link
Author

The following code change worked for me.
But i don't understand well.

diff --git a/mnt/d/Program Files/Epic Games/UE_4.24/Engine/Plugins/Marketplace/WindowCapture2D/Source/WindowCapture2D/Private/CaptureMachine.cpp b/WindowCapture2D/Source/WindowCapture2D/Private/CaptureMachine.cpp
index 2fba183..f597966 100755
--- a/mnt/d/Program Files/Epic Games/UE_4.24/Engine/Plugins/Marketplace/WindowCapture2D/Source/WindowCapture2D/Private/CaptureMachine.cpp
+++ b/WindowCapture2D/Source/WindowCapture2D/Private/CaptureMachine.cpp
@@ -82,6 +82,7 @@ bool UCaptureMachine::DoCapture()
 #if PLATFORM_WINDOWS
        if (!m_TargetWindow) return true;
        if (!TextureTarget) return true;
+       if (!m_IsUpdatedTexture) return true;

        if (Properties.CheckWindowSize)
        {
@@ -198,8 +199,12 @@ void UCaptureMachine::UpdateTexture()
 #if PLATFORM_WINDOWS
        if (!TextureTarget) return;

+       m_IsUpdatedTexture = false;
        auto Region = new FUpdateTextureRegion2D(0, 0, 0, 0, TextureTarget->GetSizeX(), TextureTarget->GetSizeY());
-       TextureTarget->UpdateTextureRegions(0, 1, Region, 4 * TextureTarget->GetSizeX(), 4, (uint8*)m_BitmapBuffer);
+       auto Func = [this](uint8* SrcData, const FUpdateTextureRegion2D* Regions) {
+               this->m_IsUpdatedTexture = true;
+       };
+       TextureTarget->UpdateTextureRegions(0, 1, Region, 4 * TextureTarget->GetSizeX(), 4, (uint8*)m_BitmapBuffer, Func);
 #endif
 }

diff --git a/mnt/d/Program Files/Epic Games/UE_4.24/Engine/Plugins/Marketplace/WindowCapture2D/Source/WindowCapture2D/Public/CaptureMachine.h b/WindowCapture2D/Source/WindowCapture2D/Public/CaptureMachine.h
index 0a39c38..6941309 100755
--- a/mnt/d/Program Files/Epic Games/UE_4.24/Engine/Plugins/Marketplace/WindowCapture2D/Source/WindowCapture2D/Public/CaptureMachine.h
+++ b/WindowCapture2D/Source/WindowCapture2D/Public/CaptureMachine.h
@@ -62,6 +62,8 @@ private:
        FIntVector2D m_OriginalWindowSize;
        FIntVector2D m_WindowOffset;

+       bool m_IsUpdatedTexture = true;
+
        class FWCWorkerThread* CaptureWorkerThread = nullptr;
        class FRunnableThread* CaptureThread = nullptr;
 };

@ayumax
Copy link
Owner

ayumax commented Feb 14, 2020

Thank you for reporting the phenomenon. I will investigate the cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants