Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug Failed to present D3D11 swapchain...

Discussion in '2023.1 Beta' started by PaulMDev, Oct 10, 2022.

  1. PaulMDev

    PaulMDev

    Joined:
    Feb 19, 2019
    Posts:
    68
    I had this error message after using the spline tool in 2023.1.
    upload_2022-10-10_17-12-51.png

    After that the editor crash and when I open it again all of the windows are black.
     
    lacas8282 likes this.
  2. PaulMDev

    PaulMDev

    Joined:
    Feb 19, 2019
    Posts:
    68
    My bad !
    I reinstalled my drivers and it's working great now !
     
  3. PaulMDev

    PaulMDev

    Joined:
    Feb 19, 2019
    Posts:
    68
    Wait no...
    It happened again after exiting play mode...
     
    lacas8282 likes this.
  4. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036
    This is a huge Unity bug and should be fixed asap as ultimate priority

    It really destroys any reliability of the system.

    I get this often from users with Nvidia and 2060 or later GPUs when DX11 is used in LUMINA HDRP, that is my most demanding asset. DX12 and Vulkan or 1050GTX older GPUs dont give this issue.

    Try Vulkan or DX12 as option and see if fixes it.
     
    PhoenixAdvanced likes this.
  5. PhoenixAdvanced

    PhoenixAdvanced

    Joined:
    Sep 30, 2016
    Posts:
    316
    Seconded.

    I never had this issue with a 980ti, but my 3090 has these crashes every so often.
     
    lacas8282 and nasos_333 like this.
  6. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,111
    As the message says, we need bug reports with more information and ideally reproduction steps to investigate incidents behind this error.
     
    nasos_333 likes this.
  7. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036
    LUMINA HDRP videos, software recorded inside Unity editor in 1050GTX Laptop GPU, for reference.






    Hi,

    In my case is not possible to send a report since I cant recreate the problem, should have a more flexible way to recreate the issues.

    E.g. is easy to just download my LUMINA HDRP asset and try it in any 2060 or 30xx Nvidia to get the problem in Unity 2021.3 LTS in DX11, i had many reports on this so should be easy to reproduce. It does not happen in 1050GTX, or in DX12 - Vulkan (at least in my tests and from clients reports so far) or in Unity 2019.

    Only latest Unity 2021.3 LTS versions have this issue and only with 20xx Nvidia and above in DX11.

    I dont own a 20xx or 30xx to replicate this and in my 1050GTX i never get this issue, so is impossible to report. But have had so many reports that i had to up my LUMINA HDRP spec to minimum DX12 or Vulkan, since would be risky to develop with DX11 if this bug happens.

    There is a very big number of reports on this Swapchain issue as well around the net. This is right now the most critical Unity issue by far from the time Unity was made, it renders the engine completely unreliable to develop anything in, as it may run in certain GPUs on the developer side and at random fail for all users of the game in other machines.

    This is a cataclysmic kind of event problem and should be the no1 to resolve in my mind. I have never seen such a severe issue in Unity that makes one think this engine is not usable at all as is a great risk to use it.

    In LUMINA HDRP case, the game runs in 1080p at 30fps on my 1050GTX, so some suggestions that the issue is related to GPU stalling for seconds and produces this error cant possibly stand, as it runs in 30fps, so each GPU round should last less than 1/30 of the second and certainly not seconds. Plus the issue happens in 20xx Nvidia that is far above 1050GTX on my laptop, so that 30fps would be around 60fps.

    https://github.com/Unity-Technologies/BoatAttack/issues/172
    https://www.reddit.com/r/unity/comments/xhipnn/unity_keeps_on_crashing_failed_to_present_d3d11/
    https://canopy.procedural-worlds.com/forums/topic/114-d3d11-swapchain-error-fix/
    https://stackoverflow.com/questions...t-d3d11-swapchain-due-to-device-reset-removed
    https://www.reddit.com/r/Unity3D/comments/hjhv6k/hdrp_makes_editor_freeze/
    https://forum.unity.com/threads/random-unity-crashes-after-upgrade-to-rtx-3070.1004528/
    https://forum.unity.com/threads/fai...wapchain-due-to-device-reset-removed.1129568/
    https://unity928.rssing.com/chan-30531769/article975366.html
    https://gamedev.stackexchange.com/q...t-d3d11-swapchain-due-to-device-reset-removed
     
    Last edited: Jan 2, 2023
    DrMeatball likes this.
  8. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,890
    You should still report it and say that it only happens on these GPUs and doesn't happen on 10xx.

    In general this message appears when the OS decides that the GPU driver hangs. This can happen due to a lot of reasons, for example, when there's so many compute shader invocations that the GPU can't complete them in reasonable time. Thus, many instances of it are user errors. There's not much that can be done on our side about this in general, as there's no safe way to estimate, how long a given frame will take to render and whether it will be below or above the OS threshold.
     
  9. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036
    Hi, thanks for the input.

    The thing is that this error appeared in Unity 2020 onwards, so for sure there is something related to how graphics are handled by Unity after 2019 versions.

    Also in general the error makes no sense whatsoever, as if something works at 30fps in 1050GTX, should not have any stalls in 20xx series and the OS should not identify it as such unless there is some bug.

    So my guess is that something in Unity handling of graphics makes the OS think that the GPU is stalling when actually this does not happen, in DX11.
     
  10. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,890
    I'm not saying it's a generic issue in your case - this is why I asked you to submit a bug report :)
    I'm just saying that in many cases the error is the same, but the underlying issue varies a lot, hence there are a lot of messages that can be found when searching for the error itself.
     
  11. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036
    I see, thanks :)

    How will i go about submit the report, will i need to include my asset whole or could download it from your side directly ?
     
  12. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,890
    It would be great if you could prepare a project with your asset already included and list simple steps to reproduce the issue. Thank you! :)
     
    nasos_333 likes this.
  13. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036
    Hi,

    I have now submitted the project with the potential bug

    New Incident created: IN-27763 - Crash of editor and build when using DX11 in Unity 2021.3.f1 and above in Nvidia 2060GTX or above, with Swapchain bug.

    Hopefully can give some more insight on the issue. Note that i cant recreate the issue on my side, so the project must be run in Nvidia 2060 or above in DX11 mode to be replicated, since this is the GPUs that had reports that fail from users.

    On my 1050GTX GPU i never had a single crash while working more than a year now on the system. That is why it looks like a bug and is also is impossible to handle on my side alone.
     
  14. CannedCaveman

    CannedCaveman

    Joined:
    Feb 28, 2020
    Posts:
    2
    I have the same error since for multiple months now (Unity 2021.3.x) on my laptop with an GTX 1660 Ti.
     
    nasos_333 likes this.
  15. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036
    Is it only happening in DX11 ? Have you tried DX12 or Vulkan ?
     
  16. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036
    Hi,

    Is there any update on the swapchain issue ?

    I had also sent a ticket below on this

    "New Incident created: IN-27763 - Crash of editor and build when using DX11 in Unity 2021.3.f1 and above in Nvidia 2060GTX or above, with Swapchain bug."

    Other threads on the issue
    https://forum.unity.com/threads/con...-to-device-removed.987834/page-4#post-8714637

    Thanks
     
    lacas8282 likes this.
  17. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,890
    Hi! Looks like it hasn't been processed yet. I'll poke QA.
     
    lacas8282 and nasos_333 like this.
  18. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036
    Hi, thanks that would be great.
     
  19. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036
    Some good news, it seems the bug has now been looked at and confirmed by the relevant team and hopefully can address soon.

    Thanks for the help on this, is very appreciated

    "IN-27763 - Build stops responding when building the project using DirectX11 graphics API UPDATE: Internal ID created
    CASE IN-27763
    Thank you again for your bug report.
    Your bug report Build stops responding when building the project using DirectX11 graphics API has been confirmed and transferred to the appropriate internal development team at Unity. Your bug report has the following internal ID: UUM-25111"
     
    aleksandrk likes this.
  20. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036
    UPDATE on the swapchain issue in LUMINA HDRP in DX11:

    The Unity team has managed to recreate the bug and are now looking into it. The system did not create an issue in DX12 or Vulkan on Unity side as well.

    https://forum.unity.com/threads/con...-to-device-removed.987834/page-5#post-8753740

    This below is the issue tracking link, please remember to vote for the issue to help with it be resolved faster. Thanks in advance for any help on this.

    https://issuetracker.unity3d.com/is...ding-the-project-using-directx11-graphics-api
     
    rdjadu likes this.
  21. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036





    An update, it seems after i updated my 1050GTX drivers get stuck in some of the most demanding scenes in LUMINA URP and HDRP in DX11. I never had any issues with previous drives in either versions in any scene.

    With DX12 both assets work fine as well.

    I post my new drivers details from DX Diag and Nvidia panels, in case can help.

    It is also apparent that Nvidia states Run time DX12 and DX Diag also reports DX12 use, thus i assume they have completely abandoned DX11 and thus the issues of random crashes.

    My laptop is a DELL XPS 15 9560, 1050GTX GPU.
     
  22. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,890
    I suggest to add this information to the case you submitted.
     
    nasos_333 likes this.
  23. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036
    Hi, yes have already added it, hopefully can help further
     
    aleksandrk likes this.
  24. GamesbyJP

    GamesbyJP

    Joined:
    May 20, 2018
    Posts:
    62
    Having the same issue developing for Meta Quest 2 connected through air link.
    Screen turned black twice in the timespan of 20 minutes. Happens when pressing play in the scene occasionally. My screen turns black as my graphics driver crashes, and when it comes back these error messages appear.

    Edit: Using 2020.3.33f1, which is... not listed in the issue tracker

    UNITY_CRASH.png system_info.png system_info_display.png
     

    Attached Files:

    GameLoomer likes this.
  25. starfoxy

    starfoxy

    Joined:
    Apr 24, 2016
    Posts:
    174
    I'm having this issue too. o_O

    Unity 2021.3.19f1.
    Nvidia RTX 2070 Super using the Studio Driver.
     
    PhoenixAdvanced likes this.
  26. RedRiverStudio

    RedRiverStudio

    Joined:
    Sep 8, 2014
    Posts:
    136
    Same issue, just popped up one day and happens regularly now. Win 11, RTX 2060 super, Unity 2021.3.17. I am suspicious that it is a hardware problem, not Unity. so haven't posted any bugs. DX12 just outright crashes with no popups.
     
  27. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036
    Hi,

    Is there any update on the issue ?

    Thanks
     
    PhoenixAdvanced likes this.
  28. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,890
    Hi!
    It's waiting for the team responsible for the area to pick it up.
     
  29. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036
    Hi,

    Thanks for the heads up. Is there some timeframe on when would be started, as there is a lot of backlash over this issue as randomly affects users in random ways, which is very critical.

    Thanks
     
    PhoenixAdvanced likes this.
  30. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,890
    They say "this is the next one we'll look into" :)
     
  31. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036
    Perfect, thanks a lot :)
     
  32. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036
    Hi,

    I took a preliminary peek as the lumina crash was on top of the queue now and it was poked at on forums.

    The culprit is


    Code (csharp):
    1.                         [allow_uav_condition]
    2.                         while (true)
    3.                         {
    4.                             InterlockedCompareExchange(destination[coord], compareValue, writeValue, originalValue);
    5.                             if (compareValue == originalValue)
    6.                                 break;
    7.                             compareValue = originalValue;
    8.                             float4 originalValueFloats = DecodeRGBAuint(originalValue);
    9.                             writeValue = EncodeRGBAuint(originalValueFloats + value);
    10.                         }
    SM5.0 doesn't have floating point atomics, which is probably the reason this was done. But to be strict the allow_uav_condition is only applicable for compute shaders. So we are invoking UB here by having an infinite loop and trying to break from it.

    Elsewhere the correct way was used:


    Code (csharp):
    1.                         [allow_uav_condition] for (int i = 0; i < 12; i++)
    2.                         {
    3.                             InterlockedCompareExchange(destination[coord], compareValue, writeValue, originalValue);
    4.                             if (compareValue == originalValue)
    5.                                 break;
    6.                             compareValue = originalValue;
    7.                             float4 originalValueFloats = DecodeRGBAuint(originalValue);
    8.                             writeValue = EncodeRGBAuint(originalValueFloats + value);
    9.                         }
    After I changed all the places to use that the TDR vanished. You can naturally change the amount of loop iterations done to make it produce more correct results as that naturally may produce the wrong results from time to time.

    Unfortunately there is nothing we can really do to make this work. The shader is sent to FXC and compiled as is. And as it's technically UB it's a cointoss if it works or not. But we can't unfortunately make it work if the infinite loop approach is used.

    There is a massive performance hit here too. As DX11, and thus Unity in all other backends too, mandates a full gigabarrier between every drawcall that uses an UAV you will basically get a massive pipeline bubble for each of them. In the far future we'll have something to help with this but for now if you use UAVs on drawcalls expect terrible performance.


    I post the reply from Unity above, maybe helpful in some cases, i cant say i understand everything, but i assume replacing the while loop with a clear number should address it.

    There is also some extra info in the tracking link
    https://issuetracker.unity3d.com/is...ding-the-project-using-directx11-graphics-api
     
    rdjadu likes this.
  33. GamesbyJP

    GamesbyJP

    Joined:
    May 20, 2018
    Posts:
    62
    Thank you, was looking forward to an update. Best of luck to the team!
     
  34. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036

    Hi all, i have managed to fix the issue replacing a while loop in my shader with a for loop with specific iterations.

    The video shows LUMINA running in DX11 mode.
     
    aleksandrk likes this.
  35. whyatme

    whyatme

    Joined:
    Apr 4, 2021
    Posts:
    20
    Wow this is a gnarly bug, just had it for the first time, it like crashed my entire GPU and caused some weird unrecoverable errors with my multi-monitor setup, had to reboot the machine. Thanks Unity team for prioritizing it next!
     
  36. BoxxyPrime

    BoxxyPrime

    Joined:
    Jul 2, 2014
    Posts:
    10
    This has been so rough. On beta 9 and eagerly awaiting a fix. For some reason my scenes are crashing my editor pretty constantly - seems to be worse with scenes that have the new water system - but not 100% the cause of it. Not using foam, or extruders, or anything - just baseline pool water for one scene that's constantly crashing.
     
  37. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,111
    To clarify some of the misconceptions here, there is not one single bug responsible for all instances of these errors. The case reported by @nasos_333 was investigated by our devs and the results were shared in the post above:

    https://forum.unity.com/threads/failed-to-present-d3d11-swapchain.1346855/#post-8873109

    Unless you're using Lumina, you're likely running into a different issue.

    If you are running into these errors and suspect that there is an issue with Unity rather than with your project (for example when your project used to work fine in older versions of Unity), please submit bug reports with reproduction projects so we can investigate.
     
    nasos_333 likes this.
  38. Ga2Z

    Ga2Z

    Joined:
    Feb 16, 2012
    Posts:
    67
    Hi. I've been having the same issue with a GTX 1080 Ti on Unity 2021.3.22.

    I read in this reddit post that running unity in a maximized window might cause the issue and It worked for me, my Unity stopped crashing.
     
  39. OnikiKay

    OnikiKay

    Joined:
    Dec 20, 2017
    Posts:
    10
    After upgrading to Unity 2023.1.0b15, I have a 100% reproductible case where the error triggers.
    The issue happens with a GTX 1060 6GB VRAM, Core I7-8700 16 GB RAM. NVIDIA Drivers 531.61.
    Before the message pops up, CPU and GPU are used at 100% and Unity Editor freezes. This happens only when using DirectX11. There is no problem when using DirectX12 or Vulkan. However, ignoring the crashes, DirectX11 is 25% to 30% faster than the others, so I have to stick with it.
    The project uses the default HDRP pipeline, no fancy shaders. Most of the materials use default HDRP/Lit shader, others use shaders from the digital human package or shaders created with the ShaderGraph.
     
    GameLoomer likes this.
  40. SevenPointRed

    SevenPointRed

    Joined:
    Feb 3, 2016
    Posts:
    208
    I get this all the time, but underclocking my GFX card will fix it. I think I just have a dodgy gpu.
     
  41. sevla

    sevla

    Joined:
    Mar 29, 2023
    Posts:
    1
    I have this all the time with almost any project i create. Some projects occur more often then others, idk why. I have no graphic card, only creating simple games without many graphical requirements.
     
  42. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,036
    Probably because is a bug than anything that has to do with actual graphics load
     
  43. VeloneerGames

    VeloneerGames

    Joined:
    May 30, 2016
    Posts:
    1
    The error still exists, 2023.1.0b17
     
    nasos_333 likes this.
  44. lacas8282

    lacas8282

    Joined:
    Apr 25, 2015
    Posts:
    128
    Any news on this? Rtx3070 die daily and my win11 die, I have to restart my machine. This is a very big BUG! UNITY 2022.2.20. I think I never get this error with my old card, gtx1660, and on win10.
     
  45. QQQ-123

    QQQ-123

    Joined:
    Jun 28, 2023
    Posts:
    1
    Unity2022.3.0f1c1 lts <DX11> Win11 ,still have this problem.My Gpu is RTX3060 laptop.Please fix that.
     
    MR_Development likes this.
  46. CarlinhuxD

    CarlinhuxD

    Joined:
    Jun 25, 2018
    Posts:
    4
    Unity 2021.3.17f1 Win11, i7 13700k 1080ti Strix. Issue stil happens.