You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/plugins/debug_plugins.md
+22-1Lines changed: 22 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ When developing plugins in napari, you may encounter mistakes or bugs in your co
8
8
4. Reloading code during plugin development.
9
9
5. Isolating issues from napari.
10
10
6. Logging and debug messages.
11
+
7. Debugging segfaults/memory violation errors
11
12
12
13
## Debugging plugin start-up issues
13
14
@@ -287,4 +288,24 @@ DEBUG: 20/09/2022 05:59:23 PM The input string was (logging): fast
287
288
'You entered fast!'
288
289
```
289
290
290
-
The full code changes and new files after applying the changes to the plugin in each step of the examples are [here](https://github.com/seankmartin/napari-plugin-debug/tree/full_code/napari-simple-reload).
291
+
292
+
The full code changes and new files after applying the changes to the plugin in each step of the examples are [here](https://github.com/seankmartin/napari-plugin-debug/tree/full_code/napari-simple-reload).
293
+
294
+
## Debugging segfaults/memory violation errors
295
+
296
+
If napari crashes with a segfault or memory violation error when using your plugin
297
+
it may be connected with setting some viewer/layers properties outside main thread.
298
+
Because of the limitations of the Qt library, such interactions with napari may lead to a crash.
299
+
300
+
To test if this is the case, you can use the `NAPARI_ENSURE_PLUGIN_MAIN_THREAD` environment variable to help debug the issue.
301
+
302
+
Set the environement variable: `NAPARI_ENSURE_PLUGIN_MAIN_THREAD=1`, then start napari and run your plugin.
303
+
304
+
```bash
305
+
NAPARI_ENSURE_PLUGIN_MAIN_THREAD=1 napari
306
+
```
307
+
308
+
Next, start using your plugin and observe if
309
+
`RuntimeError("Setting attributes on a napari object is only allowed from the main Qt thread.")`
310
+
occurred. If so, then you need to make sure that all of your plugin code that interacts with napari structures is executed
311
+
in the main thread. For more details you could read the [multithreading](https://napari.org/stable/guides/threading.html) section of the documentation.
0 commit comments