forked from dnSpy/dnSpy
-
-
Notifications
You must be signed in to change notification settings - Fork 654
Add delay time option when debugging unity games #189
Copy link
Copy link
Closed
Milestone
Description
dnSpy/Extensions/dnSpy.Debugger/dnSpy.Debugger.DotNet.Mono/Impl/DbgEngineImpl.cs
Lines 419 to 435 in b8820ef
| for (;;) { | |
| var elapsedTime = DateTime.UtcNow - startTime; | |
| if (elapsedTime >= connectionTimeout) | |
| throw new CouldNotConnectException(GetCouldNotConnectErrorMessage(connectionAddress, connectionPort, filename)); | |
| try { | |
| var cts = new CancellationTokenSource(connectionTimeout - elapsedTime); | |
| var asyncConn = VirtualMachineManager.ConnectAsync(endPoint, null, cts.Token); | |
| if (!asyncConn.Wait(connectionTimeout - elapsedTime)) | |
| throw new CouldNotConnectException(GetCouldNotConnectErrorMessage(connectionAddress, connectionPort, filename)); | |
| vm = asyncConn.Result; | |
| break; | |
| } | |
| catch (SocketException sex) when (sex.SocketErrorCode == SocketError.ConnectionRefused) { | |
| // Retry it in case it takes a while for mono.exe to initialize or if it hasn't started yet | |
| } | |
| Thread.Sleep(100); | |
| } |
When debugging unity games uisng Start Debugging, the process may not start very quickly.
Currently dnspy will immediately try to connect the socket, but the game port is not ready.
Then, a AggregateException with a SocketException inside will be thrown (not just a SocketException),
making the debugging fail with the error Error_CouldNotConnectToProcess.
But the expect behavior should be: keep trying until it reaches timeout (30s by default).
To fix this, we can catch both AggregateException and SocketException, or add a delay time option in Start Debugging window.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels