Parcourir la source

Delete helper process for collecting deadlock exception

CPKreuz il y a 1 an
Parent
commit
9144948474
2 fichiers modifiés avec 4 ajouts et 46 suppressions
  1. 0 7
      src/PixiEditor/App.xaml.cs
  2. 4 39
      src/PixiEditor/Helpers/DeadlockDetectionHelper.cs

+ 0 - 7
src/PixiEditor/App.xaml.cs

@@ -66,13 +66,6 @@ internal partial class App : Application
             return;
         }
 
-        if (ParseArgument("--deadlock ([0-9]+) ([0-9]+)", arguments, out Group[] deadlockGroups))
-        {
-            DeadlockDetectionHelper.HandleDeadlockOfOtherProcess(int.Parse(deadlockGroups[1].ValueSpan), int.Parse(deadlockGroups[2].ValueSpan));
-            Shutdown();
-            return;
-        }
-
         if (ParseArgument("--wait-before-init ([0-9]+)", arguments, out Group[] waitBeforeInitGroups))
         {
             Task.Delay(int.Parse(waitBeforeInitGroups[1].ValueSpan)).Wait();

+ 4 - 39
src/PixiEditor/Helpers/DeadlockDetectionHelper.cs

@@ -126,19 +126,6 @@ public class DeadlockDetectionHelper
         thread.Join(10000);
     }
 
-    private void StartDeadlockHandlerProcess()
-    {
-        Process process = new();
-
-        process.StartInfo = new()
-        {
-            FileName = Path.ChangeExtension(Assembly.GetExecutingAssembly().Location, "exe"),
-            Arguments = $"--deadlock {Process.GetCurrentProcess().Id} {mainThread.ManagedThreadId}"
-        };
-
-        process.Start();
-    }
-
     private void ForceNewProcess()
     {
         Process process = new();
@@ -152,23 +139,16 @@ public class DeadlockDetectionHelper
         process.Start();
     }
     
-    private static void ReportProblem(int mainThreadId, int processId = -1)
+    private static void ReportProblem(int mainThreadId)
     {
         string stackTrace;
-        var isOwn = false;
 
-        if (processId == -1)
-        {
-            isOwn = true;
-            processId = Process.GetCurrentProcess().Id;
-        }
-        
-        using (var target = DataTarget.CreateSnapshotAndAttach(processId))
+        using (var target = DataTarget.CreateSnapshotAndAttach(Process.GetCurrentProcess().Id))
         {
             stackTrace = GetMainClrThreadStackTrace(target, mainThreadId);
         }
 
-        CrashHelper.SendExceptionInfoToWebhook(new DeadlockException(stackTrace, isOwn)).Wait();
+        CrashHelper.SendExceptionInfoToWebhook(new DeadlockException(stackTrace)).Wait();
     }
 
     private static string? GetMainClrThreadStackTrace(DataTarget target, int threadId)
@@ -258,28 +238,13 @@ public class DeadlockDetectionHelper
 
     private static bool ReturnTrue() => true;
 
-    public static void HandleDeadlockOfOtherProcess(int processId, int mainThreadId) =>
-        ReportProblem(mainThreadId, processId);
-    
     class DeadlockException : Exception
     {
-        public DeadlockException(string stackTrace, bool isOwn) : base(GetMessage(isOwn))
+        public DeadlockException(string stackTrace) : base("A deadlock has occured. Stack trace is from the Main Thread. ")
         {
             this.StackTrace = stackTrace;
         }
 
         public override string StackTrace { get; }
-
-        private static string GetMessage(bool isOwn)
-        {
-            var builder = new StringBuilder("A deadlock has occured. Stack trace is from the Main Thread. ");
-            if (!isOwn)
-            {
-                builder.Append(
-                    "NOTICE: Any above state information is from the reporting process and not the actual deadlocked process");
-            }
-
-            return builder.ToString();
-        }
     }
 }