Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

DS4Windows hangs when disconnecting USB controller #3

Closed
GingerAdonis opened this issue Mar 25, 2017 · 15 comments
Closed

DS4Windows hangs when disconnecting USB controller #3

GingerAdonis opened this issue Mar 25, 2017 · 15 comments

Comments

@GingerAdonis
Copy link

Whenever I pull out the USB cable of a controller, DS4Windows hangs/crashes. (Win10 x64)

Happens in both shared and exclusive modes.

Ryochan7 added a commit that referenced this issue Mar 25, 2017
@Ryochan7
Copy link
Owner

Thanks for pointing out this problem. The underlying file stream being used goes into an invalid state when the USB controller is disconnected and the final call to close the stream caused the problem. The old code did not use the FileStream class for reading so this was not an issue before. I will get a new build up soon.

@Ryochan7
Copy link
Owner

New version is up.

https://github.com/Ryochan7/DS4Windows/releases/download/v1.4.55/DS4Windows_1.4.55_x64.zip

@Keltere
Copy link

Keltere commented Mar 26, 2017

Really really thanks Ryo, I'm glad that someone is updating ds4windows. Hope that with the new windows ds4windows will work without administrator permission.

@Ryochan7
Copy link
Owner

There are only two areas where DS4Windows should need administrator privileges. Exclusive mode would be one and there is no way around that problem. Security features in Windows require that an administrator account be used to disable and re-enable a device in order to be able to use a device in exclusive mode. I believe DS4Windows already checks if it can open a device in exclusive mode first before it attempts to disable and re-enable the device so there isn't much more that DS4Windows can do in that regard.

The other area would be for KB+M emulation in games that run as the administrator; one example of a game in my collection that runs as the administrator is Mass Effect 1. There is no way to work around that problem using the native SendInput API and running DS4Windows as the administrator won't work in all scenarios such as UAC prompts. Paying for an expensive signing certification could work around the UAC problem but DS4Windows would still have to be run as the administrator. The only way, that I know of, to truly work around the problem of needed to run DS4Windows as the admin in this scenario would be to use the vmulti virtual KB+M driver within DS4Windows. It works around all those problems and it even works when playing games that use anti-cheat software, such as HackShield, without any major worry about getting your account flagged.

@Ryusennin
Copy link

Hi Ryochan,

I'm not sure if it's possible to reopen this issue or if I need to create a new one, but I'm meeting the same problem on Windows 7 Ultimate (64-bit) with all versions of DS4Windows from 1.4.54 to 1.4.67. The driver works well but it crashes every time I unplug my controller from the mini USB cable.

The only version that doesn't crash is the 1.4.53 build (which is incidentally the only one with 32-bit support, although I'm not sure it's relevant).

@Ryochan7
Copy link
Owner

Ryochan7 commented May 3, 2017

That would be the version before overlapped IO was implemented. Is there any error log when the app crashes that you could post? I would assume that the error is due to some exception not getting caught when attempting to close an invalid file handle but the only relevant exception that I know of is currently being caught. I am usually against doing a grand catch of all exceptions so it would be nice to isolate the exact exception causing problems. In the meantime, I will re-open this issue.

@Ryochan7 Ryochan7 reopened this May 3, 2017
@Ryusennin
Copy link

ds4windows_2017-05-03 21-39-54-60

I'm afraid that's not much to go by. Is there a more exhaustive log saved somewhere?

@Ryochan7
Copy link
Owner

Ryochan7 commented May 3, 2017

.NET does post some error information when an application crashes. You have to open the Event Viewer from Control Panel > System and Security > Administrative Tools > Event Viewer. Expand Windows Logs, selection Application and look for an error with a source of .NET Runtime. Here is an example showing an error message in the Event Viewer; this error would occur when closing a filestream if the exception is not caught.

errorlog_20170503

Application: DS4Windows.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.IOException
   at DS4Windows.HidDevice.closeFileStreamIO()
   at DS4Windows.HidDevice.CloseDevice()
   at DS4Windows.DS4Devices.On_Removal(System.Object, System.EventArgs)
   at System.EventHandler`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Invoke(System.Object, System.__Canon)
   at DS4Windows.DS4Device.performDs4Input()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart()

@Ryusennin
Copy link

Alright, I think I've spotted to relevant logs happening two seconds apart. Hope it helps!

Event 1026, .NET Runtime

Application: DS4Windows.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.OperationCanceledException
   at System.IO.__Error.WinIOError(Int32, System.String)
   at System.IO.FileStream.EndWrite(System.IAsyncResult)
   at System.IO.FileStream.FlushWrite(Boolean)
   at System.IO.FileStream.Dispose(Boolean)
   at System.IO.Stream.Close()
   at DS4Windows.HidDevice.closeFileStreamIO()
   at DS4Windows.HidDevice.CloseDevice()
   at DS4Windows.DS4Devices.On_Removal(System.Object, System.EventArgs)
   at System.EventHandler 1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Invoke(System.Object, System.__Canon)
   at DS4Windows.DS4Device.performDs4Input()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart()

Event 1000, Application Error

Faulting application name: DS4Windows.exe, version: 1.4.67.0, time stamp: 0x5905f962
Faulting module name: KERNELBASE.dll, version: 6.1.7601.23714, time stamp: 0x58bf8a2e
Exception code: 0xe0434352
Fault offset: 0x000000000001a06d
Faulting process id: 0x1e44
Faulting application start time: 0x01d2c44a97348f4c
Faulting application path: C:\Program Files (x86)\DS4Windows\DS4Windows.exe
Faulting module path: C:\Windows\system32\KERNELBASE.dll
Report Id: c1f18272-3054-11e7-b4b6-00248c37aa6b

@Ryochan7
Copy link
Owner

Ryochan7 commented May 4, 2017

Can you give the following test build a try?

https://drive.google.com/open?id=0B6yGHDx0CFzDS21QNVlpWVFlaTA

@Ryusennin
Copy link

I quickly tested this build by unplugging and replugging the controller a dozen times, without a single crash. I didn't notice any performance regression ingame either. I will test it further tomorrow, but so far it looks very stable. Thank you! :)

@Ryusennin
Copy link

As far as I can tell, this build works great so far. Thanks for your continous support!

@shinra358
Copy link

shinra358 commented May 5, 2017

Can't get bluetooth mode working at all with .68 build.

@Keltere
Copy link

Keltere commented May 5, 2017

shinra358 try remove the device (from bluetooth and other devices) and install again. I had the same problem.

@shinra358
Copy link

ok, that did the trick. thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants