Open uefva opened 1 month ago
I can reproduce this on Windows 10 with the popup example except I get a different error:
thread 'main' panicked at packages\generational-box\src\unsync.rs:253:47:
already borrowed: BorrowMutError
The windows freezing and the new window not mounting act the same.
I also tested this on Linux with the only issue being that the new window couldn't be closed but otherwise, it worked without error.
Yes, I have encountered this error in the Popup example before, but when I used a similar method to write other programs, I encountered an error that is different from Popup
Hi @DogeDark,
I'm currently working on fixing the already borrowed
error (), especially around get_split_ref
andget_split_mut
. I’m digging into potential conflicts in recursive borrowing and exploring ways to prevent these issues from recurring. Could you assign this issue to me so I can continue making progress?
About the error : The already borrowed error typically occurs in Rust when a **RefCell**
is borrowed as immutable or mutable while there is already another active borrow that conflicts with the new one. This issue often arises in single-threaded environments when there are overlapping Ref
and RefMut
borrows, and Rust's borrow checker catches this.
Thank You for your help!
Hi everyone,
After spending some time debugging this, I think I’ve identified what seems to be causing the problem.
It initially appeared that borrow_mut
in unsync.rs
might be the source of the issue (cause we are providing mut ref within a loop). However, after a closer look, unsync.rs
actually seems to be functioning as expected. The real issue seems related to the desktop::window().new_window()
method when creating a secondary window.
The problem can be consistently reproduced by running the multiwindow.rs
or popup.rs
examples. When there is already an active primary window and a new window is created, the new window appears but does not render content properly.
The already_borrow error occurs specifically when attempting to close the primary window before the new window. Since we’re unable to close the new popup window (as it gets stuck), the mutable reference (from RefCell) remains borrowed by the new window, leading to this error.
This suggests that the borrowing conflict might stem from how .new_window()
method handles the references when the primary window is still active.
As of now, I'm still working on this, trying to figure out the issue. I'm focusing on these potential causes:
SharedContext
in the DesktopService
?VirtualDom
from the WebviewInstance
struct?Hope this helps clarify the issue! I’ll update as I learn more, and please let me know if there’s any additional insight you have.
Hi @ealmloff @DogeDark,
~It's not a Fix , rahter a workaround for now.~
After several days of debugging this issue, here's what I found and the steps I followed: Steps:
window.new_window()
, creating a new WebInstance
, setting up a new Virtual DOM
and Config
, and experimenting with the wry
library. WebView.build()
method which I found was getting stuck during second window creation , async code in the create_controller
function.multi-threading
and async functions
. While this might not be the most optimal solution, I believe it's a good workaround. There should ideally be a better way to create windows without spinning up a new thread.Solution:
That said, I’m very open to any suggestions or alternative solutions that might be more efficient or better aligned with the intended design.
_
NOTE: I've also updated the example documentation for using .new_window() to guide users through the process.
Sorry, I didn't open GitHub to view the information a while ago. Thank you for your detailed answer. If I have any new discoveries in the future, I will communicate with you in detail