webview / webview_java

A Java wrapper of https://github.com/webview/webview
Other
64 stars 9 forks source link

Show nothing on MacOS, no error thrown. #28

Closed zerofancy closed 6 months ago

zerofancy commented 6 months ago

Same issue in WebviewKo

OS: macOS 14.3.1 23D60 arm64 Kernel: 23.3.0 JVM: azul-1.8.0_392

To rule JNA reasons, I tried to write a JNI demo, but no miracle happens.

JNIEXPORT void JNICALL Java_top_ntutn_WebViewJNI_launchAndWait(JNIEnv *env, jobject obj, jstring url) {
    std::cout << "Well begin" << std::endl;
    webview::webview w(true, nullptr);
    std::cout << "Generated" << std::endl;
    w.set_title("Basic Example");
    w.set_size(480, 320, WEBVIEW_HINT_NONE);
    w.set_html("Thanks for using webview!");
    std::cout << "Half done" << std::endl;
    w.run();
}

I tried to add some log to find the position it stucks at:

image

And here is the log:

/Users/bytedance/IdeaProjects/webview-kt-wrapper/src/main/resources
Hello World from CPP
Well begin
Reach 2
Reach 4
Reach 5

I can do nothing more with my poor native development knowledge now.

e3ndr commented 6 months ago

You need to start Java with the option -XstartOnFirstThread. See the README for more info.

zerofancy commented 6 months ago

It works now, thank you. Apologize for my carelessness.

e3ndr commented 6 months ago

No problem! Just keep in mind that the thread that your main() starts with will need to be the same thread you use when you run() the webview.