Search Issue Tracker

By Design

Votes

0

Found in [Package]

2.3.0

Issue ID

XRIT-69

Regression

No

XR interaction toolkit "Select" input reference breaks script references after scene load

Package: XR Interaction Toolkit

-

Steps to reproduce:
1. Open the attached user's project "VR test.zip"
2. Open the "SampleScene.unity"
3. Make sure that "Oculus Touch Controller Profile" is added in the OpenXR plugin Interaction profiles
4. Connect Oculus Link
5. Enter Play Mode
6. Confirm the Right controller's grip works (console message "pressed grip button" appears and the XR rig transform should move a bit)
7. Hit "R" on the keyboard to reload the same scene
8. Press the Right controller's grip again and it should throw the errors

Expected results: XR interaction toolkit "Select" input reference does not break script references after scene load
Actual Results: XR interaction toolkit "Select" input reference breaks script references after scene load

Reproducible: XRIT 2.2.0 - 2.3.0 (2021.3.21f1, 2022.2.13f1, 2023.1.0b10, 2023.2.0a8)
Could not test on 2020.3.46f1 due to package errors when downgrading

Environment: Windows 10 22H2

Notes:
-This is not reproducible if a new VR template project is created
-If XR interaction toolkit rig is setup to listen for controller grip press through the Select reference from the sample files any references in the gripPress method break after loading a scene through SceneManager. It tries calling the deleted versions of objects from the initial scene
-Can be circumvented by using the SelectValue reference instead
-No errors occur if there are no references in the method
-Doesn't seem to occur/crash the game after building project
-Console Error:
MissingReferenceException: The object of type 'Transform' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Transform.get_position () (at <4014a86cbefb4944b2b6c9211c8fd2fc>:0)
Tester.GripRelease (UnityEngine.InputSystem.InputAction+CallbackContext obj) (at Assets/Tester.cs:49)
UnityEngine.InputSystem.Utilities.DelegateHelpers.InvokeCallbacksSafe[TValue] (UnityEngine.InputSystem.Utilities.CallbackArray`1[System.Action`1[TValue]]& callbacks, TValue argument, System.String callbackName, System.Object context) (at Library/PackageCache/com.unity.inputsystem@1.4.4/InputSystem/Utilities/DelegateHelpers.cs:46)
UnityEngine.InputSystem.LowLevel.<>c_DisplayClass7_0:<set_onUpdate>b_0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)
-------------
MissingReferenceException while executing 'canceled' callbacks of 'XRI RightHand Interaction/Select/HTCViveControllerOpenXR/grippressed'
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c_DisplayClass7_0:<set_onUpdate>b_0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr)

  1. Resolution Note:

    I was able to reproduce the issue, and the main problem is that the script adds listeners in the Start method for specific actions, but does not remove them when the object is destroyed. When 'R' is pressed, it does a scene reload which destroys all of the previous objects, creating an orphaned link in the list of callbacks. The Input System callbacks persist because they are not technically a part of the scene. Below is the addition to the script that avoids the issue by properly cleaning up:

    private void OnDestroy()
    {
    grip.action.started -= GripPress;
    grip.action.canceled -= GripRelease;
    }

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.