-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Desktop app can't be automatically re-opened by the dx serve
#3322
Comments
I'm encountering the same issue. |
I've rebased #3323 onto v0.6.1, so you can use it with all the latest updates. |
I am seeing the same issue on linux with desktop feature and dx 0.6.1. I am using rustc 1.83.0. |
I am happy to try the fix but I don't know how to do it. |
git clone --depth 1 -b fix-desktop-open-linux https://github.com/Andrew15-5/dioxus.git
cd dioxus
cargo install --path ./packages/cli |
Thanks. I would not have figured it on my own. The fix indeed closes and restarts the app after a rebuild. The annoying bit is that when it restarts, the app steals the focus from the editor that needs to be clicked to continue typing. This can quickly become irritiating. Also, after manually closing the app window, pressing |
Can confirm this bug also on NixOS 24.11. Can also confirm that @Andrew15-5's patch fixes the issue. I can also confirm that the app does steal focus when reloaded on my system too, unfortunately. It seems intrinsic problem to re-opening the window. Here are my thoughts on potential solutions in ascending order of jank:
In the meantime, merging this is certainly much better than nothing. The workflow is barely usable otherwise -- and truthfully, the problem of the window of the app you're prototyping stealing focus between iterations is a common one across many toolkits and ecosystems. I guess what I'm saying is, if 1. would take e.g. several months to ship, it's probably best to at least merge this for now so that Linux users can develop with |
The app focus issue is honestly the norm, because that's how the windowing system works: you open a new window, it becomes focused. I maybe thought of this once or twice before. I investigated this for Linux, and there is no way to prevent the focus, unless the app itself can somehow do this: id=$(xprop -root _NET_ACTIVE_WINDOW | awk '{print $5}') && ./app & disown && pid=$!; while ! wmctrl -lp | grep "$pid"; do :; done && wmctrl -iR "$id" And AFAIK there is no better way than just wrapping these commands in Since https://github.com/jkelleyrtp/ipbp exists, I'm petty sure there is no way to just re-load stuff in-place, since the desktop is literally a single binary.
By default, Dioxus already maintains the same window position on rebuilds, but there is some issue with it: #2318.
This is because currently it tries to find the app from the hashmap and then open it. But, IIUC, the app is being automatically removed from the hashmap because it's being closed and therefore being dropped in I don't know how to properly fix it, because I don't see an immediate way to get the |
@Andrew15-5 The shell script solution you suggest isn't really one I'd champion, as it doesn't work on Wayland. Wayland protocols for more sophisticated automation are still being developed, and X11 is being dropped by the ecosystem -- so while it might be a temporary fix to have some hook for a script the user can put in, hardcoding in an X11-specific solution seems like a no-go IMO. This seems out-of-scope for this issue, tho. |
Right, I forgot to mention that I only found the solution for the X11, and any tool that can help with that isn't even mandatory, so I'm pretty sure the dev must install them separately. You probably can check the windowing system and run the correct command. If this can be done for other OSes, then I think this is worth adding. Since there are a lot of unevenness between different OSes as is, I don't think adding this just for X11-based OSes would be that bad. Because better DX even for some group of people (not super small) is better than bad DX for everyone. I also remember this being annoying, so I would probably use this. And since I already have the patch, I can slap it on top of any version and use it, even if just for myself. |
Just fixed this in #3608 The new system adds a bit of entropy to each .exe name in development that allows us to write multiple variants of the exe in the same build dir while the app is running. |
How many generated binaries can be present in the directory at the same time? For the same program. If only 2 then it's fine, but if more, then this is unnecessary bloating as the bare-bones debug binary is over 150 MiB (and 2 of them is already over 300 MiB). |
Only two binaries - we write the new one with the entropy and then clean up the old one |
Nice! |
When re-opening or re-building the app on Linux, it shows:
Steps To Reproduce
Steps to reproduce the behavior:
dx serve
on Linux/Unix-like systemExpected behavior
No errors.
Screenshots
Environment:
The text was updated successfully, but these errors were encountered: