Sascha-L / WPF-MediaKit

Microsoft Public License
367 stars 117 forks source link

System.AccessViolationException occurred in D3DRenderer #89

Open mi1124 opened 6 years ago

mi1124 commented 6 years ago

Hi,

I get the following exception in D3DRenderer in SetBackBufferInternal(): System.AccessViolationException occurred. An attempt was made to read or write in the protected memory. This is often an indication that other memory is corrupted.

StackTrace: bei MS.Win32.PresentationCore.UnsafeNativeMethods.InteropDeviceBitmap.Create(IntPtr d3dResource, Double dpiX, Double dpiY, UInt32 version, FrontBufferAvailableCallback pfnCallback, Boolean isSoftwareFallbackEnabled, SafeMILHandle& ppInteropDeviceBitmap, UInt32& pixelWidth, UInt32& pixelHeight) bei System.Windows.Interop.D3DImage.SetBackBuffer(D3DResourceType backBufferType, IntPtr backBuffer, Boolean enableSoftwareFallback) bei Vdi.VideoFramework.MediaPlayer.D3DRenderer.SetBackBufferInternal(IntPtr backBuffer) in D:\Sources\Repository\Main\Components\VideoFramework_2015\SourceCode\VideoFramework\MediaPlayer\D3DRenderer.cs:Zeile 387.

Any workaround for this exception?

xmedeko commented 6 years ago

Do you use EVR or VMR9 presenter?

Maybe it's a WPF bug, e.g. see https://social.msdn.microsoft.com/Forums/vstudio/en-US/621c4621-d494-4c02-8dd8-8b293e7b1ee1/access-violation-when-switching-monitor-mode?forum=wpf

mi1124 commented 6 years ago

Using EVR Presenter. The crash is only happening if TWO or more monitors are connected. It seems it doesnt happen if only one monitor is connected to the PC.

xmedeko commented 6 years ago

Try VMR9 presenter. IMHO it's better than WPF-MediaKit EVR presenter. (I do not think VMR9 is generally better than EVR, just this this implementation of EVR is not perfect.)

mi1124 commented 6 years ago

Sorry , it is not the number of monitors connected to the PC that is causing the crash. The code crashes at - D3DImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, backBuffer, true); with " Access Violation Exception in PresentationCore.dll. An attempt was made to read or write in the protected memory. This is often an indication that other memory is corrupted. "

Do you know how can I prevent backBuffer(i.e, pointer) from accessing protected memory?

xmedeko commented 6 years ago

It works for well for me and many others. You have either some other problem in your setup or you have hit some WPF bug. Try VMR9 renderer.

olivegamestudio commented 5 years ago

I'm having the same symptom (callstack crash). I have my videos set to VMR9 too.

I simply have a single screen setup, then whilst videos are playing plugin another screen to the setup and pop with an access violation.

xmedeko commented 5 years ago

How do play your videos on another screen? Can you reproduce the bug somehow with the Test Application? I use playing video on another screen - i.e. open WPF Window window on another screen with the player - and it works fine.

olivegamestudio commented 5 years ago

I have a couple of videos playing on the primary screen only. i dont put them on the secondary screen or move them at all. where can i find the test application?

xmedeko commented 5 years ago

You have written "then whilst videos are playing plugin another screen". Test Application: https://github.com/Sascha-L/WPF-MediaKit/tree/master/Test%20Application Also, try some other computer (with different graphics card), if you have dual or hybrid graphics card, try to switch to the other card.