Monogame: [UWP] Disabling V-Sync crashes MG

Created on 24 Oct 2017  路  13Comments  路  Source: MonoGame/MonoGame

Setting graphics.SynchronizeWithVerticalRetrace to false causes MG to crash.

DirectX Good First Issue Help Wanted Windows 10 UWP

Most helpful comment

This is still happening apparently ... can I try to contribute to fix this issue? Based on the comment done by Chuck Walbourn: https://stackoverflow.com/questions/45071415/how-can-i-disable-vsync-in-uwp

All 13 comments

UWP does not support turning vsync off at all. MonoGame should just ignore the flag on this platform.

Setting graphics.SynchronizeWithVerticalRetrace to false causes MG to crash.

Hi @zigzag312 .

Can you be more specific? Can you share the code that crashes? Can you give us the crash callstack?

The code behind GraphicsDeviceManager.SynchronizeWithVerticalRetrace just flips a bool. That by itself should not crash.

This line fails: https://github.com/MonoGame/MonoGame/blob/bd59328676004e6183b415dad98d91ae0b06e66a/MonoGame.Framework/Graphics/GraphicsDevice.DirectX.cs#L352

Exception message:

"HRESULT: [0x887A0001], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_INVALID_CALL/InvalidCall], 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."

It seems that V-Sync support was added to UWP last year
https://stackoverflow.com/questions/45071415/how-can-i-disable-vsync-in-uwp
https://blogs.msdn.microsoft.com/directx/2016/05/10/unlocked-frame-rate-and-more-now-enabled-for-uwp/

To reproduce create new UWP project and add graphics.SynchronizeWithVerticalRetrace = false; inside Game1 constructor.

Thanks @zigzag312 !

I added quick fix in #6024
@tomspilman should I close this issue and open new one, something like "UWP Disabling V-Sync not supported/implemented" for further reference?

On develop i'm still getting a not so good error exception:

Microsoft.Xna.Framework.Graphics.NoSuitableGraphicsDeviceException
at GraphicDeviceManager line 122

With inner exception:
{"HRESULT: [0x887A0001], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_INVALID_CALL/InvalidCall], Message: The application made a call that is invalid. Either the parameters of the call or the state of some object was incorrect.\r\nEnable the D3D debug layer in order to see details via debug messages.\r\n"}

@Eversor the bugfix hasn't been merged into develop yet. Can you test #6024 if it works for you?

Sorry, i'm not in the monogame development team, but wouldn't it be better to have a NotImplemented exception risen when VSync is turned off instead of keeping it on against the will of the developer?

Sorry, i'm not in the monogame development team

It's an open source project, feel free to give any suggestions for design :) I think you make a good point.

This is still happening apparently ... can I try to contribute to fix this issue? Based on the comment done by Chuck Walbourn: https://stackoverflow.com/questions/45071415/how-can-i-disable-vsync-in-uwp

Are you using CoreApp or XAML template?

It works on CoreApp from my perspective.

CoreApp. If I do a graphics.SynchronizeWithVerticalRetrace = false, it doesn't even get to the Initialize method, it closes the window.

From what I debugged, the actual issue for that crash is that
_DXGI ERROR: IDXGIFactory::CreateSwapChainForCoreWindow: CoreWindow SwapChains only support the DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL and DXGI_SWAP_EFFECT_FLIP_DISCARD swap effect. [ MISCELLANEOUS ERROR #190: ]_

This is because on the SharpDXHelper:

case PresentInterval.Immediate:
      effect = SharpDX.DXGI.SwapEffect.Sequential;

As the error from above says, UWP only supports the flip_* flags. Fixing this will probably fix the crash, but the vsync would still be enabled anyway, I believe ...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Legendree picture Legendree  路  3Comments

monsieurmax picture monsieurmax  路  5Comments

Jjagg picture Jjagg  路  5Comments

tomspilman picture tomspilman  路  4Comments

Ellesent picture Ellesent  路  5Comments