Boscop / Boscop/web-view

Is there a way to open two webview windows without crashing?

Open
#317 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2k
Forks
179
PR merge metrics
No merged PRs in 30d

Description

**My system**
Ubuntu 21.04

**What I'm trying to do**
I actually don't need two open simultaneously, but that would also work. I want to be able to close the first webview window (clicking the "x" icon), then I am opening another window to provide a message to the user. However this results in an error every time with

> Aborted (core dumped)

**My code**
Here is an example of what produces that error. I start up the window, and during the 6 second sleep I close that first window.

```
let (popup_stopper, popup_receiver) = oneshot::channel::();
let wait_popup_future = tokio::spawn(wait_popup::show("Waiting on upload & download jobs to finish".to_string(),popup_receiver));
sleep(Duration::from_secs(6)).await; //DEBUG!!
let (popup_stopper2, popup_receiver2) = oneshot::channel::();
let wait_popup_future2 = tokio::spawn(wait_popup::show("This represents the normal app webview".to_string(),popup_receiver2));

```

And within each `wait_popup::show()` function I call webview like so:

```
let mut webview = web_view::builder()
.title("Waiting on process")
.content(Content::Html(html))
.size(500, 80)
.resizable(false)
.debug(false)
.user_data(json!({"message": message}))
.visible(true)
.invoke_handler(|webview, arg| {
use Cmd::*;
println!("cmd in rust {:?}",arg);
let cmd: Cmd = serde_json::from_str(arg).unwrap();
let cmd_copy = cmd.clone();

// clear errors / success messages
let data = webview.user_data_mut();
if cmd.will_render(){
data["errors"] = json!(null); //clear errors
data["success"] = json!(null); //clear success messages
webview.eval("shared_data.errors = null;");
webview.eval("shared_data.success = null;");
}

match cmd {
Init => {
println!("Inside Init()");
},
... //more code
WaitPopupStopReceiver => {
match stop_receiver.try_recv() {
Ok(msg) => {
println!("Quitting popup");
webview.exit();
},
_ => {}
};
}
_ => {},
}
... //more code
})
.build()
.unwrap();
```

**My question**

I've searched other github issues here which seem to imply opening multiple windows is expected to work with this crate? If so can anyone show me how I might do that?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the web_view::builder().build() calls in the two wait_popup::show() invocations and reproduce the abort by closing the first window before launching the second. Trace the window-close and webview lifecycle, then verify that the second window opens without an abort in the Ubuntu scenario described.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, rust
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.