Skip to content

Fix NPE error caused by the second HID endpoint of HID composite devices#1808

Open
KenRouKoro wants to merge 2 commits into
SlimeVR:mainfrom
KenRouKoro:main
Open

Fix NPE error caused by the second HID endpoint of HID composite devices#1808
KenRouKoro wants to merge 2 commits into
SlimeVR:mainfrom
KenRouKoro:main

Conversation

@KenRouKoro
Copy link
Copy Markdown

This PR fixes a NullPointerException in the hid4java data reader and device enumerator threads that occurs when a single USB device enumerates multiple HID interfaces (with identical VID/PID/serial numbers) due to the physical device having a second HID endpoint, which previously prevented the receiver's tracking data from being recognized.

Additionally, it resolves a secondary issue introduced by the initial fix: if the second HID endpoint is not a SlimeVR HID endpoint, it causes a loop of [TrackerServer] Reopening device ${device.serialNumber} after no data received. This happens because the system attempts to handshake with the second HID endpoint as if it were a SlimeVR device, despite there being no corresponding return data. To address this, I have introduced a keepFirstHidPerPhysicalDevice filter to block extra HID endpoints.

@github-actions github-actions Bot added the Area: Server Related to the server label Apr 13, 2026
@loucass003
Copy link
Copy Markdown
Member

@sctanf can you double check that one 🙏

@sctanf
Copy link
Copy Markdown
Member

sctanf commented May 28, 2026

The logic was a little hard to follow, but it seems to be okay.
At line 265: I think it could be changed to just remove devices not in keptSet, so making the extra sets enumeratedSet and droppedSet is redundant and probably will make it clearer to understand. Assuming the rest was done for readability which is okay I think

@sctanf
Copy link
Copy Markdown
Member

sctanf commented May 28, 2026

I am not aware of a use case to have multiple HID interfaces, is this for functionality outside of SlimeVR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Server Related to the server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants