Player loses fullscreen

I’m currently working on a standalone application which has to run fullscreen for several days. While running my machine overnight with the application I experience that in the morning the application has left fullscreen and switched from FullHD (1080p) to HDReady (720p). As the machine the application has to run will be not accessible without enourmous effort just restarting the whole thing is no solution.

I checked the logs and at some point the application starts to spam the following message:

HandleD3DDeviceLost
  HandleD3DDeviceLost: still lost
Skipped rendering frame because GfxDevice is in invalid state (device lost)
 
(Filename:  Line: 1494)

[… this repeats alot …]

HandleD3DDeviceLost
  HandleD3DDeviceLost: still lost
Skipped rendering frame because GfxDevice is in invalid state (device lost)
 
(Filename:  Line: 1494)

HandleD3DDeviceLost
  HandleD3DDeviceLost: still lost
d3d: failed to lock level 0 of texture 115 [invalid call]
d3d: failed to lock level 0 of texture 117 [invalid call]
d3d: failed to lock level 0 of texture 119 [invalid call]
d3d: failed to lock level 0 of texture 121 [invalid call]
d3d: failed to lock level 0 of texture 123 [invalid call]
d3d: failed to lock level 0 of texture 125 [invalid call]
Skipped rendering frame because GfxDevice is in invalid state (device lost)
 
(Filename:  Line: 1494)

HandleD3DDeviceLost
  HandleD3DDeviceLost: needs reset, doing it
FullResetD3DDevice
ResetD3DDevice
dev->Reset
D3Dwindow device not lost anymore
Skipped rendering frame because GfxDevice is in invalid state (device lost)
 
(Filename:  Line: 1494)

HandleD3DDeviceLost
  HandleD3DDeviceLost: still lost
Skipped rendering frame because GfxDevice is in invalid state (device lost)
 
(Filename:  Line: 1494)

[… again this repeats alot …]

HandleD3DDeviceLost
  HandleD3DDeviceLost: still lost
Skipped rendering frame because GfxDevice is in invalid state (device lost)
 
(Filename:  Line: 1494)

I also checked Windows’ error log but it didn’t logged anything of importance. I also checked this thread from the forum, with no success.

Do you have any ideas how to fix this or at least how to handle this error properly.

Sounds like Windows is powering down your GPU device, although I can’t be certain from what you have said.

In Windows, if the device is powered down, then powered up again, you will have to reacquire the device and reinit. (see PowerModeChanged event on MSDN)

After reading the post you cited, I find it hard to believe that using multiple threads is going to lose your device. Sounds like a bit of a goose chase.

Have you tried putting the machine into sleep/standby and then waking again? The test would take ~20 seconds and would probably reproduce the error you see.

But again, it’s hard to tell from what you’ve mentioned.

I didn’t solve the problem, but I’m now using a workaround which checks if the application has left fullscreen or changed it’s full resolution and if this happened restores both.

using UnityEngine;

public class ResolutionChecker : MonoBehaviour {

	public bool ForceFullscreen = true;

	void Start() {
		if (Application.isEditor)
			ForceFullscreen = false;
	}

	void Update() {
		if (ForceFullscreen && (Screen.width!=Screen.currentResolution.width || !Screen.fullScreen))
			Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, true);
	}
}

If you have another suggestion how to fix the actual error or how it could be handled please post it…

I also found the real reason for this error: The monitor was sending a signal it has been turned off after some time of inactivity. This leads to Windows powering down the GPU as no output device is present (a behaviour which cannot be disabled). The solution was to use an modified adapter which doesn’t transmit this signal. This solution originated from Microsoft Technet.