jitter_stutter.rst 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. .. _doc_jitter_stutter:
  2. Fixing jitter and stutter
  3. =========================
  4. What are jitter and stutter?
  5. ----------------------------
  6. *Jitter* and *stutter* are two different alterations to visible motion of objects on screen that may affect a game,
  7. even when running at full speed. These effects are mostly visible in games where the world moves at a constant speed
  8. in a fixed direction, like runners or platformers.
  9. Distinguishing between them
  10. ---------------------------
  11. A game running at a normal framerate without exhibiting any effect will appear smooth:
  12. .. image:: img/motion_normal.gif
  13. A game exhibiting *jitter* will shake constantly in a very subtle way:
  14. .. image:: img/motion_jitter.gif
  15. Finally, a game exhibiting *stutter* will appear smooth, but appear to *stop* or *roll back a frame* every few seconds:
  16. .. image:: img/motion_stutter.gif
  17. Jitter
  18. ------
  19. There can be many causes of jitter, the most typical one happens when the game *physics frequency* (usually 60 Hz) runs
  20. at a different resolution than the monitor refresh rate. Check whether your monitor refresh rate is different from 60 Hz.
  21. This is generally not a problem, given that refresh rates higher than 60 Hz are barely visible to the human eye, and
  22. starting with Godot 3.1, a frame timer was introduced that tries to synchronize with refresh as best as possible.
  23. Sometimes only some objects appear to jitter (character or background). This happens when they are processed in different
  24. time sources (one is processed in the physics step while another is processed in the idle step). Godot 3.1 does some
  25. improvements to this, from allowing kinematic bodies to be animated in the regular _process loop, to further fixes in the
  26. frame timer.
  27. Stutter
  28. -------
  29. Stutter may happen due to two different reasons. The first, and most obvious one, is the game not being able to keep full
  30. framerate performance. Solving this is game specific and will require optimization.
  31. The second is more complicated, because it is often not associated to the engine or game but the underlying operating system.
  32. Here is some information regarding stutter on different OSs.
  33. Windows
  34. ^^^^^^^
  35. Windows is known to cause stutter in windowed games. This mostly depends on the hardware installed, drivers version and
  36. processes running in parallel (e.g. having many browser tabs open may cause stutter in a running game). To avoid this,
  37. starting with 3.1, Godot raises the game priority to "Above Normal". This helps considerably but may not completely eliminate
  38. stutter.
  39. Eliminating this completely requires giving your game full privileges to become "time critical", which is not advised.
  40. Some games may do it, but it is advised to learn to live with this problem, as it is common for Windows games and most users
  41. won't play games windowed (games that are played in a window, e.g. puzzle games, will usaully not exhibit this problem anyway).
  42. For fullscreen, Windows gives special priority to the game so stutter is no longer visible and very rare.
  43. This is how most games are played.
  44. Linux (X11)
  45. ^^^^^^^^^^^
  46. Stutter may be visible on Desktop Linux, but this is usually associated with different video drivers and compositors.
  47. Nouveau drivers often exhibit this, while AMD or NVidia proprietary don't. Some compositors may also trigger this problem
  48. (e.g. KWin), so it is advised to try using a different one to rule it out as the cause.
  49. There is no workaround for driver or compositor stuttering other than reporting it as an issue to the driver or compositor
  50. developers.
  51. macOS
  52. ^^^^^
  53. Generally, macOS is stutter-free, although recently some bugs were reported when running on fullscreen (this is a macOS bug).
  54. If you have a machine exhibiting this behavior, please let us know.
  55. Android
  56. ^^^^^^^
  57. Generally, Android is stutter and jitter-free because the running activity gets all the priority. That said, there may be
  58. problematic devices (older Kindle Fire is known to be one). If you see this problem on Android, please let us know.
  59. iOS
  60. ^^^
  61. iOS devices are generally stutter-free, but older devices running newer versions of the operating system may exhibit problems.
  62. This is generally unavoidable.
  63. Reporting stutter or jitter problems
  64. ------------------------------------
  65. If you are reporting a stutter or jitter problem (opening an issue) not caused by any of the above reasons, please specify very
  66. clearly all the information possible about device, operating system, driver versions, etc. This may help to better troubleshoot it.
  67. Also make sure to use the correct term (jitter or stutter) based on the exhibited behavior. This will help understand your issue much faster.
  68. Provide a project that can be used to reproduce the issue, and if possible a screen capture demonstrating the bug.