Open lytico opened 3 years ago
FWIW, this is my use case:
Your two PRs seem to enable most of this to work (great job so for); the script message handler seems to be the last thing holding it back.
Do these parts already work in the mono library? I'd be happy to use that for now, but I'd want to switch back to this fork ASAP, since .NET Core compatibility is a huge plus.
seems to be a problem with namespaces in WebkitGtkSharp-api.xml
missing type is generated in namespace WebKit struct JavascriptResult
in WebkitGtkSharp-api.xml it's typed as WebKitJavascriptResult and marked as missing
it's never registered with GLib.GType.Register (...)
Happy to see you looking into this again. BlazorWebView for GTK would be so great!
the problem seems to be in JavaScriptCore.Result as soon as its referenced, the programm crashes:
test is Samples.WebviewSection
generated Code in JavascriptResult (slightly changed for debugging):
public JavaScriptCore.Value JsValue {
get {
IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal(System.Runtime.InteropServices.Marshal.SizeOf(this));
System.Runtime.InteropServices.Marshal.StructureToPtr(this, this_as_native, false);
IntPtr raw_ret = webkit_javascript_result_get_js_value(this_as_native);
var glibobj = GLib.Object.GetObject(raw_ret);
JavaScriptCore.Value ret = glibobj != null ? glibobj as JavaScriptCore.Value : default;
ReadNative(this_as_native, ref this);
System.Runtime.InteropServices.Marshal.FreeHGlobal(this_as_native);
return ret;
}
}
then, in GLib.Object.GetObject(raw_ret) GLib.Object.GetObject(raw_ret,false)
it crashes calling g_object_is_floating(o)
if (!owned_ref && !g_object_is_floating(o))
g_object_ref (o);
else if (owned_ref && g_object_is_floating(o))
unexpected_owned_floating = true;
I've taken this branch and lytico:lytico/webkit2 and merged them into one branch (jwosty:jwosty/frankenbranch) to see how they are working together - it builds.
WebView.RunJavascript(string)
is working fine, which is super cool.I'm trying to get script message handlers to work, but getting this runtime error:
What does this mean? I'd love to try to fix this, but I don't have experience working with GLib->.NET bindings.
JavascriptResult.cs
is being generated.Here's the code that registers the handler (it's F#):
And the JS I used to trigger the handler (just execute via the JS console in the inspector in the app):
Any pointers on what needs fixing?