bisecting_regressions.rst 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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://downloads.tuxfamily.org/godotengine/>`__.
  26. If you have experience with Godot 3.x and can reproduce an issue with Godot 4.0,
  27. we recommend trying to reproduce the issue in the latest Godot 3.x version (if
  28. the feature exhibiting the bug is present in 3.x). This can be used to check
  29. whether the issue is a regression in 4.0 or not.
  30. - If the issue **is present** in 3.x, then you'll need to check whether the issue
  31. occurs in older 3.x versions as well.
  32. - If the issue is **not present** in 3.x, then you can try older 4.0 alphas and
  33. betas to determine when the regression started.
  34. .. danger::
  35. Project files may be incompatible between Godot versions.
  36. **Make a backup of your project** before starting the bisection process.
  37. Going from the oldest to the newest build generally reduces the risk of the
  38. project not being able to successfully open in the editor, thanks to
  39. backwards compatibility. Try to reduce your project to the smallest
  40. repeatable example too. The more minimal the project is, the more likely
  41. you'll be able to open it without compatibility issues in newer engine
  42. versions.
  43. The Git bisect command
  44. ----------------------
  45. If you've found a build that didn't exhibit the bug in the above testing
  46. process, you can now start bisecting the regression. The Git version control
  47. system offers a built-in command for this: ``git bisect``. This makes the
  48. process semi-automated as you only have to build the engine, run it and try to
  49. reproduce the bug.
  50. .. note::
  51. Before bisecting a regression, you need to set up a build environment to
  52. compile Godot from source. To do so, read the
  53. :ref:`Compiling <toc-devel-compiling>` page for your target platform.
  54. (Compiling Godot from source doesn't require C++ programming knowledge.)
  55. Note that compiling Godot can take a while on slow hardware (up an hour for
  56. each full rebuild on a slow dual-core CPU). This means the full process can
  57. take up to several hours. If your hardware is too slow, you may want to stop
  58. there and report the results of your "pre-bisecting" on the GitHub issue so
  59. another contributor can continue bisecting from there.
  60. Determine the commit hashes
  61. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  62. To start bisecting, you must first determine the commit hashes (identifiers) of
  63. the "bad" and "good" build. "bad" refers to the build that exhibits the bug,
  64. whereas "good" refers to the version that doesn't exhibit the bug. If you're
  65. using a pre-release build as the "good" or "bad" build, browse the `download
  66. mirror <https://downloads.tuxfamily.org/godotengine/>`__, go to the folder that
  67. contains the pre-release you downloaded and look for the ``README.txt`` file.
  68. The commit hash is written inside that file.
  69. If you're using a stable release as the "good" or "bad" build, use one of the
  70. following commit hashes depending on the version:
  71. .. code-block:: none
  72. 4.1.1-stable
  73. 4.1-stable
  74. 4.0.3-stable
  75. 4.0.2-stable
  76. 4.0.1-stable
  77. 4.0-stable
  78. 3.5.2-stable
  79. 3.5.1-stable
  80. 3.5-stable
  81. 3.4.5-stable
  82. 3.4.4-stable
  83. 3.4.3-stable
  84. 3.4.2-stable
  85. 3.4.1-stable
  86. 3.4-stable
  87. 3.3.4-stable
  88. 3.3.3-stable
  89. 3.3.2-stable
  90. 3.3.1-stable
  91. 3.3-stable
  92. 3.2-stable
  93. 3.1-stable
  94. 3.0-stable
  95. You can also use this Bash function to retrieve the Git commit hash of a
  96. pre-release build (add it to your ``$HOME/.bashrc`` or similar):
  97. ::
  98. gd_snapshot_commit() {
  99. curl -s https://downloads.tuxfamily.org/godotengine/$1/$2/README.txt \
  100. | grep 'from commit' \
  101. | sed 's/^Built from commit \(.*\)\.$/\1/'
  102. }
  103. Example usage:
  104. .. code-block:: shell
  105. gd_snapshot_commit 4.0 beta4
  106. To refer to the latest state of the master branch, you can use ``master``
  107. instead of a commit hash. Note that unlike tagged releases or snapshot commit
  108. hashes, ``master`` is a perpetually moving target.
  109. Build the engine
  110. ^^^^^^^^^^^^^^^^
  111. :ref:`Get Godot's source code using Git <doc_getting_source>`. Once this
  112. is done, in the terminal window, use ``cd`` to reach the Godot repository
  113. folder and enter the following command:
  114. .. code-block:: shell
  115. # <good commit hash> is hash of the build that works as expected.
  116. # <bad commit hash> is hash of the build exhibiting the bug.
  117. git bisect start
  118. git bisect good <good commit hash>
  119. git bisect bad <bad commit hash>
  120. Compile Godot. This assumes you've set up a build environment:
  121. .. code-block:: shell
  122. scons
  123. Run the engine
  124. ^^^^^^^^^^^^^^
  125. Run the binary located in the ``bin/`` folder and try to reproduce the bug.
  126. .. note::
  127. :ref:`Double-check the output file name <doc_introduction_to_the_buildsystem_resulting_binary>`
  128. in ``bin/`` to make sure you're actually running the binary you've just compiled.
  129. Different Godot versions will output binaries with different names.
  130. If the build **still** exhibits the bug, run the following command:
  131. .. code-block:: shell
  132. git bisect bad
  133. If the build **does not** exhibit the bug, run the following command:
  134. .. code-block:: shell
  135. git bisect good
  136. After entering one of the commands above, Git will switch to a different commit.
  137. You should now build Godot again, try to reproduce the bug, then enter ``git
  138. bisect good`` or ``git bisect bad`` depending on the result. You'll have to
  139. repeat this several times. The longer the commit range, the more steps will be
  140. required. 5 to 10 steps are usually sufficient to find most regressions; Git
  141. will remind you of the number of steps remaining (in the worst case scenario).
  142. Once you've completed enough steps, Git will display the commit hash where the
  143. regression appeared. Write this commit hash as a comment to the GitHub issue
  144. you've bisected. This will help in solving the issue. Thanks again for
  145. contributing to Godot :)
  146. .. note::
  147. You can read the full documentation on ``git bisect``
  148. `here <https://git-scm.com/docs/git-bisect>`__.