Input freezes for several seconds shortly after repeatedly entering Play mode

I’ve had a problem for several months using the new input systems, where after entering Play mode for the second or more times, after ~10-20 seconds the input system will stop updating for several seconds. Restarting the editor temporarily fixes the issue.

I’m currently using Unity 2019.3.2f1, input system package preview.5-1.0.0. Note that it has occurred for the last few Unity and package versions.

  • Enter Play mode.
  • Input works as normal.
  • End Play mode.
  • Enter Play mode again.
  • Input works as normal.
  • After ~10-20 seconds, inputs are frozen, causing held key presses to remain held.
  • After several more seconds, play continues as normal.

As I’m in an ECS project and using addressables, I’m not using any of the input system’s provided monobehaviours, but instead use my own simple manager monobehaviour.

This is how I’m listening for devices:

private void Awake()
{
    InputUser.listenForUnpairedDeviceActivity = 1;
    InputUser.onUnpairedDeviceUsed += InputUser_onUnpairedDeviceUsed;
}

And when a device is detected:

public void Initialize(InputDevice inputDevice, InputActionAsset inputActionAssetPrefab)
{
    var user = InputUser.PerformPairingWithDevice(inputDevice);

    m_InputActionAsset = Object.Instantiate(inputActionAssetPrefab);
    m_Map = m_InputActionAsset.FindActionMap("Player");

    user.AssociateActionsWithUser(m_Map);

    m_MoveAction = m_Map.FindAction("Move");
    m_UseAction = m_Map.FindAction("Use");
    m_BackAction = m_Map.FindAction("Back");

    m_Map.Enable();
}

I’ve tried toggling the scene/domain editor options and toggling burst, neither of which affect the issue. During the issue, the game does not stop or lag at all - only the input system stops updating.

Note: as a separate issue, when not reloading both scene and domain, I need to call a internal function, otherwise repeated plays do not register any devices whatsoever.

[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void RunOnStart()
{
    var t = typeof(InputUser).GetMethod("ResetGlobals", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
    t.Invoke(null, null);
}

Thanks

3 Likes

I’ve just discovered the input debugger, and have noticed that the event times start in the negative. The moment that they reach 0 time, the freeze occurs.

This was my event list when spamming the keyboard.

5539072--569794--upload_2020-3-1_16-7-49.png

I’m having the exact same issue. I’m tired of the new input system. It’s so odd to use and overcomplicated for everything. I wish I knew how to revert to the old system though.

@Richay Would you mind filing a ticket with the Unity bug reporter? The problem sounds very odd and we should have a closer look.

The times going negative would be expected in this case. In public APIs, input event time is put on the Time.realTimeSinceStartup timeline. That timeline, however, resets to 0 every time the editor enters play mode. Internally, the events sit on a continuous timeline separate from realTimeSinceStartup but when there’s an event that was generated before realTimeSinceStartup resets to 0, the outcome will be a negative timestamp in the public APIs.

However, the freeze at 0 time is interesting and definitely not an expected outcome.

Yeah, we don’t yet support the no-domain-reload setting. It’s on the list.

Could you provide some more details about what in particular you found odd to use / overcomplicated?

1 Like

Logged: http://fogbugz.unity3d.com/default.asp?1225960

2 Likes

Verified, having the same exact problem! Timestamp starts at just before -10 seconds,
stops accepting input just before the 0 second mark, then accepts input again about 3 seconds after.

I posted my Input Debugger showing the result.
Using Unity 2019.3.10f1 Personal on Windows 10.
(If more information would be helpful, let me know!)

5860342--622939---20-05-17 01_38.png

1 Like

Is there any update on this issue? I’ve run into this issue as well and it’s really tedious dealing with this freeze every time I press play

Is update mode set to manual?

My guess is the freeze results from a massive input event buffer having accumulated. There’s currently no good guards in place against that. And specifically in manual mode, while the system is supposed to flush the queue automatically when not in play mode, could be that’s not happening. Reactivated the 1225960 ticket. We’ll have a look.

Please do investigate, as we have had this same issue for weeks now. Starting Play Mode, then after a few seconds no inputs are accepted for about 3 seconds. After that it does not occur again until the next starting of Play Mode.

I also noticed that while using a lot of Debug.Logs in Play Mode, the performance of the new Input System seems to drop a lot. So much that it accumulates more and more events until it stutters for a second, then resumes as normal, until the cycle begins again.

(Both the first no-inputs-problem and the stuttering do not happen in a build, by the way. Only in editor while in Play Mode.)

Is update mode set to manual?

Hey, sorry for the delay. Today, I could not reproduce the bug, since it did not happen today. (But I did not work on the project in-between, so nothing has changed. So maybe a cache thing?)

I am using the update mode “Process Events in Dynamic Update”.

I am currently using scripted events like so:

inputMove = gameplayActionMap.FindAction("Move");
inputMove.performed += OnInputMoveChanged;
inputMove.canceled += OnInputMoveChanged;

Also, if I set the update mode to Fixed Update or Manual (and then update in FixedUpdate) my events come in pretty choppy, so I can’t really use them for stuff like camera movement by mouse. Is that related to the issue? With dynamic update mode it’s fine, since I assume I am not tied to FixedUpdate anymore?

Same timings for me!

Can second this. Just noticed the issue starting to crop up occasionally and it’s producing concerns whether or not this will affect builds.

This bugged me alot, always trying to find what am i doing wrong. Sometimes it goes away after restarting editor but always come back.

It’s been more than 6 months and I’m still experiencing this issue myself. There’s really no way to fix it isn’t there?

Has there been any resolution to this problem? Experiencing the EXACT things described above (freezes a little bit in, and then no input works for ~3 seconds, with the key that was last held down still “held” (if you’re moving left, you just keep going left). I noticed that if I pause the game in the editor mode, it immediately resolves the issue.

The issue has still not been addressed. I’ve had to allow both input mode to be used, and I use Input when debugging. There’s no other way around it.

I’ve still got this issue too. I thought I’d fixed it but when I transitioned my code to ECS and access the InputAction in a System it started happening again and undoing all the changes didn’t fix it (probably a coincidence when it stopped working, doubt it’s anything to do with ECS).

Is the issue only when playing in the editor? Is it usable in a full build or does a hacky fix need to be used to trigger the freeze without any movement before giving access to the user?

I have got the same issue… Not sure how to proceed.

Same issue