WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED INVALID
245059
Web extensions doesn't work
https://bugs.webkit.org/show_bug.cgi?id=245059
Summary
Web extensions doesn't work
Ashu Sharma
Reported
2022-09-11 21:31:14 PDT
Hello, I am developing a application like a browser, for linux using Webkit2Gtk, as you know the direct access to Webkit.DOM is removed in Webkit2, so i needed to use Web extension server, It works/(loads extensions) well with 1-2 windows that uses webkit, but when i open multiple windows that uses webkit, the extensions of all webcontext's does not loads/works. Only few of webkit's web extensions of webcontext works well. With regards, Ashu Sharma
Attachments
Example program
(31.92 KB, application/zip)
2022-09-13 00:30 PDT
,
Ashu Sharma
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Michael Catanzaro
Comment 1
2022-09-12 07:09:33 PDT
Beware this API is probably going away, see:
https://lists.webkit.org/pipermail/webkit-dev/2022-August/032329.html
Anyway, can you confirm that the WebKitWebExtension::page-created or WebKitWebExtension::user-message-received signals are not emitted when expected? If so, please submit an example program that demonstrates the bug.
Ashu Sharma
Comment 2
2022-09-12 11:14:37 PDT
Thanks for your reply, Let me explain: My application needed to handle many webkit process (Webkit::WebContext) on each different Gtk.Window, Since each window needed to access in DOM of its WebPage, I am using DBus to connect with its extension that is loaded by webkit, but DBus needed a unique name and path, so it will only work on one window, so to fix it i have created a another process named EventServer (.so) that loaded by my application before doing any webkit stuff, now when it creates a window, each window implements a different Webkit:WebContext, then this try to connect with EventServer (Note: There is only one EventServer process running in all application), Meanwhile in the other side Webkit:WebExt is loaded by Webkit, it register its own random unique DBus name, Now when it Webkit:WebExt recieves _on_page_created by WebKit, it try to connect with EventServer through DBus, on the successful connection it calls a function of EventServer and send its DBus Name, WebkitPage.PageId through params, Now as EventServer recieved the information, it immediately try to connect with WebExt as it gets its DBus name and save the connection and all data that it received. After a successful connection it also call a function of WebExt to do its init stuffs (i.e. adding event listeners like click) (the listeners are connected with EventServer functions) and also logs messages (all are good at this point), Now on running the app with 3,4,5,6>.. windows, the clicks/any message are not recieved by 1-2... WebExt (_on_page_created are recieved successfully by these extensions also), but at the same time it works well with other windows. The problem I guess is, maybe WebKit can't handle few its extensions or it lost signal while the system is busy, Or maybe its a linux kernel process bug. By the way, I am on Ubuntu 19.04. Anyway, as you said the api maybe go away, is there any other way to access to DOM? Or I needed to edit Webkit source a patched source of webkit2 for direct access to DOM exist?
Michael Catanzaro
Comment 3
2022-09-12 11:42:39 PDT
(In reply to Ashu Sharma from
comment #2
)
> The problem I guess is, maybe WebKit can't handle few its extensions or it > lost signal while the system is busy, Or maybe its a linux kernel process > bug.
Well it's certainly not impossible. If you can provide a code sample that demonstrates the bug, we could maybe take a look. The simpler the better, of course.
> Anyway, as you said the api maybe go away, is there any other way to access > to DOM?
You can use webkit_web_view_run_javascript() in the UI process. It's pretty limiting and definitely not a replacement for WebKitWebExtension, but we don't yet know what else to do. (I was just giving you a heads-up that this will be a problem for you in the future: we don't actually have any replacement functionality available yet.)
> Or I needed to edit Webkit source a patched source of webkit2 for > direct access to DOM exist?
That sounds pretty difficult. I wouldn't recommend trying that.
Ashu Sharma
Comment 4
2022-09-13 00:27:36 PDT
Sorry, I can't provide my source code, But that is just simple, i have attached a working "webext example", i connects through dbus in same way as done in "example program", but my application just opens multiple windows with different instances of webkit.Webcontext in each window as i said earlier. Whatever, I just need to do following: 1. Add/Modify/Remove element from DOM 2. Receive each mouse/key events from WebKit 3. Set custom "window['CUSTOM']" in javascript. (like window['chrome'] etc) 4. Even if possible call app function by calling javascript method: I have heard about "JavascriptCoreGtk", does it can do above? As i know the current way, it all working well with 1-2 windows, fewtimes even with multiple windows.
Ashu Sharma
Comment 5
2022-09-13 00:30:03 PDT
Created
attachment 462305
[details]
Example program
Carlos Garcia Campos
Comment 6
2022-09-13 00:40:43 PDT
You can use use messages api instead of custom DBus for the process communication. See
https://webkitgtk.org/reference/webkit2gtk/stable/WebKitUserMessage.html
Michael Catanzaro
Comment 7
2022-09-13 07:44:29 PDT
Ah, your example program is a blast from the past.... (In reply to Ashu Sharma from
comment #4
)
> Sorry, I can't provide my source code, But that is just simple, i have > attached a working "webext example", i connects through dbus in same way as > done in "example program", but my application just opens multiple windows > with different instances of webkit.Webcontext in each window as i said > earlier.
Without an example that reproduces the bug, I'm afraid my guess is you're doing something wrong. :P Based on the example that you attached, I'm actually a little more confident of this.
> Whatever, I just need to do following: > 1. Add/Modify/Remove element from DOM > 2. Receive each mouse/key events from WebKit > 3. Set custom "window['CUSTOM']" in javascript. (like window['chrome'] etc) > 4. Even if possible call app function by calling javascript method:
>
> I have heard about "JavascriptCoreGtk", does it can do above?
I think you can do all of this using webkit_web_view_run_javascript().
> As i know the current way, it all working well with 1-2 windows, fewtimes > even with multiple windows.
> You can use use messages api instead of custom DBus for the process communication. See
https://webkitgtk.org/reference/webkit2gtk/stable/WebKitUserMessage.html
This would indeed be easier than using D-Bus. The example that you attached was written before the messages API existed. Another issue with that example is it is using the session bus instead of a private connection. But most importantly, it's using a fixed address. Even if you were using a single web extension -- which you're not, because you mentioned you were multiple web contexts -- you would still need to use a different address for each web process. Unless you show how your code handles that, we'll need to assume there's a bug on your end. Using the message passing API would allow you to ignore those considerations. But since the risk is high that it will go away in the future, I would probably try to stick to the UI process if you can, and see if you can do everything using webkit_web_view_run_javascript(). It might not be possible, but if you can, then you don't need to worry about it breaking in the future.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug