Some of my player get a strange error and i don’t know why…

Exception caught:
HRESULT: [0x887A0001],
Module: [SharpDX.DXGI],
Message: The application made a call that is invalid. Either the parameters of the call or the state of some object was incorrect.
Enable the D3D debug layer in order to see details via debug messages.

This message is trowed by: GraphicsDeviceManager.ApplyChanges()

at SharpDX.Result.CheckError()
at SharpDX.DXGI.SwapChain.ResizeBuffers(Int32 bufferCount, Int32 width, Int32 height, Format newFormat, SwapChainFlags swapChainFlags)
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.CreateSizeDependentResources()
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Reset()
at .() in 127\Settings.cs:line 88

I use MonoGame, the DirectX template with HiDef profile.

The issue happened on those graphics cards:

Radeon RX 580 Series
GeForce GTX 980 Ti
NVIDIA GeForce GTX 1070 Ti 
GeForce GTX 1080 - GeForce GTX 1080
NVIDIA GeForce RTX 2070

Another similar one this time at Game.Run():

Exception caught:
HRESULT: [0x887A0001],
Module: [SharpDX.DXGI],
Message: Unknown
	at SharpDX.Result.CheckError()
	at SharpDX.DXGI.SwapChain.GetFullscreenState(RawBool& fullscreenRef, Output& targetOut)
	at SharpDX.DXGI.SwapChain.get_IsFullScreen()
	at Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformDispose()
	at Microsoft.Xna.Framework.Graphics.GraphicsDevice.Dispose(Boolean disposing)
	at Microsoft.Xna.Framework.GraphicsDeviceManager.Dispose(Boolean disposing)
	at Microsoft.Xna.Framework.Game.Dispose(Boolean disposing)
	at Microsoft.Xna.Framework.Game.Dispose()
	at .() in 127\Program.cs:line 464

For most players everything works fine but some of them still get this errors and apparently their computer is up to date.

An idea of where this issue can come from?

looks a bit like you’re trying to use resources which are no longer there (device reset, device lost or something)

I’m not sure. the exception thrown by ApplyChanges happen during startup of the game, no resources has been disposed at this moment.

Are you running the game fullscreen? and if yes then did you set the preferred backbuffer size to one of the supported values from Adapter.Modes?

No, the game is not in fullscreen but i will try to set the preferred backbuffer anyway maybe it will help thanks!

By default the resolution is set to 1280x720 in window mode.

this errors keep happening, I do not understand what is wrong… :worried:

I remember there was an issue with ApplyChanges on DX platforms.

Are you calling ApplyChanges() inside the Game() constructor?
Try not to call ApplyChanges until after Game.Initialize() is called and after you call base.Initialize().
Maybe that would help.

Also, show us you initialization code.
Maybe you are requesting a surface type or a multisample level that is not supported on those cards.

I had a problem which looked like this in WP8 a looong time ago (I mean, it’s not the same problem at all, but also was a SharpDX/DXGI problem). And I had tons, however they seemed to be always transitory.

What I did back then was to slightly modify MonoGame to print extra information of the error when happened.

In your case, I’d modify monogame so that when it founds this error, it also prints several parameters which could cause the problem into the exception. As you’re calling SwapChain.ResizeBuffers, in example, I’d add to the exception message the parameters widht, height and newFormat (actually it’s easy to just add them all)

That won’t fix the problem, but will give you a better insight of the problem (in example, when starting it could be that width,height are 0 for some reason and then fails to allocate a surface), then try to figure a solution with better information.

p.s. back then I didn’t find the problem, but I think it was a good idea :wink:

Here how the game initialize:

    protected override void Initialize() {
        // Load settings, init steamAPI, language files etc...
	// start second thread for the game, close splash screen

I will remove the ApplySettings at the end and make sure it start in the first Update().

@KakCAT maybe I would do this if nothing else works

I found a solution.

If I do a GraphicsDevice.Reset() before GraphicsDeviceManager.ApplyChanges() it works as expected.

It is safe to reset the GraphicsDevice like that ?

I wonder why certain computer must have their graphics reseted while most computer don’t.

1 Like

the links below have relevant details. here are some quotes.

Step 2:
Also, include a check for the device removed error when responding to window size changes.
This is a good place to check for DXGI_ERROR_DEVICE_REMOVED or DXGI_ERROR_DEVICE_RESET for several reasons:
Resizing the swap chain requires a call to the underlying DXGI adapter, which can return the device removed error.
The app might have moved to a monitor that’s attached to a different graphics device.When a graphics device is removed or reset, the desktop resolution often changes, resulting in a window size change.

It is safe to reset the GraphicsDevice like that ?

Reset is the only method that has an effect when a device is
lost, and is the only method by which an application can change the
device from a lost to an operational state.

Responding to a Lost Device
A lost device must re-create resources (including video memory resources) after it has been reset.
If a device is lost, the application queries the device to see if it can be restored to the operational state.
If not, the application waits until the device can be restored. If the device can be restored, the application
prepares the device by destroying all video-memory resources and any swap chains.
Then, the application calls the IDirect3DDevice9::Reset method.

You are encouraged to develop applications with a single code path to respond to device loss.
This code path is likely to be similar, if not identical, to the code path taken to initialize the device at startup.
In Direct3D 9, vertex shaders and pixel shaders don’t need to be
re-created after reset. They will be remembered.