Skip to content
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

EdgeHTML: webview.eval inconsistent during startup #127

Open
BenoitRanque opened this issue Jan 13, 2020 · 0 comments
Open

EdgeHTML: webview.eval inconsistent during startup #127

BenoitRanque opened this issue Jan 13, 2020 · 0 comments

Comments

@BenoitRanque
Copy link

Executing webview.eval during startup is inconsistent, the js code may or may not run.
We are discussing this issue on tauri here. Test code below: expect 1000 <p> nodes to be added, but node 0 is not reliably inserted.

This was tested in 0.5.4 and 0.6.0. This may or may not be related to c++ async code handling here

use web_view::*;

fn main() {
    let webview = web_view::builder()
        .title("Example")
        .content(Content::Html(HTML))
        .size(800, 600)
        .resizable(true)
        .debug(true)
        .user_data(0)
        .invoke_handler(|_webview, _arg| {
            Ok(())
        })
        .build()
        .unwrap();

    let handle = webview.handle();
    for i in 0..1000 {
        handle.dispatch(move |webview| {
            webview.eval(&format!("document.body.appendChild(document.createElement('p')).appendChild(document.createTextNode('Item {}'))", i))
        }).unwrap();
    }
    webview.run().unwrap();
}

const HTML: &str = r#"
<!doctype html>
<html>
    <body>
        <h1>Hello World!</h1>
    </body>
</html>
"#;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant