bisecting_regressions.rst 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. .. _doc_bisecting_regressions:
  2. Bisecting regressions
  3. =====================
  4. .. highlight:: shell
  5. Bisecting is a way to find regressions in software. After reporting a bug on the
  6. `Godot repository on GitHub <https://github.com/godotengine/godot>`__, you may
  7. be asked by a contributor to *bisect* the issue. Bisecting makes it possible for
  8. contributors to fix bugs faster, as they can know in advance which commit caused
  9. the regression. Your effort will be widely appreciated :)
  10. The guide below explains how to find a regression by bisecting.
  11. What is bisecting?
  12. ------------------
  13. Godot developers use the `Git <https://git-scm.com/>`__ version control system.
  14. In the context of Git, bisecting is the process of performing a manual
  15. `binary search <https://en.wikipedia.org/wiki/Binary_search_algorithm>`__
  16. to determine when a regression appeared. While it's typically used for bugs,
  17. it can also be used to find other kinds of unexpected changes such as
  18. performance regressions.
  19. Using official builds to speed up bisecting
  20. -------------------------------------------
  21. Before using Git's ``bisect`` command, we strongly recommend trying to reproduce
  22. the bug with an older (or newer) official release. This greatly reduces the
  23. range of commits that potentially need to be built from source and tested.
  24. You can find binaries of official releases, as well as alphas, betas,
  25. and release candidates `here <https://godotengine.org/download/archive/>`__.
  26. .. danger::
  27. Project files may be incompatible between Godot versions.
  28. **Make a backup of your project** before starting the bisection process.
  29. Going from the oldest to the newest build generally reduces the risk of the
  30. project not being able to successfully open in the editor, thanks to
  31. backwards compatibility. Try to reduce your project to the smallest
  32. repeatable example too. The more minimal the project is, the more likely
  33. you'll be able to open it without compatibility issues in newer engine
  34. versions.
  35. The Git bisect command
  36. ----------------------
  37. If you've found a build that didn't exhibit the bug in the above testing
  38. process, you can now start bisecting the regression. The Git version control
  39. system offers a built-in command for this: ``git bisect``. This makes the
  40. process semi-automated as you only have to build the engine, run it and try to
  41. reproduce the bug.
  42. .. note::
  43. Before bisecting a regression, you need to set up a build environment to
  44. compile Godot from source. To do so, read the
  45. :ref:`Compiling <toc-devel-compiling>` page for your target platform.
  46. (Compiling Godot from source doesn't require C++ programming knowledge.)
  47. Note that compiling Godot can take a while on slow hardware (up an hour for
  48. each full rebuild on a slow dual-core CPU). This means the full process can
  49. take up to several hours. If your hardware is too slow, you may want to stop
  50. there and report the results of your "pre-bisecting" on the GitHub issue so
  51. another contributor can continue bisecting from there.
  52. Determine the commit hashes
  53. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  54. To start bisecting, you must first determine the commit hashes (identifiers) of
  55. the "bad" and "good" build. "bad" refers to the build that exhibits the bug,
  56. whereas "good" refers to the version that doesn't exhibit the bug.
  57. You can use either a commit hash (like ``06acfccf8``), the tag of a stable
  58. release (like ``4.2.1-stable``), or a branch like ``master``.
  59. If you're using a pre-release build as the "good" or "bad" build, you can find
  60. the commit hash in the Project Manager in the lower-right corner, or in in the
  61. **Help > About Godot** dialog in the Godot editor. The version information will
  62. look something like ``v4.4.beta3.official [06acfccf8]``, and the commit hash is
  63. within the brackets, in this case ``06acfccf8``. You can click on the version
  64. information to copy it, including the commit hash.
  65. Alternately, you can browse the `interactive changelog
  66. <https://godotengine.github.io/godot-interactive-changelog/>`__ to find commits
  67. for all releases, including development builds. The commits will be listed as a
  68. range, like ``commits: a013481b0...06acfccf8``, and the second commit is the one
  69. you should use for bisecting. You can also browse the `Godot Archive
  70. <https://godotengine.org/download/archive/>`__, and find the commit hash within
  71. the release page linked from the **News** button.
  72. If you're using a stable release as the "good" or "bad" build, you can use the
  73. tag of that release directly, such as ``4.2-stable`` or ``4.2.1-stable``. A full
  74. list of release tags is available `on GitHub
  75. <https://github.com/godotengine/godot/tags>`__, and you can also find the actual
  76. commit hash that corresponds to a stable release there.
  77. To refer to the latest state of the master branch, you can use ``master``
  78. instead of a commit hash. Note that unlike tagged releases or snapshot commit
  79. hashes, ``master`` is a perpetually moving target.
  80. Build the engine
  81. ~~~~~~~~~~~~~~~~
  82. :ref:`Get Godot's source code using Git <doc_getting_source>`. Once this
  83. is done, in the terminal window, use ``cd`` to reach the Godot repository
  84. folder and enter the following command:
  85. .. code-block:: shell
  86. # <good commit hash> is hash of the build that works as expected.
  87. # <bad commit hash> is hash of the build exhibiting the bug.
  88. git bisect start
  89. git bisect good <good commit hash>
  90. git bisect bad <bad commit hash>
  91. Compile Godot. This assumes you've set up a build environment:
  92. .. code-block:: shell
  93. scons
  94. Run the engine
  95. ~~~~~~~~~~~~~~
  96. Run the binary located in the ``bin/`` folder and try to reproduce the bug.
  97. .. note::
  98. :ref:`Double-check the output file name <doc_introduction_to_the_buildsystem_resulting_binary>`
  99. in ``bin/`` to make sure you're actually running the binary you've just compiled.
  100. Different Godot versions will output binaries with different names.
  101. If the build **still** exhibits the bug, run the following command:
  102. .. code-block:: shell
  103. git bisect bad
  104. If the build **does not** exhibit the bug, run the following command:
  105. .. code-block:: shell
  106. git bisect good
  107. After entering one of the commands above, Git will switch to a different commit.
  108. You should now build Godot again, try to reproduce the bug, then enter ``git
  109. bisect good`` or ``git bisect bad`` depending on the result. You'll have to
  110. repeat this several times. The longer the commit range, the more steps will be
  111. required. 5 to 10 steps are usually sufficient to find most regressions; Git
  112. will remind you of the number of steps remaining (in the worst case scenario).
  113. Once you've completed enough steps, Git will display the commit hash where the
  114. regression appeared. Write this commit hash as a comment to the GitHub issue
  115. you've bisected. This will help in solving the issue. Thanks again for
  116. contributing to Godot :)
  117. .. seealso::
  118. You can read the full documentation on ``git bisect``
  119. `here <https://git-scm.com/docs/git-bisect>`__.