Skip to content

Commit

Permalink
[Fix] MAUI Profiler - dsrouter connection not getting established (ma…
Browse files Browse the repository at this point in the history
…cOS) #103
  • Loading branch information
JaneySprings committed Jun 16, 2024
1 parent 83dc2d6 commit dd4371a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/DotNet.Meteor.Debug/Agents/BaseLaunchAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ public abstract class BaseLaunchAgent {
logger.OnErrorDataReceived($"[HotReload]: {ex.Message}");
}
}
public virtual void Dispose() {
public virtual void Dispose() {
foreach (var disposable in Disposables) {
disposable.Invoke();
DebuggerLoggingService.CustomLogger.LogMessage($"Disposing {disposable.Method.Name}");
try {
disposable.Invoke();
DebuggerLoggingService.CustomLogger.LogMessage($"Disposing {disposable.Method.Name}");
} catch (Exception ex) {
DebuggerLoggingService.CustomLogger.LogMessage($"Error while disposing {disposable.Method.Name}: {ex.Message}");
}
}

Disposables.Clear();
Expand Down
7 changes: 2 additions & 5 deletions src/DotNet.Meteor.Debug/Agents/TraceLaunchAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ public class TraceLaunchAgent : BaseLaunchAgent {
DeviceBridge.Shell(Configuration.Device.Serial, "setprop", "debug.mono.profile", $"127.0.0.1:{Configuration.ProfilerPort},suspend");

var routerProcess = DSRouter.ServerToServer(Configuration.ProfilerPort + 1, logger);
System.Threading.Thread.Sleep(1000); // wait for router to start
var traceProcess = Trace.Collect(routerProcess.Id, nettracePath, logger);
System.Threading.Thread.Sleep(1000); // wait for trace to start

Disposables.Add(() => traceProcess.Terminate());
Disposables.Add(() => routerProcess.Terminate());
Disposables.Add(() => DeviceBridge.RemoveReverse(Configuration.Device.Serial));

Expand All @@ -86,6 +81,8 @@ public class TraceLaunchAgent : BaseLaunchAgent {
DeviceBridge.Install(Configuration.Device.Serial, Configuration.OutputAssembly, logger);
DeviceBridge.Launch(Configuration.Device.Serial, applicationId, logger);

var traceProcess = Trace.Collect(routerProcess.Id, nettracePath, logger);
Disposables.Insert(0, () => traceProcess.Terminate());
Disposables.Add(() => DeviceBridge.Shell(Configuration.Device.Serial, "am", "force-stop", applicationId));
}
private void LaunchWindows(IProcessLogger logger, string diagnosticPort, string nettracePath) {
Expand Down

0 comments on commit dd4371a

Please sign in to comment.