AB4D Forum

Full Version: DXViewportView disappearing
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

We have the following issue with both our code and the DXEngine samples: if one clicks on a DXViewportView after its containing window has been minizied then maximized, that viewport is no longer displayed.

To reproduce:
- launch the DXEngine samples that come with the commercial version
- select the "frustum culling" samplen play around with the mouse a bit
- minimized the main window, then maximized it
- click on the viewport to try and rotate it => everything dissapears...

Any hint? This is a blocking issue for us.

Best Regards,
I cannot reproduce that. Also, I have never got a report of such an issue from any of my customers.

Therefore I would guess that you have a problem with your graphics card drivers or windows system.
Could you please check that and in case of older drivers update them.

If this will not help, please try the following:

You can also try to enable logging warnings to Visual Studio output window. This is done by the following code:

Ab3d.DirectX.DXDiagnostics.LogLevel = Ab3d.DirectX.DXDiagnostics.LogLevels.Warn;
Ab3d.DirectX.DXDiagnostics.IsWritingLogToOutput = true;

Then reproduce the issue and check if there is any line in Visual Studio Output window that starts with "DXEngine" text. This may indicate the cause of the problem.

You may also try to resize the application window - does that helps?

You may also try to use software rendering - run the samples project and in the settings select software rendering.

Run the application on some other computer.
Hello Andrej,
Many thanks for the quick answer and suggestions.
The driver are up-to- (latest stable drivers for the graphics card, and Nvidia Quadro 2000M).
As for your list of suggestions:
1/ Logging does not provide further information.
2/ Interestingly resizing the main window does partially help: the viewport is displayed correctly as soon the window begins to resize. However it disappears again as soon as one clicks on it... (FrustumCullingSample).
3/ This is not an option for us. Our app is originally WPF and we moved to AB3D.DXEngine for performance reasons (and we are happy with this choice).
4/ I will get another computer this week and will give it a try. However point 2/ above deserves a look I think.
Best Regards,
Hm, you always mention FrustumCullingSample - does this problem occur only for this sample or also for other samples.

With software rendering, I meant that you only try to reproduce the problem without using the graphics card - do this test only once and see if the problem still occurs. 

Because resizing still rendered the image, this means that when the RenderTragets (buffers that store the rendered image) are recreated they are shown, but when they are only updated, the image disappears. Maybe there are some problems with "sending" the DirectX rendering to WPF.

To get more info, I would ask you to test the following:

First, add the following code to FrustumCullingSample.xaml.cs after InitializeComponent:
            MainDXViewportView.DXSceneDeviceCreated += delegate(object sender, EventArgs args)
                if (MainDXViewportView.DXScene != null)
                    MainDXViewportView.DXScene.UseSharedWpfTexture = true;

This will use a different method (slower) to "send" DirectX 11 rendering to WPF - it will copy the rendered image to main CPU memory and there update a standard WPF bitmap that will be then shown by WPF (instead of using D3DImage that reuses the rendered image by WPF so that the rendered image can stay in the GPU memory).

Start the samples and check if the problem still exists.

The other test is to to open FrustumCullingSample.xaml and change line 23 from

This use completely different method of showing the 3D scene - it has a better performance but prevents adding WPF 3D objects on top of 3D scene (or behind the scene).

I would like to know if any of those two methods solve the problem.
I have tried both methods and, unfortunately none of them works.
The second one (DirectXOverlay) generates the following exception:

An unhandled exception of type 'SharpDX.SharpDXException' occurred in Ab3d.DXEngine.dll

Additional information: HRESULT: [0x887A0005], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_DEVICE_REMOVED/DeviceRemoved], Message: The GPU device instance has been suspended. Use GetDeviceRemovedReason to determine the appropriate action.

The good news is however that this issue is not reproduced on another, more recent computer.

Since the computer on which I have spotted the issue will be replaced soon we can wait until then.

Kind Regards,
It looks like for some reason the DirectX device is removed when you minimize the window. This should not happen - Windows OS should preserve the device even when the computer goes to sleep.

This indicates a problem with the system or a driver.

Anyway, I the future I plan to improve error handling in this case (calling GetDeviceRemovedReason to get a better reason for device removal). Also, there will be an event called in such a case - to handle such situations, the user will need to save the current state of the objects, then dispose all existing DXEngine / DirectX resources and recreate the scene from scratch.
To be more precise: the DXdevice error message pops up as soon as the FrustrumSample is started (upon exiting the contructor).
The full call stack is attached.
Have you tried to check version of DXEngine / Powertoys / etc.. to see if there are incompatible versions?
I solved an issue with disappearing WireGridVisual3D under some circumnstance due to incompatible versions.
Just try to remove reference and re-add it with latest versions.

Good luck

This is to confirm this issue is not reproduced on my new laptop and can therefore be closed.
For some reason the most recent driver on my old laptop (where problem happens) is buggy despite being up-to-date.