[wpe-webkit] Web Extension Support In WPE

Carlos Garcia Campos cgarcia at igalia.com
Tue Jun 18 09:39:14 PDT 2019


El mar, 18-06-2019 a las 21:58 +0530, Munez Bn escribió:
> 
> 
> On Tue, Jun 18, 2019 at 7:03 PM Adrian Perez de Castro <
> aperez at igalia.com> wrote:
> > Hello Munez,
> > 
> > First of all: yes, the WebKitWebExtension API is supported in WPE
> > WebKit,
> > and I have successfully used it myself in a couple of projects — it
> > works.
> > 
> 
> Thanks for confirming.
>  
> > On Sat, 08 Jun 2019 20:43:17 +0530, Munez Bn <munezbn.dev at gmail.com
> > > wrote:
> > 
> > > I had written a test webextension for WebKitGTK long back
> > (WebKitGTK
> > > 2.16.6). I wanted o test it with WPE 2.24.x (RPI3) and the page
> > was not
> > > launching. After debugging I found that
> > JSContextGetGlobalObject() is
> > > getting struck and never returns. Same extension when i Tried on
> > WebKitGTK
> > > 2.24.x on Fedora, I don't see this issue.
> > > 
> > > static void
> > > window_object_cleared_callback (WebKitScriptWorld *world,
> > >                                 WebKitWebPage     *web_page,
> > >                                 WebKitFrame       *frame,
> > >                                 gpointer           user_data)
> > > {
> > >     JSGlobalContextRef globalContext;
> > >     JSObjectRef        globalObject;
> > > 
> > >     GRefPtr<JSCContext> jsContext =
> > > doptGRef(webkit_frame_get_js_context_for_script_world(frame,
> > world));
> > > 
> > >     globalContext = jscContextGetJSContext(jsContext.get());
> > >     globalObject = JSContextGetGlobalObject (globalContext);  -
> > --> Blocked
> > > and doesn't return
> > > ..........
> > 
> > Is the function really blocked, or did the “WPEWebProcess” program
> > crash?
> 
> There is no WebProcess crash, the call is  blocked in function 
> JSObjectRef JSContextGetGlobalObject(JSContextRef ctx) at line 
> "JSLockHolder locker(vm);"

You are mixing both APIs, I wonder how you can use
jscContextGetJSContext() which is private. You shouldn't mix both APIs
in any case.

> > I did a very quick check of the “JSContextGetGlobalObject” function
> > and
> > unless I missed something, the only way it can fail is if your
> > build has
> > assertions enabled and the the passed “JSContextRef” is null —
> > there
> > is “ASSERT_NOT_REACHED()” in that case.
> > 
> 
> Like I mentioned above, it has crossed ASSERT and struck at
> locker(vm) call.
>  
> > This “window_object_cleared_callback” function is not in the
> > upstream WebKit
> > sources... Is this is code from your own WebExtension, or have you
> > patched
> > WPE WebKit in any way?
> > 
> 
> It is my callback code of extension
>     g_signal_connect (webkit_script_world_get_default (),   "window-
> object-cleared",  G_CALLBACK (window_object_cleared_callback), 
> usrData);
> 
> > In case the above is the code of your WebExtension, please update
> > it to use
> > the JSC GLib API [1] because the plain C JavaScriptCore API that
> > this piece of
> > code has never been public in WPE WebKit, and there is no stability
> > guarantee
> > for it. 
> 
>  I realized this recently and started moving my code to use JSC GLIB
> API, but I was not sure how to return native objects using JSC Gib
> API. Please refer to my post in 
> https://stackoverflow.com/questions/56516809/returning-native-objects-using-javascriptcore-glib-api
> Can you please help me answering above question? Basically i want
> something like this, Create a File object ( GFile *) which has
> properties path and size. Return this object to javascript code such
> that I can access its properties path and size.
> I was able to do this in JS object C API, But not sure how to do it
> in JSC Glib API..

You need to register the class so that JSC can create and handle
wrapped GFiles. We do that in our unit tests, check this:

https://trac.webkit.org/browser/webkit/trunk/Tools/TestWebKitAPI/Tests/JavaScriptCore/glib/TestJSC.cpp#L2369

> > Also, this is using the “GRefPtr”, which is internal to WebKit and
> > the header that defines that is not even installed as part of the
> > public API.
> > 
> 
> Agree. I will update my code and give a try.
> 
> > As a reminder: please use only public symbols from the installed
> > API headers
> > in software that uses WebKit.
> > 
> 
> Agree. 
> > Best regards,
> > —Adrián
> > 
> > ---
> > [1] https://webkitgtk.org/reference/jsc-glib/stable/index.html
> 
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> webkit-wpe mailing list      (webkit-wpe at lists.webkit.org)
> Help/Unsubscribe/Update your Subscription:
> https://lists.webkit.org/mailman//listinfo/webkit-wpe
-- 
Carlos Garcia Campos
http://pgp.rediris.es:11371/pks/lookup?op=get&search=0xF3D322D0EC4582C3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
URL: <http://lists.webkit.org/pipermail/webkit-wpe/attachments/20190618/8070f382/attachment-0001.bin>


More information about the webkit-wpe mailing list