Skip to content

Commit d3db6ad

Browse files
committed
📝 Add notes on profiling
1 parent b686f33 commit d3db6ad

6 files changed

Lines changed: 64 additions & 14 deletions

File tree

src/assets/img/debugging.png

100755100644
-147 KB
Loading

src/assets/img/inspecting-menu.png

227 KB
Loading
393 KB
Loading

src/assets/img/open-inspector.png

76.1 KB
Loading
270 KB
Loading

src/content/docs/debugging.mdx

Lines changed: 64 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,34 @@
22
# SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
33
# SPDX-License-Identifier: CC-BY-4.0
44

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.
97
---
108

11-
import { LinkButton } from '@astrojs/starlight/components';
9+
import { Aside } from '@astrojs/starlight/components';
1210
import Intro from '../../components/Intro.astro';
13-
import CustomAside from '../../components/CustomAside.astro';
1411
import {Image} from 'astro:assets';
12+
import { Icon } from 'astro-icon/components';
1513

1614
import vscodeDebugging from '../../assets/img/debugging.png';
15+
import performanceProfile from '../../assets/img/performance-profile.png';
1716

1817
![banner](../../assets/banners/banner13.png)
1918

2019
<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.
2221
</Intro>
2322

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
2624

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.
2930
Kando has one main process and two renderer processes: one for the menu and one for the settings dialog.
3031

31-
## Debugging in VSCode
32+
### Debugging in VSCode
3233

3334
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.
3435
Put the following content into that file:
@@ -75,9 +76,58 @@ You can then set breakpoints in your code and inspect variables!
7576
<center>
7677
<Image src={vscodeDebugging} alt="debugging in VSCode" class="shadow"/>
7778
</center>
79+
<center>
80+
<sup>Render process debugging in VSCode!</sup>
81+
</center>
7882

79-
## Other IDEs
83+
### Other IDEs
8084

8185
Have you successfully set up debugging in another IDE?
8286
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+
![open-inspector](../../assets/img/open-inspector.png)
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+
![inspecting-settings](../../assets/img/inspecting-settings.jpg)
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+
![inspecting-menu](../../assets/img/inspecting-menu.png)
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

Comments
 (0)