Skip to content

fix(psvr2): don't change an ioData buffer's length where macOS refuses - #7

Merged
aaf2tbz merged 1 commit into
mainfrom
fix/psvr2-iodata-length
Nov 18, 2026
Merged

aaf2tbz merged 1 commit into
mainfrom
fix/psvr2-iodata-length

Conversation

@aaf2tbz

@aaf2tbz aaf2tbz commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

A PlayStation VR2 owner's metalvrd ended right after finding the headset:

*** Terminating app due to uncaught exception 'ioDataSetLengthException', reason: 'Length can not be modified for ioData buffer'
  2 IOUSBHost  -[IOBufferMutableData bufferID]
  3 metalvrd   Psvr2Backend::startReader(...)

startReader set r.data.length = size on the buffer ioDataWithCapacity: returned. On their macOS that buffer already has its capacity as its length, and any change throws.

Now the length is set only when it differs from the transfer size, inside @try. A refusal is logged, and a buffer still shorter than the transfer leaves that endpoint unopened (startReader returns false, as for a pipe that doesn't open) instead of reading short. The Rift's USB shim (usb_shim.mm) never sets an ioData length, so it isn't affected.

Tested

  • metalvrd builds (cmake --build build/native --target metalvrd).
  • Not run with a PS VR2: there isn't one here. The fix needs the reporter to confirm the headset now gets past this point.

… to change it

startReader set the length of each endpoint's ioDataWithCapacity buffer to
its transfer size. Some macOS versions give such a buffer its capacity as
its length and throw ioDataSetLengthException on any change, which ended
metalvrd as soon as a PlayStation VR2 was found. The length is set only
when it differs, the refusal is caught and logged, and a buffer shorter
than the transfer leaves that endpoint unopened instead.
@aaf2tbz
aaf2tbz merged commit 2745afd into main Nov 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant