Search Unity

HandleD3DDeviceLost

Discussion in 'Editor & General Support' started by jdyeager, Mar 5, 2012.

  1. jdyeager

    jdyeager

    Joined:
    Aug 18, 2008
    Posts:
    29
    Hi All,

    We're seeing the following error when running our game on OSX machines running Windows 7 (BootCamp):

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

    Graphics info for the machines is:

    Direct3D:
    Version: Direct3D 9.0c [nvd3dum.dll 8.16.11.8861]
    Renderer: NVIDIA GeForce 9400
    Vendor: NVIDIA
    VRAM: 241 MB (via DXGI)
    Caps: Shader=30 DepthRT=1 NativeDepth=1 NativeShadow=1 DF16=0 DF24=0 INTZ=1 RAWZ=0 NULL=1 RESZ=0 SlowINTZ=0
    desktop: 1920x1080 59Hz; virtual: 1920x1080 at 0,0

    The game is apparently freezing after some amount of play time and then spamming the log file with these errors. Anyone have any ideas or seen this before? The game is a standalone build created with 3.5.0f5. We're thinking it's a graphics driver issue right now, but haven't been able to reproduce this due to a lack of similar machines to test on (this is from a client machine). Any help would be much appreciated.

    Thanks!

    - Josh
     
  2. Babaa

    Babaa

    Joined:
    Nov 24, 2009
    Posts:
    47
    Hi, I have the same issue (not bootcamp):

    Version: Direct3D 9.0c [nvd3dum.dll 8.17.12.8538]
    Renderer: NVIDIA GeForce GTX 570
    Vendor: NVIDIA
    VRAM: 1248 MB (via DXGI)
    Caps: Shader=30 DepthRT=1 NativeDepth=1 NativeShadow=1 DF16=0 DF24=0 INTZ=1 RAWZ=0 NULL=1 RESZ=0 SlowINTZ=0
    desktop: 1920x1080 60Hz; virtual: 1920x1080 at 0,0

    At Windows 7 x64

    /Johan
     
  3. Zaicheg

    Zaicheg

    Joined:
    Sep 30, 2009
    Posts:
    46
    I have the same issue (not bootcamp).
     
  4. flekoun

    flekoun

    Joined:
    Jul 13, 2010
    Posts:
    51
    Yes, same here. Standalone build on 3.5 unity win7 64bit bootcamp. Spamming exactly same thing into log. Game freezes after few ALT+TABs usually. Easy to repro. What is it?? Anyone know? We are in trouble because we can't pass our distributors QA :( (they can repro this on Win7 64b machines without bootcamp as well) Someone help.
     
  5. flekoun

    flekoun

    Joined:
    Jul 13, 2010
    Posts:
    51
    I don't want to be inpatient but I would like to get some kind of answer. Why is this happening? When will this be fixed? Are "Unity guys" aware of this problem? This is completely reproducible on a lot of Win 7 64b machines. Just ALT+TABing few times (around 10) and the Unity freeze for some reason. This is definitely 3.5 ONLY bug. 3.4 was ok. We are stuck now. We can't go back to 3.4 and we can't fix this on 3.5. Our parter don't want to take our program because it simply freezes too often and we can't do anything about it. Any solution? Any ETA? Anything.
     
  6. Kaspar-Daugaard

    Kaspar-Daugaard

    Unity Technologies

    Joined:
    Jan 3, 2011
    Posts:
    150
    Did you file a bug report with your project? (or one that reproduces the problem)

    The main difference between 3.4 and 3.5 renderer is that we introduced multithreading, so there might be some incompatibilities we didn't see on our hardware. You can run single-threaded by using a command line switch: -force-gfx-st

    Let us know if using the switch helps, that gets us closer to a solution.
     
  7. flekoun

    flekoun

    Joined:
    Jul 13, 2010
    Posts:
    51
    Wow! you made my day! This command helped 100%. Not a single crash or freeze! Thanks a lot! We are having headaches over a week now and this one command fixed it all.
    I have one question. Can I run Unity with this command switch by default? Because I don't want to create any kind of .bat file or something like this. Is it possible to run Unit in this "single-threaded" mode everytime when player runs my app?
     
  8. Kaspar-Daugaard

    Kaspar-Daugaard

    Unity Technologies

    Joined:
    Jan 3, 2011
    Posts:
    150
    Good to know! Although sad that it was causing problems in the first place... There is no way to force single-threaded mode other than the switch right now, but we may be able to sneak it in for a hotfix release. It depends on how close you are to shipping if this is useful to you.

    Cheers,
    Kaspar
     
  9. flekoun

    flekoun

    Joined:
    Jul 13, 2010
    Posts:
    51
    For now, our distributors QA has only this freeze problem on a list. As soon as it is fixed they can release our game. So this is a VERY actual problem for us. I don't know how long does it take to release a hotfix for Unity but we would be very grateful if Unity allows us to run as single-threaded by default somehow. Do you have any idea how long it takes to release a hofix for this?
     
  10. flekoun

    flekoun

    Joined:
    Jul 13, 2010
    Posts:
    51
    Any news on this issue? We are getting reports of random freezes in addition to ALT+tabbing also. Any news when the hotfix will come out to enable sigle threaded rendering as a default?
     
  11. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Have you reported this issue? Do you have a case number?
     
  12. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    2,054
    That's very interesting to know.

    I wish Unity would publish all the command line parameters, i've often found them useful in the past, but the webpage dealing with them is very limited in scope.

    What would be even more helpful was if there was a way to set up these parameters from within Unity as its not always possible to set up command line for end users. I mean on windows the only way I know to achieve it is to use a shortcut and add the parameters to the end of the target field. This works, but obviously if you run the project from the exe and not the shortcut everything breaks.

    I'm slightly confused as I was informed recently that -force-gfx-direct would also force single threading on the renderer as a fix to getting some old opengl code working in 3.5. It did work ( using a combination of '-force-opengl -force-gfx-direct') though i'm wondering what gfx-direct actually means now, since gfx-st from the name sounds more likely to switch to single threaded.
     
  13. flekoun

    flekoun

    Joined:
    Jul 13, 2010
    Posts:
    51
    Yes I have reported the bug using the Editor "Report Bug". Dunno what the case number is.
     
  14. flekoun

    flekoun

    Joined:
    Jul 13, 2010
    Posts:
    51
  15. Kaspar-Daugaard

    Kaspar-Daugaard

    Unity Technologies

    Joined:
    Jan 3, 2011
    Posts:
    150
  16. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    For those of you looking to get through certification before this issue is fixed, Kaspar pointed me to PlayerSettings.MTRendering, which you can set to false in an editor script before you build in order to force single-threaded rendering without any command line options.
     
  17. Kaspar-Daugaard

    Kaspar-Daugaard

    Unity Technologies

    Joined:
    Jan 3, 2011
    Posts:
    150
    Hi, as Daniel mentioned you can disable multithreading from script via player settings. For example put this C# script in a folder called Editor:

    Code (csharp):
    1. using UnityEditor;
    2.  
    3. class ExtraSettings
    4. {
    5.     [MenuItem("Extra Settings/Enable MT Rendering")]
    6.     static void EnableMTRendering()
    7.     {
    8.         UnityEditor.PlayerSettings.MTRendering = true;
    9.     }
    10.  
    11.     [MenuItem("Extra Settings/Disable MT Rendering")]
    12.     static void DisableMTRendering()
    13.     {
    14.         UnityEditor.PlayerSettings.MTRendering = false;
    15.     }
    16. }
    17.  
     
  18. flekoun

    flekoun

    Joined:
    Jul 13, 2010
    Posts:
    51
    Thanks a lot!!! I am going to try this immediately!
     
  19. flekoun

    flekoun

    Joined:
    Jul 13, 2010
    Posts:
    51
    Tried to build a game with your script and now everything works without any freeze. Thanks!!
     
  20. Wolf5370

    Wolf5370

    Joined:
    Aug 31, 2012
    Posts:
    10
    //EDIT: This was meant to be in reply to Kaspar Daugaard's post above - hit reply, thought it would add as a comment (sorry!)

    This is excellent (same issue here - on a high-spec windows box) - I also added the method as follows:

    Code (csharp):
    1.  
    2. [MenuItem("Extra Settings/Show MT Rendering Status")]
    3.     static void ShowMTRenderingStatus()
    4.     {
    5.         UnityEditor.EditorUtility.DisplayDialog("MT Rendering Status",
    6.             (UnityEditor.PlayerSettings.MTRendering)
    7.             ? "Multi-Threading Rendering is currently ON"
    8.             : "Multi-Threading Rendering is currently OFF"
    9.             , "OK");               
    10.     }
    11.  
     
    Last edited: Oct 7, 2012
  21. Wolf5370

    Wolf5370

    Joined:
    Aug 31, 2012
    Posts:
    10
  22. nicciSixx

    nicciSixx

    Joined:
    Apr 5, 2012
    Posts:
    9
    Is this likely to be addressed? I have two unity projects running continuously. One on a machine with a AMD which is running fine and one with a nVidia which isn't.

    I'm getting the device handle lost messages in the log file and my coroutines aren't being re-entered.
     
  23. Aurore

    Aurore

    Director of Real-Time Learning

    Joined:
    Aug 1, 2012
    Posts:
    3,106
    @Wolf5370 can you give a bug number for that, the link doesn't work
     
  24. nicciSixx

    nicciSixx

    Joined:
    Apr 5, 2012
    Posts:
    9
    Sorry to be a pain about this, is there a way to set the rendering to single threaded in code for executables, so the system can be configures without passing in command parameters?

    Like the "UnityEditor.PlayerSettings.MTRendering" but for running outside the eidtor?
     
  25. Youenn

    Youenn

    Joined:
    Nov 26, 2012
    Posts:
    1
    Hello,

    We encounter a quite similar problem on our application running on a dedicated pc with windows 7 embedded ( and APU trinity A10 ). For some unknown reason, the gfx device is lost and Unity is minimized, even with the multithreading option disabled and the "Run in background" checked.

    Since this application is supposed to run continously on TV screens, actually we can't ship our product with this random lost device stuff ( not very sexy to show a blue windows screen in public places ).

    We are trying to investigate about possible services that could try to get a hook on the 3d device, causing Unity being messed up but we haven't much clue yet. Unity can be maximized manually but it isn't the point of our application ( stand alone installed in backdoor access like a DVD player and broadcasting on TV screens ).

    If anybody has an idea where or how we could get any information. May it be possible to find a tool that could track 3d device access ?

    Any help would be very appreciated. Thanks.

    DxDiag joined.
     

    Attached Files:

  26. pain_gwar

    pain_gwar

    Joined:
    Apr 14, 2013
    Posts:
    22
    I have encountered the exact same problem (it seems only when i switch to Unity4x).

    I try to disable MT Rendering but nothing changes. It's weird because it happened only if i build for PC in x86, i try to build in x86_64 (MT Rendering on and off) and i haven't any error. The problem is that i don't want to build in x86_64....

    Any ideas or alternative workaround? Thanks
     
  27. Lexustio

    Lexustio

    Joined:
    Jun 26, 2013
    Posts:
    18
    Same problem as with Axe Services. I've built something that's supposed to run as a standalone application. I've left the program to run overnight a few times but both times the thing has minimized to the task bar and the output log is full (last time 140 MB) of "HandleD3DDeviceLost"-messages.

    The application is supposed to run continuously in an exhibition and this kind of behavior pretty much prevents us from shipping.

    Could the problem have something to do with the screen resolution options (ie. the "Run in the background"-option)?
     
  28. reddotgames

    reddotgames

    Joined:
    Apr 5, 2011
    Posts:
    707
    We have the same problem with our game.

    Skipped rendering frame because GfxDevice is in invalid state (device lost)
    HandleD3DDeviceLost:

    Even with MT Rendering disabled via script (and checked in debug mode of player settings its disabled) it's loosing device after alt tabbing ... any ideas?

    "Run in background" (from debug player settings) will help this not happening?
     
    Last edited: Nov 8, 2013
  29. dustinandrew

    dustinandrew

    Joined:
    Apr 30, 2010
    Posts:
    102
    Getting the same thing on our exhibit that is on all day long (shutdown at night). Runs good for a few hours, then crashes. Output log, shows spam of this error:

    Code (csharp):
    1. HandleD3DDeviceLost
    2.   HandleD3DDeviceLost: still lost
    3. Skipped rendering frame because GfxDevice is in invalid state (device lost)
    Then:

    Code (csharp):
    1.  
    2. HandleD3DDeviceLost
    3.   HandleD3DDeviceLost: needs reset, doing it
    4. FullResetD3DDevice
    5. ResetD3DDevice
    6. dev->Reset
    7. D3Dwindow device not lost anymore
    Then Crash!!!

    Weird thing is, we have this installed on 4 different machines with the same setup, but only one is crashing after losing the device.

    UPDATE: turning multi-threaded rendering off does not fix the issue. upgrading to Unity 4.3.3 did not fix the issue. Alt-tabbing or windows key will trigger it, i think if the fullscreen window loses focus, it loses the graphics device.

    FIX: I think we might have found a fix for this.

    Force the size from code without forcing fullscreen:
    Code (csharp):
    1. Screen.SetResolution(1920, 1080, false);
    Set your build resolution settings:
    $Screen Shot 2014-02-07 at 3.44.13 PM.png

    Then from a command line pass in -popupwindow

    This doesn't cause errors or crashes! :D

    The only down side is that your taskbar will be over your app, for us we are installing on controlled machines, so we can just hide and lock the taskbar.

    Also another note and possible Unity bug: If you show the dialog box, uncheck the windowed setting, then rebuild without the dialog, your old windowed setting is saved forced, you can't change it from Screen.SetResolution unless you show the dialog again and turn it back on.
     
    Last edited: Feb 7, 2014
  30. p87

    p87

    Joined:
    Jun 6, 2013
    Posts:
    318
    Running an AMD A10 6800k and I'm having the same issues. Unity editor crashes repeatedly, particularily when you are rotating the scene around or working the gpu. It's pretty bad in the editor, soon as you hit play in the editor it crashes the video drivers repeatedly, almost locking up the system unless you CTRL ALT DEL and end unity task.

    Having a lot of issues with A10's integrated Radeon HD 8670. I have tried installing several versions of the drivers, even the most recent catalyst 14.2 or whatever they are.

    I tried enabling DX11 only, and also tried force single threaded.

    I just changed the registry value for TdrDelay, as suggested in microsoft's troubleshooting, and I have to restart my system to see if that helps... can't restart right now though; I'll have to report back later if it fixes it.

    Anyone able to get the A10 6800k running unity editor stable?
     
  31. thilina098

    thilina098

    Joined:
    Oct 31, 2012
    Posts:
    18
    I have the same issue. I'm running my application in Windows 7 standalone and unity freezes after running couple of minutes, some times couple of hours. Its hard to say when its going to freeze. And it crashes after this message

    I'm using "-force-opengl" option at the moment as a fix. But it takes about 7-8 seconds to start the application. Please reply if any of you have found a better solution.
     
  32. Neeko

    Neeko

    Joined:
    Mar 9, 2012
    Posts:
    24
    Any news if this is fully addressed in Unity 5? I was experiencing this issue (causing the game to freeze) when built with 4.3.4.
     
  33. ForceMagic

    ForceMagic

    Joined:
    Feb 27, 2015
    Posts:
    38
    I just got the problem in Unity 5.2.1. We need to release a build soon, but after that we will update to 5.2.2 hoping this issue will be resolved....
     
  34. Moyses

    Moyses

    Joined:
    Feb 10, 2014
    Posts:
    2
    I'm having this issue in Unity 5.2.2. Unity freezes every time I lock the screen (Windows 7 x64).
     
  35. Pawl

    Pawl

    Joined:
    Jun 23, 2013
    Posts:
    113
    Seeing this as well (on an older Unity 4.3). Seems to happen while the full screen game is alt-tabbed. After giving the game focus again, I do see:

    Code (CSharp):
    1. HandleD3DDeviceLost
    2.   HandleD3DDeviceLost: needs reset, doing it
    3. FullResetD3DDevice
    4. ResetD3DDevice
    5. dev->Reset
    6. D3Dwindow device not lost anymore
    7.  
    and everything seems okay most of the time, but some users are reporting that the game gets stuck with a black screen.
     
  36. hernaez

    hernaez

    Joined:
    Aug 16, 2010
    Posts:
    19
    Hey Guys, I'm having the same issue here.
    It happens when alt-tabbing, also we have "Run in Background" on in our compile preferences.
    Any help here would be appreciated.
     
  37. DonDraper22

    DonDraper22

    Joined:
    Dec 23, 2020
    Posts:
    1
    Interesting info, thanks for share it.