Error: XR Input Action State giving NullPointerException

This works for me.I updated the xr-interaction pacakge from 2.0.1 to 2.5.4 and this issue occured.

Thank you! This was exactly my problem. Checking Use Reference fixed the issue! For context, I was using Unity 2021.3 and XR Toolkit 2.5.4. This bug likely occurs for people that are on XR Toolkit upgrade paths or that create custom ActionBasedControllers. The Unity XR Starter Kit has these references populated in their prefabs, so it won’t be an issue there.

I checked the change logs in the XR Toolkit and it doesn’t appear that Unity has fixed this issue yet in any package.

Here is an explanation of why this occurs:
If the UI Scroll Action is not assigned, InputActionProperty.action will return an instance of InputAction that is effectively empty, not null. This means the null check (if (uiScrollAction != null)) is insufficient, as it doesn’t handle the case where the action exists but is unbound or has no meaningful configuration.

The problem is that even though the action instance exists, attempting to call methods like ReadValue() on an unbound or invalid InputAction can result in runtime errors. Specifically, InputActionState.ApplyProcessors may throw a NullReferenceException because there are no bindings or valid state associated with the action.

This bug isn’t present everywhere. For example, IsTrackedAction handles the null and empty check correctly.

            // Actions without bindings are considered empty and will fallback
            if (isTrackedInputAction != null && isTrackedInputAction.bindings.Count > 0)

However, in other areas the binding check is configured incorrectly.

            var uiPressValueAction = m_UIPressActionValue.action;
            if (uiPressValueAction == null || uiPressValueAction.bindings.Count <= 0)
                uiPressValueAction = m_UIPressAction.action;
            controllerState.uiPressInteractionState.SetFrameState(IsPressed(m_UIPressAction.action), ReadValue(uiPressValueAction));

I recommend checking UseReference for all actions and leave them empty if you don’t use them.

Hopefully Unity fixes this issue at some point.