Exceptions on Wake
#1
Hi,

I am having problems during wake up from a Laptop with an external monitor. I have occasionally seen similar issues with a Desktop when connecting via RDP when the DXEngine was already running in an existing window. I see the issue with the default GraphicsProfiles and when I set to NormalQualitySoftwareRendering. I can do a mini-application that I can send, but before I got too carried away I wondered if you had any initial ideas about where the problem is.

The problem can be simply that the DXViewportView is blank but sometimes all the controls on the window fail to redraw themselves although I think they may response to mouse messages.  The UI thread seems to be running - just no redraw.

Here is the information for the blank case.

From the VS Output panel:
Code:
Exception thrown: 'Ab3d.DirectX.DXEngineComException' in Ab3d.DXEngine.Wpf.dll
Exception thrown: 'Ab3d.DirectX.DXEngineException' in Ab3d.DXEngine.Wpf.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in System.Private.CoreLib.dll
Exception thrown: 'Ab3d.DirectX.DXEngineComException' in Ab3d.DXEngine.Wpf.dll
Exception thrown: 'Ab3d.DirectX.DXEngineException' in Ab3d.DXEngine.Wpf.dll
DXEngine Error:    D3DImage initialization failed inside DXImage.ProcessSizeChanged
    Cannot created DirectX 9 shared surface that is used to send DirectX 11 buffer to WPF
    DXEngineException
      at Ab3d.DirectX.Controls.D3D11ImageSource.InitializeBackBuffer(Texture2D dx11BackBuffer, Int32 width, Int32 height)
      at Ab3d.DirectX.Controls.DXImage.g(Int32 a, Int32 b)
      Inner exception:
      HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: The parameter is incorrect.

      DXEngineComException
              at n.a(Int32 a, Int32 b, UInt32 c, Int32 d, Int32 e, Int32 f, IntPtr& g)
        at Ab3d.DirectX.Controls.D3D11ImageSource.c(n a, Texture2D b, Int32 c, Int32 d)
        at Ab3d.DirectX.Controls.D3D11ImageSource.InitializeBackBuffer(Texture2D dx11BackBuffer, Int32 width, Int32 height)

This is from my logging file. You can see the screen resolution change to 1920x1057 followed by an exception.  Then the screen goes to  3413x1417 and you get a different set of exceptions. CubeView is the UserControl with the DXViewportView and "Fitting into View" is just the IFitIntoViewCamera.FitIntoView () call. The laptop is switching between these resolutions as it switches out of sleep.
Code:
2022-04-21 23:00:13.9533 | 1 | Info | Haystack.Explorer.App | Screen Changed to 1920x1057 | TRUMBJD
2022-04-21 23:00:14.2397 | 1 | Error | Haystack.Explorer.App | Exception has been thrown by the target of an invocation. | TRUMBJD
2022-04-21 23:00:14.2528 | 1 | Error | Haystack.Explorer.App |    at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
  at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
  at System.Delegate.DynamicInvokeImpl(Object[] args)
  at Microsoft.Win32.SystemEvents.SystemEventInvokeInfo.InvokeCallback(Object arg)
  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) | TRUMBJD
2022-04-21 23:00:15.2337 | 1 | Info | Haystack.Explorer.Features.DataAnalysis.Visualizations.SynthonCube.CubeView | CubeView Size Changed 706.5549999999998x759.8975 | TRUMBJD
2022-04-21 23:00:15.7575 | 1 | Info | Haystack.Explorer.Features.DataAnalysis.Visualizations.SynthonCube.CubeView | Fitting into View | TRUMBJD
2022-04-21 23:00:16.9116 | 1 | Info | Haystack.Explorer.App | Screen Changed to 3413x1417 | TRUMBJD
2022-04-21 23:00:18.2643 | 1 | Info | Haystack.Explorer.Features.DataAnalysis.Visualizations.SynthonCube.CubeView | CubeView Size Changed 1453.0549999999998x1029.8975 | TRUMBJD
2022-04-21 23:00:18.4669 | 1 | Info | Haystack.Explorer.Features.DataAnalysis.Visualizations.SynthonCube.CubeView | Fitting into View | TRUMBJD
2022-04-21 23:25:28.6162 | 1 | Info | Haystack.Explorer.Features.DataAnalysis.Visualizations.SynthonCube.CubeView | CubeView Size Changed 706.5549999999998x759.8975 | TRUMBJD
2022-04-21 23:25:28.8875 | 1 | Info | Haystack.Explorer.Features.DataAnalysis.Visualizations.SynthonCube.CubeView | Fitting into View | TRUMBJD
2022-04-21 23:25:30.0089 | 1 | Error | Haystack.Explorer.App | UCEERR_RENDERTHREADFAILURE (0x88980406) | TRUMBJD
2022-04-21 23:25:30.0089 | 1 | Error | Haystack.Explorer.App |    at System.Windows.Media.Composition.DUCE.Channel.SyncFlush()
  at System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean enableRenderTarget, Nullable`1 channelSet)
  at System.Windows.Interop.HwndTarget.UpdateWindowPos(IntPtr lParam)
  at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
  at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(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) | TRUMBJD
2022-04-21 23:25:30.1868 | 1 | Error | Haystack.Explorer.App | UCEERR_RENDERTHREADFAILURE (0x88980406) | TRUMBJD
2022-04-21 23:25:30.1913 | 1 | Error | Haystack.Explorer.App |    at System.Windows.Media.Composition.DUCE.Channel.SyncFlush()

The debug info on startup is here:
Code:
Visual Xccelerator Engine v6.5.1.26063
### GPU Capability Test ###
  Is BGRA feature required: TRUE

Examining Graphics Adapter: NVIDIA Quadro RTX 5000
  VRAM: 16170Mb
  DeviceId: 7861

  Visual Xccelerator Engine Direct3D9 Compatibility
    Determines whether the adapter is blacklisted due to its unstable work... FALSE
      Trying to create Direct3D9 Device... SUCCESS

  Visual Xccelerator Engine Direct3D11 Compatibility
      Trying to create Direct3D9Ex Device (WPF Compatibility)... SUCCESS
      Trying to create Direct3D11 Device... SUCCESS

  Rank: 3016170 Points

Examining Graphics Adapter: Microsoft Basic Render Driver
  VRAM: 0Mb
  DeviceId: 140

  Visual Xccelerator Engine Direct3D9 Compatibility
      Determines whether the adapter is blacklisted due to its unstable work... FALSE
      Trying to create Direct3D9 Device... SUCCESS

  Visual Xccelerator Engine Direct3D11 Compatibility
      Trying to create Direct3D9Ex Device (WPF Compatibility)... SUCCESS
      Trying to create Direct3D11 Device... SUCCESS

  Rank: 2000000 Points

Examining Graphics Adapter: Microsoft Basic Render Driver
  VRAM: 0Mb
  DeviceId: 140

  Visual Xccelerator Engine Direct3D9 Compatibility
      Determines whether the adapter is blacklisted due to its unstable work... FALSE
      Trying to create Direct3D9 Device... SUCCESS

  Visual Xccelerator Engine Direct3D11 Compatibility
      Trying to create Direct3D9Ex Device (WPF Compatibility)... SUCCESS
      Trying to create Direct3D11 Device... SUCCESS

  Rank: 2000000 Points

Selected Graphics Adapter, where DeviceId is: 7861
  Is Direct3D9 Supported: TRUE
  Is Direct3D11 Supported: TRUE
  Is Blacklisted: FALSE

**VisualXcceleratorEngine: SUCCESS!
'Haystack.Explorer.exe' (CoreCLR: clrhost): Loaded 'c9754357-f57f-445b-8e83-56d42bb353b7'.
VisualXcceleratorRenderSurface: attempt to initialize the engine with parameters:
  Use Direct3D9 - False

Thanks!
#2
Thank you for the reported problem. 
As you have found out, the multi-monitor setup works fine when using hardware rendering but when using software rendering the 3D scene does not redraw correctly (the D3DImage that is used to send the rendered 3D scene to WPF is not refreshed).

Waking up from sleep or changing the primary monitor should be handled by Windows, but also when using hardware rendering there are some cases when this is not done correctly without some additional "intervention" from DXEngine. It seems that some additional code will be needed to specially handle the case when using software rendering (hopefully it is possible to fix that, though the WPF's error UCEERR_RENDERTHREADFAILURE does not look good).

I am finishing the preparation for the next release of Ab3d.PowerToys and Ab3d.DXEngine. Anyway I will try to find the cause of this problem and include the fix into this release.+
Andrej Benedik
#3
Ab3d.DXEngine v5.1 that was released a few days ago was improved and can handle a few other cases where the operating system or WPF rendering engine have problems or got exceptions after changing the primary monitor.
Andrej Benedik
  


Forum Jump:


Users browsing this thread:
1 Guest(s)