webview / webview_java

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

Swing Example Crashes #29

Open SuperDino484 opened 6 months ago

SuperDino484 commented 6 months ago

The error is posted below. This happens when just running the Swing example from this repo.

Exception in thread "Thread-0" java.lang.Error: Invalid memory access at com.sun.jna.Native.invokeLong(Native Method) at com.sun.jna.Function.invoke(Function.java:431) at com.sun.jna.Function.invoke(Function.java:364) at com.sun.jna.Library$Handler.invoke(Library.java:270) at dev.webview.webview_java.$Proxy0.webview_create(Unknown Source) at dev.webview.webview_java.Webview.<init>(Webview.java:193) at dev.webview.webview_java.Webview.<init>(Webview.java:185) at dev.webview.webview_java.Webview.<init>(Webview.java:177) at dev.webview.webview_java.Webview$1.lambda$paint$0(Webview.java:77) at java.base/java.lang.Thread.run(Thread.java:833)

e3ndr commented 6 months ago

Yeah it looks like this was introduced in an update to the upstream library. Still trying to figure it out.

Osiris-Team commented 1 month ago

@e3ndr any updates on this?

Osiris-Team commented 1 month ago

So it definetly has something todo with this line: $pointer = N.webview_create(debug, windowPointer); when passing null as windowPointer it works (however opens a new windows like documented) so there is probably something wrong with the windowPointer object.

Osiris-Team commented 1 month ago

Where do you get the binaries from? Maybe trying a newer version of webview fixes it.

Osiris-Team commented 1 month ago

Reverting to the webview version in 1.3.0 seems to fix this issue. Maybe this even is even only related to the webview2loader.dll not being preset, who knows and maybe this is only a Windows issue. Did that on my fork and replaced the libraries with the older versions. Note that not all were replaced since there are more supported architectures now. https://github.com/Osiris-Team/webview_java You can get it from here as a temporary workaround: https://jitpack.io/#Osiris-Team/webview_java/1.3.2

Use with 1JPM:

            implementation("com.github.Osiris-Team.webview_java:core:1.3.2");
            implementation("com.github.Osiris-Team.webview_java:bridge:1.3.2");
e3ndr commented 1 month ago

Where do you get the binaries from? Maybe trying a newer version of webview fixes it.

They were self-built. You can checkout this GH action to see how I was doing it.

any updates on this?

Unfortunately not, I have decided to step away from webview_java and have been meaning to get in contact with some people about someone taking over maintaining.

Link-Kou commented 4 weeks ago

@e3ndr Support Swing

e3ndr commented 4 weeks ago

@Osiris-Team if you're willing to contribute, i believe the issue is weak references to the native callback interfaces. basically, the JVM will garbage collect those callbacks since the function is returning. i don't think that fixes the swing issue but it might be related.

Osiris-Team commented 4 weeks ago

@e3ndr I would love to. However I have no idea what that even means, and since I got it working by downgrading the dll there is little motivation for me to fix that haha.