freezy / dmd-extensions

A toolbox for virtual pinball dot matrix displays.
GNU General Public License v2.0
127 stars 54 forks source link

Mirroring screen to virtual dmd crashes since v1.10.0 works fine in v1.9.0 #357

Closed joyrider3774 closed 1 year ago

joyrider3774 commented 1 year ago

Hi,

Mirroring the screen to a virtual dmd crashes since version 1.10.0 and up for me. The last version this worked in for me was version 1.9.0

V1.9.0 works fine

C:\Users\joyri>"C:\temp\dmdext\dmdext.exe" mirror --source=screen --position=0 0 1080 97 --destination=virtual --virtual-stay-on-top --virtual-position=2104 0 1024 300
 [1] 2023/02/26 22:45:00.082  INFO | Launching console tool v1.9.0 ()
 [1] 2023/02/26 22:45:00.262  INFO | Added virtual DMD renderer.
 [1] 2023/02/26 22:45:00.262  INFO | Setting up Render Graph for 1 destination(s)
 [1] 2023/02/26 22:45:00.278  INFO | Connecting Screen Grabber to Dmd (Bitmap => Bitmap)
 [1] 2023/02/26 22:45:00.311  INFO | Press CTRL+C to close.
 [1] 2023/02/26 22:45:00.742  INFO | Creating FBOs for 128x32

V1.10.0 and up results in crashes, here is the stack trace

C:\Users\joyri>"C:\temp\dmdext\dmdext.exe" mirror --source=screen --position=0 0 1080 97 --destination=virtual --virtual-stay-on-top --virtual-position=2104 0 1024 300
 [1] 2023/02/26 22:46:51.102  INFO | Launching console tool v1.10.0 ()
 [1] 2023/02/26 22:46:51.284  INFO | Added virtual DMD renderer.
 [1] 2023/02/26 22:46:51.295  INFO | Setting up Render Graph for 1 destination(s)
 [1] 2023/02/26 22:46:51.306  INFO | Connecting Screen Grabber to Dmd (Bitmap => Bitmap)
 [1] 2023/02/26 22:46:51.338  INFO | Press CTRL+C to close.
 [1] 2023/02/26 22:46:51.338  INFO | Resizing virtual DMD to 1080x97
 [1] 2023/02/26 22:46:51.783  INFO | Creating FBOs for 1080x97

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at LibDmd.Output.Virtual.Dmd.VirtualDmdControl.glTexSubImage2D(UInt32 target, Int32 level, Int32 xoffset, Int32 yoffset, Int32 width, Int32 height, UInt32 format, UInt32 type, IntPtr pixels)
   at LibDmd.Output.Virtual.Dmd.VirtualDmdControl.ogl_OpenGLDraw(Object sender, OpenGLRoutedEventArgs args) in C:\Development\dmd-extensions\LibDmd\Output\Virtual\Dmd\VirtualDmdControl.xaml.cs:line 485
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Windows.RoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at LibDmd.Output.Virtual.Dmd.OpenGLControlExt.DoRender() in C:\Development\dmd-extensions\LibDmd\Output\Virtual\Dmd\OpenGLControlExt.xaml.cs:line 198
   at LibDmd.Output.Virtual.Dmd.OpenGLControlExt.<RequestRender>b__16_0() in C:\Development\dmd-extensions\LibDmd\Output\Virtual\Dmd\OpenGLControlExt.xaml.cs:line 177
   at System.Windows.Threading.DispatcherOperation.InvokeDelegateCore()
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at DmdExt.DmdExt.Main(String[] args)

C:\Users\joyri>

Latest version V1.10.2 procedues same error

C:\Users\joyri>"C:\temp\dmdext\dmdext.exe" mirror --source=screen --position=0 0 1080 97 --destination=virtual --virtual-stay-on-top --virtual-position=2104 0 1024 300
 [1] 2023/02/26 22:51:07.361  INFO | Launching console tool v1.10.2
 [1] 2023/02/26 22:51:07.562  INFO | Added virtual DMD renderer.
 [1] 2023/02/26 22:51:07.562  INFO | Setting up Render Graph for 1 destination(s)
 [1] 2023/02/26 22:51:07.582  INFO | Connecting Screen Grabber to Dmd (Bitmap => Bitmap)
 [1] 2023/02/26 22:51:07.615  INFO | Press CTRL+C to close.
 [1] 2023/02/26 22:51:07.615  INFO | Resizing virtual DMD to 1080x97
 [1] 2023/02/26 22:51:08.059  INFO | Creating FBOs for 1080x97

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at LibDmd.Output.Virtual.Dmd.VirtualDmdControl.glTexSubImage2D(UInt32 target, Int32 level, Int32 xoffset, Int32 yoffset, Int32 width, Int32 height, UInt32 format, UInt32 type, IntPtr pixels)
   at LibDmd.Output.Virtual.Dmd.VirtualDmdControl.ogl_OpenGLDraw(Object sender, OpenGLRoutedEventArgs args) in C:\Development\dmd-extensions\LibDmd\Output\Virtual\Dmd\VirtualDmdControl.xaml.cs:line 502
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Windows.RoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at LibDmd.Output.Virtual.Dmd.OpenGLControlExt.DoRender() in C:\Development\dmd-extensions\LibDmd\Output\Virtual\Dmd\OpenGLControlExt.xaml.cs:line 198
   at LibDmd.Output.Virtual.Dmd.OpenGLControlExt.<RequestRender>b__16_0() in C:\Development\dmd-extensions\LibDmd\Output\Virtual\Dmd\OpenGLControlExt.xaml.cs:line 177
   at System.Windows.Threading.DispatcherOperation.InvokeDelegateCore()
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at DmdExt.DmdExt.Main(String[] args)
CarnyPriest commented 1 year ago

Confirmed. I came to report a bug and found the issue already reported here. No public releases from v1.10.0 to v2.0 successfully grabs screen and mirrors to virtual. I have a similar trace.

freezy commented 1 year ago

Thanks to @GyroJoe, this is fixed! Test build is here.

joyrider3774 commented 1 year ago

thanks guys tested and works fine again