[SDK 3.11.0-beta.1] IndexOutOfRangeException thrown when Reload Domain is disabled
tracked
BluWizard
The Unity 6 VRChat SDK has a problem with ContactReceiver.UpdateContact throwing an index out of range into unassigned, specific to when Unity's
Project Settings -> Editor -> When entering Play Mode
setting is set to m_EnterPlayModeOptions: 3
(Do not reload Domain or Scene). It gets thrown repeatedly when executed.IndexOutOfRangeException: Index 65535 is out of range of '9216' Length.
at VRC.Dynamics.ContactReceiver.UpdateContact ()
at VRC.Dynamics.ContactManager.HandleDynamicsFrameComplete ()
This is because the SDK has changed how Contacts register, which no longer works when Reload Domain is turned off.
To be specific: Enabling a receiver still puts it on the update list right away, but its slot is now assigned later, at the start of the next physics frame. Until then its slot number is 65535, meaning “none yet”.
The new approach relies on the queued slot requests getting processed in a set order from a clean start. With domain and scene reload off, Unity carries over values that VRC.Dynamics expects to be reset, such as each receiver’s slot number and the physics scheduler’s internal state. Something about that carried-over state makes a receiver miss its slot on the first frame, and then the jam keeps it that way.
In the previous SDK (3.10.0 and older in Unity 2022), when a contact receiver is enabled, it’s given its slot right away in the same call. It’s never on the per-frame update list without a valid slot, so reloads being off didn’t matter.
What needs to be fixed:
Because the SDK now defers slot assignment,
UpdateContact
doesn't check for "no slot yet", unlike OnEnable
and OnDisable
. So there needs to be a check added to the code to ensure this error doesn't get thrown.Temporary Solution:
Ensure
Reload Domain
in your Project Settings -> Editor
is enabled. Specifically, ensure m_EnterPlayModeOptions:
is NOT 1
or 3
.Log In
This post was marked as
tracked
SenkyDragon
this is harmony patched in vrcfury 1.1487
SenkyDragon
This isn't actually specific to domain & scene reload disabled, it can happen any time a contact is enabled between when the contactmanager is made and when its first scheduled update happens.