Any documentation about the main thread? #3561
-
The question is kind of vague, let me explain: I had a tauri command, non-async, which hid the caller window. Doing so completely froze another visible window, and I just spent like 2 hours trying to figure out why :( (making the command async solved the issue). I would have expected that anything to do with window management HAD to be done on the main thread, but apparently this is not the case. I have found this issue, but this provides no further explanation. Nor is it mentioned in the official docs (the provided examples are async though..). Should one just make all commands async? What is the purpose of the main thread? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Some stuff must run on main thread, some stuff must run on a non-main thread. Also, the main thread should be slightly faster (no context switching or whatever). That said the frozen window sounds like a bug. So if you can i'd appreciate if you can create an issue for it with a minimal reproduction repo 🙏
Actually it used to be the other way around, window manipulation was only allowed on non-main threads. Nowadays it should be only window.close() that needs to be run on a seperate thread. |
Beta Was this translation helpful? Give feedback.
Some stuff must run on main thread, some stuff must run on a non-main thread. Also, the main thread should be slightly faster (no context switching or whatever).
The main thing to have in mind is that doing something blocking in commands which run on the main thread will also block the UI (which also runs on the main thread). So i guess you could say async commands (or sync command annotated with
#[command(async)]
) are generally the safer bet 🤷That said the frozen window sounds like a bug. So if you can i'd appreciate if you can create an issue for it with a minimal reproduction repo 🙏
Actuall…