Codeusa / Borderless-Gaming

Play your favorite games in a borderless window; no more time consuming alt-tabs.
GNU General Public License v2.0
5.47k stars 475 forks source link

ArgumentException: Process with ID xxxxx is not running #473

Closed FrozenSoda closed 7 months ago

FrozenSoda commented 4 years ago

Borderless Gaming version: 9.5.6 OS: Windows 10 1909 x64 Steps to reproduce: Unknown

The application has crashed with an unhandled exception twice seemingly random; one time today and a few months earlier as well. This is the contents of the crash file (I translated the important stuff from Swedish):

"Process with an ID 34980 is not running.ArgumentExceptionË vid System.Diagnostics.Process.GetProcessById(Int32 processId, String machineName) vid System.Diagnostics.Process.GetProcessById(Int32 processId) vid BorderlessGaming.Logic.Windows.Native.QueryProcessesWithWindows(Action1 callback, List1 windowPtrSet) i E:\Downloads\Borderless-Gaming-master (3)\Borderless-Gaming-master\BorderlessGaming.Logic\Windows\Native.cs:rad 442 vid BorderlessGaming.Logic.Core.ProcessWatcher.d20.MoveNext() i E:\Downloads\Borderless-Gaming-master (3)\Borderless-Gaming-master\BorderlessGaming.Logic\Core\ProcessWatcher.cs:rad 206 --- Slut pÃ¥ stackspÃ¥rningen frÃ¥n föregÃ¥ende plats där ett undantag utlöstes --- vid System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) vid BorderlessGaming.Logic.Core.ProcessWatcher.d15.MoveNext() i E:\Downloads\Borderless-Gaming-master (3)\Borderless-Gaming-master\BorderlessGaming.Logic\Core\ProcessWatcher.cs:rad 61 --- Slut pÃ¥ stackspÃ¥rningen frÃ¥n föregÃ¥ende plats där ett undantag utlöstes --- vid System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.b__6_1(Object state) vid System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state) vid System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) vid System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) vid System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() vid System.Threading.ThreadPoolWorkQueue.Dispatch() vid System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

thelapisfox commented 4 years ago

Getting same crash. Yesterday and today.

Borderless Gaming version: 9.5.6.1328 OS: Windows 10 1909 x64

UnhandledException_8-24-2020.crash.txt

kroppt commented 1 year ago

I had this problem recently. Looking at the code, it appears there's a race condition. I think if a window is closed between these two lines of code, this can happen. I don't do development on Windows, otherwise I'd try to fix it. I think we should catch and ignore an ArgumentException when calling GetProcessById.

https://github.com/Codeusa/Borderless-Gaming/blob/8ccf20b90e64f981c36c6cc85c3f2b4aad25b0c4/BorderlessGaming.Logic/Windows/Native.cs#L442-L443

thelapisfox commented 4 months ago

So, how exactly was this fixed? The only thing I see is an updated readme file.

kroppt commented 4 months ago

So, how exactly was this fixed? The only thing I see is an updated readme file.

It appears to be on the net8 branch.

https://github.com/Codeusa/Borderless-Gaming/pull/602/files#diff-b78d60ef587b9e389f3b5ad6a1d4c19a45c39656349cf6d37d8854b2f2d97459R47-R52