sskodje / ScreenRecorderLib

A .NET library for screen recording in Windows, using native Microsoft Media Foundation for realtime encoding to h264 video or PNG images.
MIT License
414 stars 94 forks source link

INVALID_POINTER_READ when trying to run my application using screenrecorderlib in remote vm #319

Closed KandhanSekar closed 4 days ago

KandhanSekar commented 1 month ago

I run screenrecorderlib latest version as a part of my application but my application runs automated in a vm as a cloudtest and in such remote runs i see that screenrecorderlib consistently crashes due to invalid pointer read.

I do not have the logs for screenrecorderlib even though i have log enabled, probably because the crash happens before any file is written. ( This probably also might be helpful - as in write logs as and when they are available) When i log into the vm and run my application manually everything works as expected and i do not have any more information other than the dump below. Could this be because the vm run does not have any displays or monitors?

msvcp140!mtx_do_lock+0x74 [f:\dd\vctools\crt\crtw32\stdcpp\thr\mutex.c @ 99] screenrecorderlib!Concurrency::task_completion_eventunsigned char::set+0x63 [C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.40.33807\include\ppltasks.h @ 2441] screenrecorderlib!Concurrency::task_from_result+0xd9 [C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.40.33807\include\ppltasks.h @ 7076] screenrecorderlib!std::make_uniqueRecordingManager::TaskWrapper,0+0x5a [C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.40.33807\include\memory @ 3595] screenrecorderlib!RecordingManager::RecordingManager+0x35 [C:__w\1\s\library\ScreenRecorderLib\ScreenRecorderLibNative\RecordingManager.cpp @ 69] presentationcore!DomainBoundILStubClass.IL_STUB_PInvoke+0x6e screenrecorderlib!ScreenRecorderLib::Recorder::Recorder+0xb1 screenrecorderlib!ScreenRecorderLib::Recorder::CreateRecorder+0x26

sskodje commented 1 month ago

Is the cloudtest software running in a service? The library needs to run in a desktop, due to windows security reasons.

KandhanSekar commented 1 month ago

@sskodje can you clarify what do you mean as running in a service?

Also, has the screenrecorderlib been tested with a vm that isnt connected to a remote display? is it expected to work with just virtual monitors ?

sskodje commented 1 month ago

If the software runs as a Windows service, and not a desktop program. If it runs as a service, all access to the video output is blocked by Windows for security reasons. Virtual monitors should work just fine, as long as it is run in the virtual desktop. The caveat is that if you remote in to the VM with remote desktop, and then closes the connection, the virtual monitor is uninstalled and the recording stops. A running VM with nobody remoting in is thus regarded as having no video output as far as i know, and not recordable.