-
Notifications
You must be signed in to change notification settings - Fork 176
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
Segfault when run from child thread. #26
Comments
The fault only occurs when the window is closed, either via the quit menu, or by closing the window. The system is Ubuntu 18. |
Interesting. I added a sleep after the join, followed by a print. The "Join Error" expect does not get triggered, and the window doesn't close until main is complete, at which point the segfault gets dumped. |
Hello, could you check if this problem persists after #36 was merged? I am not able to reproduce this bug. Here is your minimal example code rewritten to use the new api of web-view crate: extern crate web_view;
use web_view::*;
use std::thread::spawn;
const INDEX: &str = r#"<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
This is a test.
</body>
</html>
"#;
fn main() {
let callback = |_view: &mut WebView<()>, _arg: &str| Ok(());
let view = spawn(move || {
WebViewBuilder::new()
.title("test thread")
.content(Content::Html(INDEX))
.size(800, 600)
.resizable(true)
.debug(true)
.user_data(())
.invoke_handler(callback)
.build()
.expect("Build Error")
.run()
.expect("Run Error");
});
view.join().expect("Join Error");
} |
I got a core dump as well, but I have the WebView running in the main thread: fn main() {
std::thread::spawn(move || {
//... set up file watchers using `notify`
});
let wv = MyController::web_view();
wv.run().unwrap();
} |
And here's the coredump stack frame:
|
Note: You could never run this on a non-main thread on macOS anyway, because macOS is weird like that. |
I've come across this issue as well. Ubuntu 18.04 and use web_view::*;
use std::time::Duration;
fn main() {
std::thread::spawn(|| {
let mut wv = web_view::builder()
.content(web_view::Content::Url(""))
.user_data(0)
.invoke_handler(|wv, arg| {
// terminate in here causes free(): invalid pointer
Ok(())
})
.build().expect("Build Error");
wv.run().expect("Run Error");
});
std::thread::sleep(Duration::from_secs(7));
} I did some of my own snooping around by running it through std::thread::spawn(|| {
let mut wv = web_view::builder()
.content(web_view::Content::Url(""))
.user_data(0)
.invoke_handler(|wv, arg| {Ok(())})
.build().unwrap();
let mut looped = 0;
loop {
match wv.step() {
Some(Ok(a)) => (),
Some(Err(e)) => (),
None => {
looped += 1;
if looped > 4 {
println!("Closed");
return;
}
}
}
}
}); but it's a very ugly magical workaround and I'm really unsure as to why it works exactly. It feels like some kind of race condition, but I'm not sure how the window manager works. Hope this helps deduce what's wrong. |
Hello! Thank you for building this, first of all! I've had alright success running this from the main thread, but it seems to die when run from a child. Here's the segfault:
And here's the minimal code to reproduce:
The text was updated successfully, but these errors were encountered: