Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Input freezes for several seconds shortly after repeatedly entering Play mode

Discussion in 'Input System' started by Richay, Mar 1, 2020.

  1. Richay

    Richay

    Joined:
    Aug 5, 2013
    Posts:
    109
    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:

    Code (CSharp):
    1. private void Awake()
    2. {
    3.     InputUser.listenForUnpairedDeviceActivity = 1;
    4.     InputUser.onUnpairedDeviceUsed += InputUser_onUnpairedDeviceUsed;
    5. }
    And when a device is detected:

    Code (CSharp):
    1. public void Initialize(InputDevice inputDevice, InputActionAsset inputActionAssetPrefab)
    2. {
    3.     var user = InputUser.PerformPairingWithDevice(inputDevice);
    4.  
    5.     m_InputActionAsset = Object.Instantiate(inputActionAssetPrefab);
    6.     m_Map = m_InputActionAsset.FindActionMap("Player");
    7.  
    8.     user.AssociateActionsWithUser(m_Map);
    9.  
    10.     m_MoveAction = m_Map.FindAction("Move");
    11.     m_UseAction = m_Map.FindAction("Use");
    12.     m_BackAction = m_Map.FindAction("Back");
    13.  
    14.     m_Map.Enable();
    15. }
    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.

    Code (CSharp):
    1. [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
    2. private static void RunOnStart()
    3. {
    4.     var t = typeof(InputUser).GetMethod("ResetGlobals", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
    5.     t.Invoke(null, null);
    6. }
    Thanks
     
    Last edited: Mar 1, 2020
  2. Richay

    Richay

    Joined:
    Aug 5, 2013
    Posts:
    109
    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.

    upload_2020-3-1_16-7-49.png
     
  3. StuwuStudio

    StuwuStudio

    Joined:
    Feb 4, 2015
    Posts:
    165
    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.
     
  4. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    @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?
     
    graeioume likes this.
  5. Richay

    Richay

    Joined:
    Aug 5, 2013
    Posts:
    109
    Last edited by a moderator: Apr 29, 2020
    graeioume and Rene-Damm like this.
  6. graeioume

    graeioume

    Joined:
    Aug 29, 2017
    Posts:
    1
    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!)
     

    Attached Files:

    Last edited: May 17, 2020
    kp11soccer likes this.
  7. Sparkkie

    Sparkkie

    Joined:
    Oct 10, 2018
    Posts:
    12
    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
     
  8. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    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.
     
  9. RyFridge

    RyFridge

    Joined:
    Apr 7, 2014
    Posts:
    52
    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.)
     
  10. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Is update mode set to manual?
     
  11. RyFridge

    RyFridge

    Joined:
    Apr 7, 2014
    Posts:
    52
    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:
    Code (CSharp):
    1. inputMove = gameplayActionMap.FindAction("Move");
    2. inputMove.performed += OnInputMoveChanged;
    3. 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?
     
  12. kp11soccer

    kp11soccer

    Joined:
    Nov 17, 2018
    Posts:
    1
    Same timings for me!
     
  13. Khaeops

    Khaeops

    Joined:
    Dec 28, 2014
    Posts:
    31
    Can second this. Just noticed the issue starting to crop up occasionally and it's producing concerns whether or not this will affect builds.
     
  14. waseku

    waseku

    Joined:
    Jun 28, 2020
    Posts:
    7
    This bugged me alot, always trying to find what am i doing wrong. Sometimes it goes away after restarting editor but always come back.
     
  15. StuwuStudio

    StuwuStudio

    Joined:
    Feb 4, 2015
    Posts:
    165
    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?
     
  16. SaroVati

    SaroVati

    Joined:
    Jun 7, 2015
    Posts:
    5
    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.
     
  17. StuwuStudio

    StuwuStudio

    Joined:
    Feb 4, 2015
    Posts:
    165
    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.
     
  18. SagaraBattousai

    SagaraBattousai

    Joined:
    Oct 7, 2020
    Posts:
    1
    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?
     
  19. Gmoolenbroek

    Gmoolenbroek

    Joined:
    Jan 5, 2020
    Posts:
    5
    I have got the same issue.. Not sure how to proceed.
     
  20. FrickinSilly

    FrickinSilly

    Joined:
    Feb 19, 2020
    Posts:
    53
    Same issue
     
  21. TheGreatHeroStudios

    TheGreatHeroStudios

    Joined:
    May 16, 2020
    Posts:
    1
    Same issue here, but only on my laptop. Has anyone tested whether this affects standalone builds? I haven't tested this, but it would be the difference between a minor inconvenience in testing and a major bug for players.
     
  22. DeanyLu

    DeanyLu

    Joined:
    Jul 11, 2018
    Posts:
    1
    Same issue between 7s and 10s after game start.
    (Even with really few objects on the scene)
     
  23. radiatoryang

    radiatoryang

    Joined:
    Jul 7, 2014
    Posts:
    19
    Haha I have this bug too, happy 2021 everyone!!

    If I restart the editor, it goes away for a little while... hopefully it doesn't affect builds... but it probably does lol

    If the problem is the input buffer / input history, I wish there was an easy way to reset or flush out all these negative timestamp events
     
    Last edited: Jan 7, 2021
  24. szantner

    szantner

    Joined:
    May 15, 2015
    Posts:
    2
    Hey everyone, same here in 2020.2.1f The problem only exists when running in the editor, the build works fine.
     
  25. blazingcometgames

    blazingcometgames

    Joined:
    Jan 21, 2020
    Posts:
    3
    One thing I narrowed down; it happens after waking up my computer from hibernate with Unity already open. So I have to close it and reopen it each day, which is unfortunate given how long opening it can take sometimes. Not sure if that helps narrow down the why behind it though.
     
    vamidi16 likes this.
  26. RoiIam

    RoiIam

    Joined:
    Dec 30, 2015
    Posts:
    1
    This also happens to me, reopening solves it, I'm on 2019.4.8f1 IS v1.0.1.
     
    vamidi16 likes this.
  27. QuadrantGames

    QuadrantGames

    Joined:
    Jan 10, 2016
    Posts:
    20
    Getting this as well, Unity 2019.4.16f1 IS v 1.0.2
     
  28. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,504
    Happy one year anniversary on reporting this bug and not getting it fixed!

    Maybe it's time to realize it's not going to be fixed.

    Just remember this the next time a Unity employee tells you to submit a bug.
     
    Enmoore likes this.
  29. oakus

    oakus

    Joined:
    Dec 27, 2012
    Posts:
    15
    I have this too on all my projects using the Input System. Need to reopen the project every time I wake computer up from hibernation. Please fix this or at least give us some way to "flush" or "clear" the buffer manually.

    This is very annoying.
     
  30. darashayda

    darashayda

    Joined:
    Jun 27, 2020
    Posts:
    422
    For all of those who are sick of this bug based on a hint by Rene-Damm.

    Force a FLUSH into the IO queues, I rolled a dice to solve this problem on my Android build (iOS works fine). The Accelometer on Android works just find, until adding I added the Input Fields and upon any event on the Input Fields in a few seconds nearly freezes the game.

    This is a KLUDGE: in order to force FLUSHES

    1. Make an empty game object

    2. Add a Fixed Update

    void FixedUpdate()
    {
    if (
    Time.frameCount % interval == 0 && Globals.interrupt==false)
    {
    if (gravitySensor != null)
    {

    InputSystem.DisableDevice(gravitySensor);

    InputSystem.EnableDevice(gravitySensor);


    }
    }

    }

    I set the interval to 32 since freq for my Accelometer was set to the same amount.

    My fluid physics simulation now runs smooth as water!

    The Input Sys folks need to treat their code like an OS, we need to have something like IOCTL calls from USER LAYER which is us the poor game dev guys, to the guts of the Input sys (the super duper Unity guys and gals).

    https://man7.org/linux/man-pages/man2/ioctl.2.html

    IOCTL will then allow the application layer programmers fiddle with the underlying OS with some sane interface e.g. force flushes vs. my butcher code above.

    Hope this might help some people who are stuck, at least have solution to finish their games.

    Dara
     
  31. darashayda

    darashayda

    Joined:
    Jun 27, 2020
    Posts:
    422
    Forgot to mention you should be able to do this for any other device param, not just Accelorameter.
     
  32. menderbug

    menderbug

    Joined:
    May 14, 2018
    Posts:
    26
    Just wanted to add that I've been seeing the same issue for a while, currently on 2020.1.6f1.
     
  33. Harry_J_Unity

    Harry_J_Unity

    Unity Technologies

    Joined:
    Jan 31, 2020
    Posts:
    4
    Hey guys, could you submit a new bug report regarding this with a reproduction project where it's constantly reproducible?

    Thanks
     
  34. darashayda

    darashayda

    Joined:
    Jun 27, 2020
    Posts:
    422
    I did already, and Unity support ignored it as have ignored previously! So it is sitting there on their ticket system ignored!

    Dara
     
  35. Harry_J_Unity

    Harry_J_Unity

    Unity Technologies

    Joined:
    Jan 31, 2020
    Posts:
    4
    Hey Dara,

    Can you also submit a bug report through Unity's bug reporter? Preferably with a project attached where the issue is reproducible.

    Thanks
     
  36. RedHillbilly

    RedHillbilly

    Joined:
    Mar 24, 2014
    Posts:
    39
    Same issue here as well, inputs freezes for a couple of seconds (if this happens while a key is down that input will continue to be given until unfrozen). Had this bug for a while, but doesn't seem to affect builds.

    Doesn't happen all the time, but once it occurs it will happen until the computer is restarted, looks like a buffering issue?

    Kind of hard to create a reproducible example project given the difficulty to pinpoint the origin.

    Any update on resolving the issue?
     
  37. Ezzataii

    Ezzataii

    Joined:
    Jul 15, 2019
    Posts:
    2
    I'm experiencing the same bug as everyone else here.
     
  38. Superstition

    Superstition

    Joined:
    May 22, 2015
    Posts:
    12
    This bug still persists. Mine is -13s and continues from 0 to positive 13.
    Fix your S***.
     
  39. jonathan_timmerlid

    jonathan_timmerlid

    Joined:
    Feb 15, 2018
    Posts:
    7
    We also have this problem. Input is locked/freezed for 10 seconds at some point during every start of the game in the editor. Is there anything one can do in the scripts as a temporary workaround? (Unity 2020.3.0f1)
     
  40. andrew_oc

    andrew_oc

    Unity Technologies

    Joined:
    Apr 16, 2021
    Posts:
    77
    Hi all. For anyone experiencing this issue, it would really help us narrow it down if you could post what version of the input system package you're using.

    Thanks
     
  41. RedHillbilly

    RedHillbilly

    Joined:
    Mar 24, 2014
    Posts:
    39
    Hei @andrew_oc
    Over the last couple of weeks I've tried to pay more careful attention to when this was happening and as far as I can tell this is what seems to occur to me (Using Unity 2021.1.3f1 with the Input System package 1.02 on Windows):
    • as @solidmoose32 mentioned, I'm pretty sure this only happens if I leave Unity open, put the PC to hibernate, and then resume after waking up the PC.
    • I think this only happens with keyboard inputs, or at least it often happens that they keyboard is frozen but my joystick still works.
    • The inputs usually work for a couple of seconds and then freeze, keeping the input at the moment the inputs freeze (so if I'm going right at the moment of freezing, it keeps going right even if the key is not down anymore until it unfreezes).
    I'm gonna try to make a reproducible project, but given that this does not seem to be only happening because of unity but actually windows <-> unity interaction this seems difficult.

    Thanks for looking into that!

    Cheers
     
  42. neil_nerial

    neil_nerial

    Joined:
    Jan 5, 2021
    Posts:
    1
    I've been experiencing this issue for quite some time on a large multi-developer project, and noticed it today on a brand new minimal project so decided to take a closer look and stumbled upon this thread.

    Following on from RedHillbilly's experience, I made a few tests. It seems to happen:
    • In Windows but not MacOS
    • In all version of Input System (v1.0.0, v.1.0.1 and v1.0.2)
    • In both Update and Fixed Update modes
    • On mouse and keyboard, but not XInput gamepad
    • Only after resuming from hibernation, until the editor is restarted
     
    NotaNaN and RedHillbilly like this.
  43. nongbenzgames

    nongbenzgames

    Joined:
    Oct 8, 2018
    Posts:
    19
    I often always keep Unity open through hibernations and get this problem too. With all versions of InputSystem even preview.
     
  44. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,606
    I get this issue too, specifically on my laptop.

    1.0.2 currently, but it also happened with 1.0.0 and I believe I also tried 1.0.1 in the middle.

    I don't know about "constantly", but I get it a lot on my laptop with the project I submitted on my recent bug report about this.

    Thanks for this. Next time I run into it I'll try a restart to see if it helps. Surely I've tried that before, but... who knows? Hah.
     
    NotaNaN likes this.
  45. Tkrain42

    Tkrain42

    Joined:
    Jul 25, 2015
    Posts:
    43
    Glad I noticed this thread. I've been experiencing this, and it's got me close to just going back to the old input system that I know and love so well.
    Like the others, I often leave my project open and sleep/hybernate the computer. Just restarted the project, and it seems to be working correctly. This is, however, a workaround, not a fix.
     
  46. zdolezal

    zdolezal

    Joined:
    Sep 27, 2017
    Posts:
    75
    Having this issue as well and yeah, I am hibernating my PC with Unity open :)
     
  47. strictfp

    strictfp

    Joined:
    Jul 29, 2020
    Posts:
    13
    Same issue here.
     
  48. flippi273

    flippi273

    Joined:
    Nov 17, 2018
    Posts:
    24
    I'm coming from this other thread that also is reporting this issue and figured I'd double post my latest one:

    Sadly I cannot share my repo and it doesn't happen on my partner's machine. Something I recently noticed was that click input still works through the editor panes. What I mean by that is that in our game, you click where you want the player to go, but when the issue is going on, the inputs are ignored however if I click in certain areas of the unity editor (see screenshots below for example) the click does get registered in-game and my player will walk in that direction. This doesn't fix the issue though I still have to wait some time. Also, this makes the game loose focus and so it only works on the first click



     
  49. cp-

    cp-

    Joined:
    Mar 29, 2018
    Posts:
    78
    @Rene-Damm @HaroldasJ @andrew_oc It seems the good people of this thread have found the root of this issue, so would you mind sharing some insight of what your internal status of resolving this is?

    Guys, please, just help us out. Or at least show some good will.
     
  50. HeceduMG

    HeceduMG

    Joined:
    Nov 8, 2019
    Posts:
    4
    I'm here to report that I'm experiencing this issue on Unity 2020.3.12f1. The issue seems to solve itself when I restart the editor but also comes back after a while. Is my game going to have this same behavior when I ship it? Thats my biggest concern about this bug :)