Search Unity

Unity stutters and hitches even in empty scenes, Unreal does not

Discussion in 'Editor & General Support' started by rawalanche, Jan 9, 2019.

  1. ElijahRaymond

    ElijahRaymond

    Joined:
    May 16, 2013
    Posts:
    1
    This stuttering happens in every Unity game.
     
  2. Zalton

    Zalton

    Joined:
    Oct 2, 2013
    Posts:
    2
    I have the same thing happening to me in, even in a simple new 2d project. When I build and run the issue is not present so it is something inside the editor. I ran the profiler (which I have 0 experience with btw) and seen that when the hiccup happens in the EditorLoop (73 ms).

    upload_2020-2-8_21-8-45.png
     
  3. HassanKhallouf

    HassanKhallouf

    Joined:
    Mar 5, 2015
    Posts:
    52
    2019.4, still an issue
     
  4. RecursiveRuby

    RecursiveRuby

    Joined:
    Jun 5, 2013
    Posts:
    163
    I had this bug quite some time ago and upgraded to some version of 2019 I forget which exactly but it seemed to have resolved it. However since upgrading to 2020.1 it appears to be back again? Anyone else getting this?
     
  5. HassanKhallouf

    HassanKhallouf

    Joined:
    Mar 5, 2015
    Posts:
    52
    for my case, it turned out to be G-Sync, I disabled it from NVIDIA settings and the stuttering stopped
     
  6. TheCheeb

    TheCheeb

    Joined:
    Aug 30, 2020
    Posts:
    2
    Disabling G-Sync for me didn't seem to help much. Stuttering was still an issue in the Scene window.
     
  7. HassanKhallouf

    HassanKhallouf

    Joined:
    Mar 5, 2015
    Posts:
    52
    for the record my issue was related to G-Sync screen, I disabled G-Sync from NVIDIA settings and the stuttering is gone
     
  8. RecursiveRuby

    RecursiveRuby

    Joined:
    Jun 5, 2013
    Posts:
    163
    I've never even had G-Sync enabled and I'm still getting this issue unfortunately.
     
  9. RecursiveRuby

    RecursiveRuby

    Joined:
    Jun 5, 2013
    Posts:
    163
    Hey so I figured something interesting out. It is definitly a mouse polling issue. I was under the impression that I had set my mouse polling to be lower via the logitech app. This however was not the case after I decided to check if my polling rate ACTUALLY changed using https://zowie.benq.com/en/support/mouse-rate-checker.html which it had not. I figured out how to actually change my polling rate and unity is much smoother. Not exactly a solution and its still a problem that persists but something to consider for anyone searching this issue. Check that your mouse polling rate is actually lower than what you think it is using the site that I linked.

    Also as a side note for anyone using a logitech mouse polling rate can only be changed if you have it set to onboard memory. It may say its 125, 500 or whatever, but its not actually. Not unless you're using onboard memory.
     
  10. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    Since Unity 2019.3? they added the "Interaction Mode" to the preferences window.

    Can you check if it improves editor performance for you if you set it to "Custom" and set the Frame Throttling value to 16 or 33? The higher the value, the "better" Unity should perform, but it might introduce some input lag.

    "No Throttle" causes the most overhead. "Monitor Refresh-Rate" can cause a lot of overhead too, if you have a 120hz Monitor for example.
     
  11. RecursiveRuby

    RecursiveRuby

    Joined:
    Jun 5, 2013
    Posts:
    163
    2019.3 actually fixed the issue for me. It regressed when I upgraded to 2020.1. I wasn't aware of the Interaction Mode. I've tried playing around with it a bit and unfortunately it doesn't seem to do anything. I even wrote a custom script to capture how many mouse drags events are published per frame, just to tell if anything is actually different. which it isn't. Even playing around with all the different type of Interaction Mode settings the event count remains consistent.

    I'm getting around 68+ mouse drag events when dragging the mouse per frame and a similar amount of layout events as well. Since layout events seems to be published just before a mouse drag event. On average I'm getting 140 events per frame which consist largely of mouse drag and layout events. This seems to be the same testing on both a 144hz monitor and a 240hz monitor.

    Although in writing this I've found setting "wantsLessLayoutEvents" in the EditorWindow to false actually fixes the issue. I've tried this in the past to no success. I'm not sure why it works now. Maybe something to do with the latest unity update. I'm currently using 2020.1.6f1. As a comparison using this I'm getting around 5 events per frame while dragging compared to 140 while it is disabled.

    Also as a final note with "wantsLessLayoutEvents" false (the default) the average amounts of events I'm getting per frame on different mouse polling settings are as follow..
    • 1000hz - 140 events
    • 500hz - 10 events
    • 240hz - 4 events
    • 125hz - 4 events
     
    Peter77 likes this.
  12. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    Interesting. In what EditorWindow(s) do you set "wantsLessLayoutEvents"?
     
  13. RecursiveRuby

    RecursiveRuby

    Joined:
    Jun 5, 2013
    Posts:
    163
    Just a custom editor window I'm making. I just set it when its created. Also since writing that I've found out that it doesn't 100% completely alleviate the issue but it does help a large amount. So much so that the lag is only apparent when a lot is happening.

    For example I mostly find this lag annoying because I've been developing a tool using a node editor I wrote. When moving around the canvas the lag is extremely apparent. With just one singular node and wantsLessLayoutEvents as true I get much less lag but on a canvas with maybe 20+ nodes I will see it stutter a bit. Despite being massively more performant with wantsLessLayoutEvents on. Off the top of my head with wantsLessLayoutEvents off on a large canvas with 20+ nodes performance is around 4-6fps with wantsLessLayoutEvents on performance is around 40fps and with polling set to a low hz I get 60+ easily. It doesn't seem to matter whether or not wantsLessLayout events is on or not with polling set low but I've not looked a huge amount into it.

    Also I've made sure my node editor isn't the bottle neck by creating very simple examples with the lag being apparent in them. Its just most noticeable in the editor when using an editor that visually moves elements around while dragging the mouse.
     
    Last edited: Sep 24, 2020
  14. ElectroLlama

    ElectroLlama

    Joined:
    Dec 8, 2019
    Posts:
    2
    This one has been killing me for a while. Changing the mouse polling rate did not fix my issues. There are a few posts out there with varying solutions (turn off GSync, disable player logging, force use of OpenGL, tweaking "Interaction Mode" frame throttling, changing mouse polling) all of which did not work or only partially worked, in either 2019.4 or 2020.2. The problem is definitely mouse related though -- running the same control examples that come with the Input System package work fine with gamepads but suffer terrible stutter in the editor with mouse moves.

    I do not know enough about Unity yet to set the wantsLessLayoutEvents flag on the current editor windows, is there a simple way to do that?

    I have found a solid workaround that works for me -- The Input System package also adds an Input Debugger (Window -> Analysis -> Input Debugger). Simply running that in an un-docked window fixes everything. I suppose that it's intercepting the mouse events in some manner but I don't know what's happening under the hood.

    --EDIT-- This continued to be on occasional issue for me, but I found that disabling the GeForce Experience in-game overlay got rid of the problem.
     
    Last edited: May 22, 2021
  15. Kychris

    Kychris

    Joined:
    Apr 21, 2017
    Posts:
    2
    That worked for me! 2020.3.20f1 on MacBook Pro. Thanks!
     
    Peter77 likes this.
  16. Glader

    Glader

    Joined:
    Aug 19, 2013
    Posts:
    456
  17. cwbeta

    cwbeta

    Joined:
    Jan 12, 2017
    Posts:
    32
  18. stephc-int13

    stephc-int13

    Joined:
    Oct 21, 2017
    Posts:
    4
    +1 This issue is not only affecting the editor but the whole engine.

    The high polling rate on a mouse will drastically reduce the performance, but it seems that even a standard polling rate (125Hz) is far from zero cost.

    The internal events handler is not doing the work correctly. Maybe related to a mulithreading lock or a loop that should not be there... In any case this is not rocket science and it would be an easy win for general performance of the engine.
     
  19. rossetagotstoned

    rossetagotstoned

    Joined:
    Jan 12, 2020
    Posts:
    8
    This is issue mostly caused by custom preferences from NVIDIA Control Panel, I did reset everything to application controlled and it's fixed.

    Also this can be caused by G-Sync if it be set to Windowed and Full Screen mode, You need to set it to be enable for Only Full Screen Applications.
     
    Last edited: Nov 27, 2022
  20. Setmaster

    Setmaster

    Joined:
    Sep 2, 2013
    Posts:
    239
    Gsync doesn't seem to be related, at least on my end. It being on/off, fullscreen, etc doesnt change anything. Now having my razer polling rate to 125-500 fixes the issue, anything higher like 1000 and the stuttering happens. Unity 2022.2.18