Repository navigation
fix: hand tracking and controller swap crash - #59
Conversation
fixes Yellow-Dog-Man#3 access violation crash
|
Looks promising, though I'm curious if this works within Wine at all. More importantly: I'm curious if it has the potential to break under Wine. It would kinda suck to have this work fine for Windows users, but break something on Linux. |
|
I have not tested on Linux (proton), so I genuinely don't know but if it can't find those exact memory sites and it's a mismatch, it will just back down and basically fallback to default behavior. |
Frooxius
left a comment
There was a problem hiding this comment.
This is excellent!
It sucks that it has to be handled this way, but as we're kinda stuck with this Unity version, I don't think there's any other options anyway.
Since it has mechanism to disarm itself and we'll likely be moving away from Unity completely in the future, I'm inclined to merge this into the default client, as there would be a big benefit for users before that happens.
Thank you very much for diving into this issue and doing this kind of reverse engineering fix!
We'll test this under Proton as well to make sure it doesn't explode (maybe it won't like the AddVectoredExceptionHandler, I'm not sure how commonly it's used in software), but that should also be easy enough to handle and just disable it in that scenario.
Motivation
Fixing the hand tracking and controller swap crash. Also removes extra trackers added when using hand tracking.
This is a workaround for a Unity 2019 engine bug, not a root-cause fix and I'm mostly just PR'ing it so it's documented. This probably makes more sense as a mod than a real fix, but I know many people have reported issue and tbh it has annoyed me a lot personally lot too because I have to go and disable hand tracking in VD every time I want to play resonite and sometimes I forget and take off my controllers for a sec and boom I crash.
Below are videos demoing the crash and the fixed version.
Before (Vanilla - 2026.9.14.1239):
before.mp4
After: (This PR - 2026.9.14.1239):
after.mp4
Related GitHub issues
Notable Changes
I've tried many other things before I resorted to this method but frankly this is a Unity 2019 bug and there is no way to fix it other than memory patching UnityPlayer.dll without updating the engine to a newer version where the VR input stuff has been fully rewritten.
Basically as far as I could tell, vr inputs are not properly freed, they seem to leave stale memory pointers which are called again when the controller and hand tracking swap happens and that causes access violation crash. I think the issue is that at least in Virtual Desktop (where I primarily tested on), possibly related to how VD reuses device slots/serials across hand and controller devices, and maybe that's why there is stale pointers left behind? I am not sure frankly.
I managed to identify all places where state pointers seem to cause the access violation after testing many times and faults are repaired with neutral input state instead of crashing.
Scope of the change is three parts: a small native DLL (
XRInputGuard) that registers a vectored exception handler and repairs the known fault sites, a C# binding that surfaces its status, and a SteamVR driver tweak so role-less devices with a known controller serial never fall back to trackers. The DLL is rebuilt automatically as part of "Build > Windows" context menu.On safety: the guard only activates when every guarded site matches its expected byte signature in the loaded UnityPlayer.dll, checked at load and re-checked on every fault. On any mismatch it disarms itself loudly through the status string instead of touching an unknown build, so a future engine upgrade fails safe rather than corrupting input.
You can tell it's working by the
[XRInputGuard] ARMED: helpers=16 getfeature=3 sites=19line in theplayer.logon startup. The status string also carries catch counters, so each repaired fault is observable there instead of ending the player.Testing
I've tested many times using my Quest 3 and Virtual desktop on windows, where I keep switching between hands and controller until I get an access violation crash. Resonite 2026.9.14.1239 (shown in the videos)
Backwards Compatibility
None. No changes to managed input behavior when no fault occurs.