Crash on restore from sleep/hibernate (Direct3D rendering)

Problems building or running the engine, queries about how to use features etc.
Post Reply
zanir
Gnoblar
Posts: 4
Joined: Fri Jul 02, 2010 9:58 am

Crash on restore from sleep/hibernate (Direct3D rendering)

Post by zanir »

Hi, I'm getting crash on restore from sleep/hibernate mode. It crashes only if program run in full scrren mode. Ogre log:

Code: Select all

16:58:44: !!! Direct3D Device Lost!
16:58:44: Releasing D3D9 default pool texture: Ogre/ShadowTexture0
16:58:44: Released D3D9 default pool texture: Ogre/ShadowTexture0
16:58:44: D3D9TextureManager released:
16:58:44: 1 unmanaged textures
16:58:44: D3D9HardwareBufferManager released:
16:58:44: 2 unmanaged vertex buffers
16:58:44: 0 unmanaged index buffers
16:58:44: OGRE EXCEPTION(3:RenderingAPIException): Error Presenting surfaces in D3D9RenderWindow::swapBuffers at d:\Ogre 1.6.5\RenderSystems\Direct3D9\src\OgreD3D9RenderWindow.cpp (line 828)
There is exception which is showed because mpD3DDevice->Present( NULL, NULL, NULL, NULL ); returned 0x8876086c which means:

Code: Select all

The HRESULT: 0x8876086c (2289436780):
Name: D3DERR_INVALIDCALL
Description: Invalid call
Severity code: Failed
Facility Code: FACILITY_D3D (2166)
Error Code: 0x086c (2156)
Direct3D logging gives message:

Code: Select all

Direct3D9: (ERROR) :Lost due to display uniqueness change
The program can successfully restore device lost after Alt-Tab. I'm using Ogre 1.6.5. It crashes on Windows 7, but it works on Windows XP.

Have you any idea what can be wrong or how fix it? Thanks.
zanir
Gnoblar
Posts: 4
Joined: Fri Jul 02, 2010 9:58 am

Re: Crash on restore from sleep/hibernate (Direct3D renderin

Post by zanir »

I found out, that if I ignore this exception and continue the same way as normal device lost then restore is successfully processed.

"The fix" is:

Code: Select all

void D3D9RenderWindow::swapBuffers( bool waitForVSync )
...
old code:
			if( D3DERR_DEVICELOST == hr )
			{
				SAFE_RELEASE(mpRenderSurface);

				static_cast<D3D9RenderSystem*>(
					Root::getSingleton().getRenderSystem())->_notifyDeviceLost();
			}
new code:
			if( D3DERR_DEVICELOST == hr ||
				 D3DERR_INVALIDCALL == hr )			// Direct3D9: (ERROR) :Lost due to display uniqueness change
			{
				SAFE_RELEASE(mpRenderSurface);

				static_cast<D3D9RenderSystem*>(
					Root::getSingleton().getRenderSystem())->_notifyDeviceLost();
			}
But I still getting crash on restore from sleep/hibernate, but on different places. One somewhere in message manager, second during locking of VB.

I try to disable rendering between PBT_APMSUSPEND and PBT_APMRESUMESUSPEND window messages, but I cannot get these messages ..., probably there is something with win32 window creating that these messages are not sending into the window.
Last edited by zanir on Wed Jul 18, 2012 3:58 pm, edited 1 time in total.
zanir
Gnoblar
Posts: 4
Joined: Fri Jul 02, 2010 9:58 am

Re: Crash on restore from sleep/hibernate (Direct3D renderin

Post by zanir »

Discoveries found out my colleague:
- PBT_APMSUSPEND and PBT_APMRESUMESUSPEND messages are sending, but not always, it seems that it is depended on CPU usage
- logging into log file on PBT_APMSUSPEND is not working, probably it is blocked or not performed by Windows until sleep
Ixuss
Gnoblar
Posts: 12
Joined: Fri Dec 13, 2013 4:39 pm
Location: Belarus

Re: Crash on restore from sleep/hibernate (Direct3D renderin

Post by Ixuss »

Today, I also encountered this problem. Ogre 1.9.
Are there any solutions?
Post Reply