Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Cannot attach Debbuger #875

Closed
orlando320 opened this issue Jan 22, 2024 · 8 comments
Closed

[BUG] Cannot attach Debbuger #875

orlando320 opened this issue Jan 22, 2024 · 8 comments
Labels
area-dotnet-debugging Issues around .NET Debugging with console, ASP.NET, or Aspire area-unity Unity support bug Something isn't working needs-more-info Needing more information, waiting on OP

Comments

@orlando320
Copy link

Describe the Issue

the only way I can attached the debugger is if I completely close vscode and unity then open them both back up but then when I do unity freezes until I release it from the debugger. When it doesn't connect I get this error "Failed to attach debugger to 127.0.0.1:56200

Steps To Reproduce

No response

Expected Behavior

  • Closed VS and in Unity > Edit > Preferences > External Tools and Click on "Regenerate project files" (you don't need to check anything else, just click the button)
  • Closed both VS code unity (this fixes the attachment issue but not when it locks up unity)

Environment Information

I am running unity 2022.3.1 on Windows 11 in VSCODE (ver 1.85.2)

@orlando320 orlando320 added the bug Something isn't working label Jan 22, 2024
@microsoft-issue-labeler microsoft-issue-labeler bot added the area-project Project load, Solution Explorer label Jan 22, 2024
@timheuer timheuer added area-unity Unity support area-dotnet-debugging Issues around .NET Debugging with console, ASP.NET, or Aspire and removed area-project Project load, Solution Explorer labels Jan 22, 2024
@jbevain
Copy link
Member

jbevain commented Jan 23, 2024

@orlando320, so attaching the debugger works once, but subsequent tentatives fail to attach unless you restart Unity?

Could you modify your .vscode/launch.json file to enable some logging:

    "configurations": [
        {
            "name": "Attach to Unity",
            "type": "vstuc",
            "request": "attach",
            "logFile": "${workspaceRoot}/debug.log"
        }

And send the resulting log file to [email protected]? Thank you!

@desplesda
Copy link

I'm also seeing an error very similar to this, where the debugger fails to attach.

When I attempt to connect the debugger, VS Code appears to start a debug session, and shows the debug controls (the floating continue/step/disconnect pane). The Debug Console appears, but no text appears in it. Unity's 'Debug Mode' icon turns blue, indicating that it believes a debugger is attached. When I click the Disconnect button, the debug session ends in VS Code, and Unity's 'Debug Mode' icon turns yellow, indicating that the debugger has disconnected.

My only difference from @orlando320 is that Unity is not locking up - it continues to operate normally, as though the debugger had successfully attached.

My steps:

  • Launch my Unity project
  • Regenerate project files, just to be sure.
  • Set Unity to Debug Mode, to allow debugger attaching.
  • Launch VS Code.
  • Start a debugger session using the Attach to Unity configuration.

I've sent a copy of my debug log to [email protected].

My environment:

  • macOS 12.6.2
  • Unity: 2021.3.9f1
  • Unity for Visual Studio Code: 0.9.4
  • C# for Visual Studio Code: 2.15.30
  • C# Dev Kit: 1.2.7

I've also tested this with the previous version of the VS Code extensions, with the exact same steps results:

  • Unity for Visual Studio Code: 0.9.3
  • C# for Visual Studio Code: 2.14.8
  • C# Dev Kit: 1.1.16

@jbevain jbevain added the needs-more-info Needing more information, waiting on OP label Jan 25, 2024
@jbevain
Copy link
Member

jbevain commented Feb 14, 2024

Closing this as we haven't heard in 3 weeks. Feel free to reopen or send the logs as requested for further investigation. Thanks!

@jbevain jbevain closed this as completed Feb 14, 2024
@AntonioDrk
Copy link

Hello,
I don't know how relevant it is, but it somewhat is happening to me today as well, I've managed to get the debug.log out.
Hope it helps:

--> R (attach-2): {"type":"response","request_seq":2,"success":false,"command":"attach","message":"Failed to attach debugger to 127.0.0.1:56160","body":{},"seq":2}
<-- C (disconnect-3): {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":3}
Stopping due to fatal error: NullReferenceException: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at SyntaxTree.VisualStudio.Unity.Debugger.UnityEngine.Detach()
at Microsoft.VisualStudio.Unity.AD7DebugAdapter.HandleDisconnectRequest(DisconnectArguments arguments)
at Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.DebugAdapterBase.HandleProtocolRequest(String requestType, Object requestArgs)
at Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.DebugAdapterBase.OnProtocolRequestReceived(Object sender, RequestReceivedEventArgs e)
at Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.DebugProtocol.OnRequestReceived(String command, IRequestResponder responder)
at Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.DebugAdapterBase.HandleDisconnectRequestAsync(IRequestResponder1 responder) at Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.DebugAdapterBase.<InitializeProtocolClient>b__5_12(IRequestResponder1 r)
at Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.RequestInfo`1.Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.IRequestInfo.InvokeHandler(DebugProtocol protocol, ProtocolRequest request, Object args)
at Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.DebugProtocol.HandleIncomingRequest(String msg)
at Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.DebugProtocol.HandleIncomingMessage(String msg)
at Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.DebugProtocol.ProcessMessageBody()
at Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.DebugProtocol.ReaderThreadProc()

@RobTranquillo
Copy link

RobTranquillo commented May 30, 2024

I have the same problem with my everyday project that I have been working on for over a year. Since some of the latest versions of VSCode, the debugger stops connecting at some point. Only a restart of VSCode and Unity fixes the problem. Until it reappears.

I actually see the problem every day. But even after a few experiments, I have not yet been able to reproduce it for sure. My guess is that it could be caused by a complex mix of OpenVPN, Tailscale, multiple Unity editors and VSCode editors connected for debugging in conjunction with Windows sleep mode (Supend-To-Disk)

Output if it fails:

--> R (attach-2): {"type":"response","request_seq":2,"success":false,"command":"attach","message":"Failed to attach debugger to 127.0.0.1:56636","body":{},"seq":2}
<--   C (disconnect-3): {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":3}
--> R (disconnect-3): {"type":"response","request_seq":3,"success":true,"command":"disconnect","body":{},"seq":3}

@Entretoize
Copy link

For the even restarting both VSCode and Unity does nothing, Unity is locked if I start debugging !

@Yecats
Copy link

Yecats commented Aug 1, 2024

I am also running into this issue. Versions:

  1. Unity 2023.2.15f1
  2. Unity Visual Studio package: 2.0.22
  3. VS Code: v1.91.1
  4. VS Code Unity Extension: 1.0.2

@wuxingogo
Copy link

Versions:

Unity 2023.3.22f1
Unity Visual Studio package: 2.0.22
VS Code: v1.95.3
VS Code Unity Extension: 1.0.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dotnet-debugging Issues around .NET Debugging with console, ASP.NET, or Aspire area-unity Unity support bug Something isn't working needs-more-info Needing more information, waiting on OP
Projects
None yet
Development

No branches or pull requests

9 participants