microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.39k stars 8.3k forks source link

Brand new Windows 10 install: This terminal has encountered an issue with the graphics driver and it could not recover in time. #15601

Open CorpulentBrony opened 1 year ago

CorpulentBrony commented 1 year ago

Windows Terminal version

1.17.11461.0

Windows build number

10.0.19045.0

Other Software

N/A

Steps to reproduce

image

Expected Behavior

Actual Behavior

image

CorpulentBrony commented 1 year ago

My settings.json, only change I've made was disabling Atlas engine based on a troubleshooting solution I saw here. Didn't make a difference:

{
    "$help": "https://aka.ms/terminal-documentation",
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "actions": 
    [
        {
            "command": 
            {
                "action": "copy",
                "singleLine": false
            },
            "keys": "ctrl+c"
        },
        {
            "command": "paste",
            "keys": "ctrl+v"
        },
        {
            "command": "find",
            "keys": "ctrl+shift+f"
        },
        {
            "command": 
            {
                "action": "splitPane",
                "split": "auto",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+d"
        }
    ],
    "copyFormatting": "none",
    "copyOnSelect": false,
    "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
    "experimental.rendering.software": false,
    "newTabMenu": 
    [
        {
            "type": "remainingProfiles"
        }
    ],
    "profiles": 
    {
        "defaults": 
        {
            "useAtlasEngine": false
        },
        "list": 
        [
            {
                "commandline": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "hidden": false,
                "name": "Windows PowerShell"
            },
            {
                "commandline": "%SystemRoot%\\System32\\cmd.exe",
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "hidden": false,
                "name": "Command Prompt"
            },
            {
                "guid": "{17bf3de4-5353-5709-bcf9-835bd952a95e}",
                "hidden": true,
                "name": "Ubuntu-22.04",
                "source": "Windows.Terminal.Wsl"
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            },
            {
                "guid": "{d7b20cea-47a9-518c-95a4-c8bd91e2e1c6}",
                "hidden": false,
                "name": "Ubuntu 22.04.2 LTS",
                "source": "CanonicalGroupLimited.Ubuntu22.04LTS_79rhkp1fndgsc"
            }
        ]
    },
    "schemes": 
    [
        {
            "background": "#0C0C0C",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#012456",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell Powershell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#282C34",
            "black": "#282C34",
            "blue": "#61AFEF",
            "brightBlack": "#5A6374",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B6C2",
            "brightGreen": "#98C379",
            "brightPurple": "#C678DD",
            "brightRed": "#E06C75",
            "brightWhite": "#DCDFE4",
            "brightYellow": "#E5C07B",
            "cursorColor": "#FFFFFF",
            "cyan": "#56B6C2",
            "foreground": "#DCDFE4",
            "green": "#98C379",
            "name": "One Half Dark",
            "purple": "#C678DD",
            "red": "#E06C75",
            "selectionBackground": "#FFFFFF",
            "white": "#DCDFE4",
            "yellow": "#E5C07B"
        },
        {
            "background": "#FAFAFA",
            "black": "#383A42",
            "blue": "#0184BC",
            "brightBlack": "#4F525D",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B5C1",
            "brightGreen": "#98C379",
            "brightPurple": "#C577DD",
            "brightRed": "#DF6C75",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#E4C07A",
            "cursorColor": "#4F525D",
            "cyan": "#0997B3",
            "foreground": "#383A42",
            "green": "#50A14F",
            "name": "One Half Light",
            "purple": "#A626A4",
            "red": "#E45649",
            "selectionBackground": "#FFFFFF",
            "white": "#FAFAFA",
            "yellow": "#C18301"
        },
        {
            "background": "#002B36",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#FFFFFF",
            "cyan": "#2AA198",
            "foreground": "#839496",
            "green": "#859900",
            "name": "Solarized Dark",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#FDF6E3",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#002B36",
            "cyan": "#2AA198",
            "foreground": "#657B83",
            "green": "#859900",
            "name": "Solarized Light",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#FFFFFF",
            "cyan": "#06989A",
            "foreground": "#D3D7CF",
            "green": "#4E9A06",
            "name": "Tango Dark",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#FFFFFF",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#000000",
            "cyan": "#06989A",
            "foreground": "#555753",
            "green": "#4E9A06",
            "name": "Tango Light",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#300A24",
            "black": "#171421",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#08458F",
            "brightCyan": "#2C9FB3",
            "brightGreen": "#26A269",
            "brightPurple": "#A347BA",
            "brightRed": "#C01C28",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#A2734C",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#FFFFFF",
            "green": "#26A269",
            "name": "Ubuntu-22.04-ColorScheme",
            "purple": "#881798",
            "red": "#C21A23",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#A2734C"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#000080",
            "brightBlack": "#808080",
            "brightBlue": "#0000FF",
            "brightCyan": "#00FFFF",
            "brightGreen": "#00FF00",
            "brightPurple": "#FF00FF",
            "brightRed": "#FF0000",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#FFFF00",
            "cursorColor": "#FFFFFF",
            "cyan": "#008080",
            "foreground": "#C0C0C0",
            "green": "#008000",
            "name": "Vintage",
            "purple": "#800080",
            "red": "#800000",
            "selectionBackground": "#FFFFFF",
            "white": "#C0C0C0",
            "yellow": "#808000"
        }
    ],
    "themes": []
}
lhecker commented 1 year ago

Could you use DebugView to try and see if there's any relevant output when you launch Windows Terminal?

microsoft-github-policy-service[bot] commented 1 year ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

microsoft-github-policy-service[bot] commented 1 year ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

Benjamin-Connelly commented 1 year ago

This has been happening to me using panes and my $PAGER (I think) on W11.

CRYPTO-GENIK commented 11 months ago

Same issue on Windows 11 here Only started after updating all drivers (Nvidia + Intel)

ValentinRonsseray commented 9 months ago

I had this issue on my Lenovo Thinkpad W520. Setting experimental.rendering.software from false to true solved the problem on my side (the procedure is equivalent to turn on "use software rendering" (not sure about the name) in the settings).

Terminal Windows Version : 1.18.3181.0 Windows 10 Version 22H2 Build 19045.3803

0x6d6e647a commented 9 months ago

Same problem as @Valentin-Ronsseray on Lenovo Thinkpad W520 but setting experimental.rendering.software to true. does not fix the issue. However, if I connect to the laptop via Remote Desktop it works. Something seems really broken with the rendering. Using "Cmder" until this gets fixed.

0x6d6e647a commented 9 months ago

@lhecker I ran DebugView (both 32-bit and 64-bit, both as normal user and as administrator) and then ran Windows Terminal (with software rendering enabled and disabled). There was no relevant output in DebugView.

I ran Windows Terminal and attached to it with the x64dbg debugger and click the Resume button and caught many exceptions in nvumdshimx, d3dll, dxgi. I've attached the log from x64dbg: log-Fri Jan 5 22-52-09 2024.txt

Please note the debug log was generated with software rendering disabled.

Let me know if you need any more information!

lhecker commented 9 months ago

@0x6d6e647a Wow that's excellent! 😊 There's basically two failures: DxRenderer.cpp(679) and DxRenderer.cpp(1291). The latter is the same as the former (it's the caller). The issue occurs due to the CreateSwapChainForCompositionSurfaceHandle call failing. Given that the exceptions happen every time right before the CreateSwapChainForCompositionSurfaceHandle call fails, I suspect that they're correlated. I'll ask around what the best way to debug this is.

In the meantime, if you'd like, you could create a dump of the process at the moment when the first exception hits and send it to my mail (see my GitHub profile). That may also clear things up, since I have access to the source code and the unstripped debug symbols (not Nvidia's, but at least Microsoft's).

0x6d6e647a commented 9 months ago

@lhecker I sent you an email containing the dumps. Please let me know if I can provide any more assistance. Thank you for looking into this!

0x6d6e647a commented 8 months ago

Sent @lhecker an improved dump file via email to examine. Please let me know if I can provide any more assistance. Thanks again!

lhecker commented 8 months ago

@0x6d6e647a sorry for the late response. I was able to take a look at the dump now. Can you try and see what happens if you enable the "AtlasEngine" in the "Rendering" settings? Does the issue still occur then?

But I think the chance that this fixes the issue is rather small unfortunately. This is the stack trace of the exception you caught (the function names aren't a secret thankfully):

d3d11!ThrowFailure
d3d11!NDXGI::CDevice::CreateFenceImpl
d3d11!NDXGI::CDevice::CreateFenceImpl
d3d11!CFence::FinalConstruct
d3d11!CLayeredObject<CFence>::{ctor}
d3d11!CLayeredObject<CFence>::CreateInstance
d3d11!CDevice::CreateLayeredChild
d3d11!NDXGI::CDevice::CreateLayeredChild
d3d11!NOutermost::CDeviceChild::FinalConstruct
d3d11!CUseCountedObject<NOutermost::CDeviceChild>::{ctor}
d3d11!CUseCountedObject<NOutermost::CDeviceChild>::CreateInstance
d3d11!NOutermost::CDevice::CreateLayeredChild
d3d11!NDXGI::CDevice::CreateFence
dxgi!CDXGISwapChain::CreateTrackedFenceExtended
dxgi!CDXGISwapChain::BindToDwm
dxgi!CDXGISwapChain::InitializeSwapChainDeviceState
dxgi!CDXGISwapChainApplicationClass::FinalConstruct
dxgi!CMTUseCountedObject<CDXGISwapChainApplicationClass>::CMTUseCountedObject<CDXGISwapChainApplicationClass>
dxgi!CMTUseCountedObject<CDXGISwapChainApplicationClass>::CreateInstance
dxgi!CDXGIFactory::CreateSwapChainImpl
dxgi!CDXGIFactory::CreateSwapChainForCompositionSurfaceHandle
Microsoft_Terminal_Control!Microsoft::Console::Render::DxEngine::_CreateDeviceResources
Microsoft_Terminal_Control!Microsoft::Console::Render::DxEngine::StartPaint
Microsoft_Terminal_Control!Microsoft::Console::Render::Renderer::_PaintFrameForEngine
Microsoft_Terminal_Control!Microsoft::Console::Render::Renderer::PaintFrame
Microsoft_Terminal_Control!Microsoft::Console::Render::RenderThread::_ThreadProc

CreateFenceImpl's purpose is to call CreateSynchronizationObject2 and it throws an exception if that call fails. The parameter that it passed in your case were this:

D3DKMT_CREATESYNCHRONIZATIONOBJECT2{
    .hDevice = 0x40003a80,
    .Info = {
        .Type = D3DDDI_MONITORED_FENCE,
        .Flags = { 
            .Shared                = 1,
            .NtSecuritySharing     = 1,
            .NoGPUAccess           = 1,
            .DeferredWaits         = 1,
        },
        .MonitoredFence = {
            .InitialFenceValue           = 0,
            .FenceValueCPUVirtualAddress = 0,
            .FenceValueGPUVirtualAddress = 0,
            .EngineAffinity              = 0,
        },
        .SharedHandle = 0,
    },
    .hSyncObject = 0,
};

The call failed with status 0x80070057 which is "The parameter is incorrect.". CreateSynchronizationObject2 is part of the driver Device Driver Interface for GPUs. In other words, your GPU driver is returning a failure when creating a fence (a fence is basically a semaphore). Looking through your other GPU-related objects I don't see anything that would indicate that your device works different from my PC.

I'll ask a colleague about this who knows more about GPU drivers and DWM. In the meantime, I'd suggest checking whether there are any GPU driver updates (or similar) available for your machine.

ghost commented 8 months ago

I encountered this issue and successfully resolved it on my PC. I noticed abnormal CPU usage while playing a game, and then I realized that the GPU wasn't functioning properly. To address this, I uninstalled my Nvidia GPU from the Device Manager and performed a "Scan for hardware changes" to restart it. This resolved the problem.

0x6d6e647a commented 8 months ago

@lhecker I enabled the "AtlasEngine" and tired it with both software and hardware rendering but this did not resolve this issue. However, the behavior of the failure was different. The program now additionally displays: "Warning: Renderer encountered an unexpected error -2147024809". Hopefully this information might help. If you want I can get another dump of this behavior.

In terms of GPU, I thought it might be relevant to mention some peculiarities of the Lenovo W520. It is a very early generation of hybrid graphics so the output sinks between the Nvidia and Intel graphics are not shared. Details are available on the Arch wiki. I had Bumblebee properly setup with Gentoo Linux but was disappointed at the strange issues with connecting to projectors for work or using the docking station at my desk. I had Windows 7 at the time setup for dual boot and it worked flawlessly so I gave up on Linux on the hardware and stuck with Windows. This worked fine through Windows 8 and Windows 10 but at some point a Windows update happened and Windows began to display the same behavior as Linux in regards to the outputs. Because such early hybrid graphics hardware is primitive and exotic now so support being silently dropped isn't surprising. Around the same time I noticed I couldn't use the "Performance" tab in the "Task Manager" which I at the time debugged was related to the graphics drivers.

I suppose this issue might just come down to the strange early hybrid graphics setup on the W520. As it stands the W520 is not supported for Windows 11 so I'll probably be migrating this machine back to Gentoo Linux once this issue is resolved. I'm only keeping Windows on it for the time being to assist by generating dumps.

@JymirJones I'll try your suggestion and see if it fixes the issue for me. I have upgraded this system from Windows 7 all the way to Window 10 without reinstalling windows so it wouldn't be too surprising if something like this fixes it.

0x6d6e647a commented 8 months ago

@lhecker @JymirJones Uninstalling the device and rebooted and now Windows Terminal works perfectly with all combinations of "AtlasEngine" being on/off and Software Rendering being on/off. I checked in Device Manager and it installed the same version I had before but I suppose uninstalled it cleaned up some bad setting somewhere. For what it's worth the "Performance" tab in Task Manager still crashes. Seems the issue wasn't caused by Windows Terminal at all in my case. Thanks @JymirJones for the fix! Special thanks to @lhecker for working closely with me on the crash dumps and being extra patient!

lhecker commented 8 months ago

-2147024809 is 0x80070057 which is E_INVALIDARG, which is the same error that I found in your dump and described above. AtlasEngine's error handling is a bit more robust and so that's probably why we can now see the actual error code. This confirms that your dump indeed contained the failing stack trace. Nice!

I've read a bit more into the W520 and it does seem like this may be a driver issue. Windows Update also distributes driver updates from partners including from Lenovo, so maybe one of their driver updates had (and continues to have) a bug?

That aside, it's not a well known feature, but Windows allows you to choose your preferred graphics card on a per application basis. It's in the System > Display > Graphics section of the Settings application: image

The new text renderer in Windows Terminal will respect this setting and use the GPU that you choose there. If Windows Terminal is not listed there, you can add it by clicking the Browse button at the top of the page (choose "Microsoft store app" in the dropdown). This setting also exists in Windows 10 at the same location, but it looks a little bit different.

@0x6d6e647a Thanks again for helping me investigate this! It's unfortunate that we can't help you further, but it was definitely super helpful to get an example on how such driver issues can look like (this my first time encountering such a GPU driver failure). @JymirJones Thanks for letting us know how you resolved this issue! I'll use this next time someone has the same issue - maybe it helps them as well. :)

0x6d6e647a commented 7 months ago

Quick follow up. After a reboot the issue returned. Following the same steps resolved it again. I noticed when Windows Terminal works the brightness up and down keys on the keyboard will not work. This is not a major problem since I can still adjust the brightness from the notification center. After a reboot (perhaps related to Windows update?) the brightness keys on the keyboard work but Windows Terminal has the same issues. At this point I think it's a combination of early implementation of hybrid graphics hardware on the W520 and unsupported / abandoned driver support from Nvidia. I'm going to retire this laptop in the coming months so it's not a big deal.

Just wanted to keep everyone up to date on the issue and solution. Thanks again to everyone for their help!

RishiWadhwa commented 2 months ago

@lhecker @0x6d6e647a

One solve I found is just uninstalling the NVIDIA GPU Driver, it seems to be particularly an NVIDIA problem, and is very easy to fix.

RishiWadhwa commented 2 months ago

@0x6d6e647a simplest fix:

settings > display > graphics

From the dropdown select: Microsoft Store App and choose terminal. In Terminal, change the setting from the separate chip. This problem seems to be happening with external/secondary chips instead of built-in chips. So I set my terminal to only use power-saving/in-built gpu.

syaifulwachid commented 1 month ago

Just disable hybrid graphic in bios setting, this problem can accure if your devices have two graphic card, chose only one between the two of them. or you can disable it from your graphic setting app in the performance setting or graphic switcher image

syaifulwachid commented 1 month ago

And also you can setting like this what i am doing and it can fix my problem image

Nene020 commented 3 days ago

I had the same issue recently I switched my graphics from hybrid to discrete and restarted That solved my issue .