Input Recorder and OpenXR

I try to use the Input Recorder with openxr. The results are very inconsistent when the recordings will be played and when not. Is it in a buggy state or is there a (not documented) way how to use it properly?

Thanks in advance!

Edit: I tried it with quest 2 on oculus link and rift s in Unity 2020.3.14.

bump

I haven’t used InputRecorder with XR, but I have used InputEventTrace successfully which InputRecorder is based on.

Recording example (to byte array):

// declare locals
private InputEventTrace inputEventTrace = new InputEventTrace();

// later... enable recording
inputEventTrace.Enable()

// later... save to byte array
MemoryStream ms = new MemoryStream();
inputEventTrace.WriteTo(ms);
var inputSystemBytes = ms.ToArray();
inputEventTrace.Clear();

Playback example (from byte array):

// declare locals
public InputEventTrace inputEventTrace = new InputEventTrace();
public InputEventTrace.ReplayController replay = null;

// later... load from byte array and play back
var ms = new MemoryStream(message.Value.Bytes, offset, msg.ByteCount);
inputEventTrace.ReadFrom(ms);

if (replay == null)
{
    replay = inputEventTrace.Replay().WithAllDevicesMappedToNewInstances();
}
                   
replay.Rewind();
replay.PlayAllEvents();
                   
inputEventTrace.Clear();

Hello thep3000, thank your for your response. Recording is working and replay during the same Playmode. But if i return to editor and go to playmode again. Then Replay is not working anymore. I save it to a file and load it… and it plays… but controllers are standing still.

The Sample is pretty much identical to your code but uses

            // Start replay.
            if (m_SimulateOriginalTimingOnReplay)
                m_ReplayController.PlayAllEventsAccordingToTimestamps();
            else
                m_ReplayController.PlayAllFramesOneByOne();

            m_ChangeEvent?.Invoke(Change.ReplayStarted);

instead of PlayAllEvents

but I guess it should work the same way, right?

Check the input debugger (Window → Analysis → Input Debugger) … check that there aren’t duplicated devices during the playback. Double click on a device and see if data is coming through. Debugging | Input System | 1.0.2

@thep3000 Why did unity removed input recorder in new versions of input system?

Here it implies the same code is still part of the new InputSystem package from version 1.6.3.
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.6/manual/Debugging.html#other-tips

And from the API:
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.6/api/UnityEngine.InputSystem.LowLevel.InputEventTrace.html#UnityEngine_InputSystem_LowLevel_InputEventTrace_WriteTo_System_IO_Stream_

https://docs.unity3d.com/Packages/com.unity.inputsystem@1.6/api/UnityEngine.InputSystem.LowLevel.InputEventTrace.ReplayController.html

Anyone fixed this issue? I’m testing with a XR device trying to record the Headset + controller position. Record and replay works within the same play session. But if I stop the session and go to restart it via editor, it doesn’t work any more. Suspect it’s something to do with instance ID? Any help is appreciated.

Same issue here

You can check here, im just doing a pull request, these changes are working perfectly for my use case, i can just replay the whole VR gameplay, no issues at all.
There was a problem with device usages not being serialized, and also it adds to another problem that the headset rotation is always overriden by the real headset, to workarround this, you also just need to set your Tracked Pose Driver component rotation input to Passthrough, so the last device (the created copy) overrides the real headset every time you replay, this this whole code is compatible with older input system versions upto 14.x
Just, with these changes setting Create new devices on replay, and everything should go fine as long as you have your hmd rotation to passthrough