|
2 | 2 | # SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de> |
3 | 3 | # SPDX-License-Identifier: CC-BY-4.0 |
4 | 4 |
|
5 | | -title: Debugging |
6 | | -description: How to debug Kando. |
7 | | -sidebar: |
8 | | - order: 4 |
| 5 | +title: Debugging & Profiling |
| 6 | +description: Learn how to debug or profile Kando. |
9 | 7 | --- |
10 | 8 |
|
11 | | -import { LinkButton } from '@astrojs/starlight/components'; |
| 9 | +import { Aside } from '@astrojs/starlight/components'; |
12 | 10 | import Intro from '../../components/Intro.astro'; |
13 | | -import CustomAside from '../../components/CustomAside.astro'; |
14 | 11 | import {Image} from 'astro:assets'; |
| 12 | +import { Icon } from 'astro-icon/components'; |
15 | 13 |
|
16 | 14 | import vscodeDebugging from '../../assets/img/debugging.png'; |
| 15 | +import performanceProfile from '../../assets/img/performance-profile.png'; |
17 | 16 |
|
18 | 17 |  |
19 | 18 |
|
20 | 19 | <Intro> |
21 | | -If you want to 💡 **understand Kando's code base** or fix an especially 🐛 **nasty bug**, using a debugger is a great idea. |
| 20 | +At some point, `console.log(...)` statements are not enough anymore. At some point, you will want to use a 🐛 debugger, 💡 inspect Kando's UI, or 🚀 profile its performance. |
22 | 21 | </Intro> |
23 | 22 |
|
24 | | -However, debugging an Electron application is not exactly straightforward. |
25 | | -This is because Electron applications consist of two parts: the main process and the renderer processes. |
| 23 | +## <Icon name="solar:bug-bold-duotone" class="inline-icon" /> Using a Debugger |
26 | 24 |
|
27 | | -The main process is responsible for managing the application lifecycle and has access to the operating system. |
28 | | -The renderer processes are responsible for rendering the user interface and are more or less isolated from the operating system. |
| 25 | +Debugging an Electron application is not exactly straightforward. |
| 26 | +This is because Electron applications consist of **two parts: the main process and the renderer processes**. |
| 27 | + |
| 28 | +The **main process** is responsible for managing the application lifecycle and has access to the operating system. |
| 29 | +The **renderer processes** are responsible for rendering the user interface and are more or less isolated from the operating system. |
29 | 30 | Kando has one main process and two renderer processes: one for the menu and one for the settings dialog. |
30 | 31 |
|
31 | | -## Debugging in VSCode |
| 32 | +### Debugging in VSCode |
32 | 33 |
|
33 | 34 | If you are using [Visual Studio Code](https://code.visualstudio.com/), you can set up debugging by creating a `.vscode/launch.json` file in your project directory. |
34 | 35 | Put the following content into that file: |
@@ -75,9 +76,58 @@ You can then set breakpoints in your code and inspect variables! |
75 | 76 | <center> |
76 | 77 | <Image src={vscodeDebugging} alt="debugging in VSCode" class="shadow"/> |
77 | 78 | </center> |
| 79 | +<center> |
| 80 | +<sup>Render process debugging in VSCode!</sup> |
| 81 | +</center> |
78 | 82 |
|
79 | | -## Other IDEs |
| 83 | +### Other IDEs |
80 | 84 |
|
81 | 85 | Have you successfully set up debugging in another IDE? |
82 | 86 | Let us know by editing this page! |
83 | | -You can also join our [Discord server](https://discord.gg/hZwbVSDkhy) and discuss it there. |
| 87 | +You can also join our [Discord server](https://discord.gg/hZwbVSDkhy) and discuss it there. |
| 88 | + |
| 89 | +## <Icon name="solar:rocket-bold-duotone" class="inline-icon" /> Using the DevTools |
| 90 | + |
| 91 | +Kando comes with built-in development tools that you can use to inspect the user interface and debug your code. |
| 92 | +You can open the DevTools from the General Settings dialog. |
| 93 | +Here, you can choose between inspecting the menu itself or the settings dialog. |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | +### Inspecting the Settings and the Menu |
| 98 | + |
| 99 | +The DevTools for the settings dialog will open in a separate window. |
| 100 | +You can use this to inspect the HTML and CSS of the settings dialog, and to test temporary changes. |
| 101 | +Especially for understanding the layout of the components, this is very useful. |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +The DevTools for the menu will open embedded in the menu window. |
| 106 | +This is useful, as otherwise the menu window would obscure the DevTools. |
| 107 | + |
| 108 | +To open the DevTools, click the "Inspect Menu" button in the General Settings dialog and then open a menu. |
| 109 | +The menu window will not be transparent anymore, due to a quirk in Electron. |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | +### Profiling the Rendering Performance |
| 114 | + |
| 115 | +A good rendering performance is important for the settings dialog but it is crucial for the menu. |
| 116 | +Hence, when implementing new features, we should always keep an eye on the performance. |
| 117 | + |
| 118 | +The development tools allow you to capture a performance profile of the menu or the settings dialog. |
| 119 | +To do this, open the DevTools and switch to the "Performance" tab. |
| 120 | +Then, click the "Record" button and interact with the menu or the settings dialog. |
| 121 | +Once you are done, click the "Stop" button to stop the recording. |
| 122 | + |
| 123 | +Now you explore the recorded profile frame by frame. |
| 124 | +You can see how long each frame took to render and which functions were called during that frame. |
| 125 | +This is extremely useful to identify performance bottlenecks in your code. |
| 126 | + |
| 127 | +<center> |
| 128 | +<Image src={performanceProfile} alt="profiling in the dev tools" class="shadow"/> |
| 129 | +</center> |
| 130 | + |
| 131 | +<Aside type="tip" title="Need Help?"> |
| 132 | +If you encounter a problem at any stage, feel free to ask for help in the **#support** or **#dev-chat** channel on [Kando's Discord Server](https://discord.gg/hZwbVSDkhy)! |
| 133 | +</Aside> |
0 commit comments