Bug 134664

Summary: Timeout when calling dom method in WebExtension via dbus
Product: WebKit Reporter: Marcel Tiede <marcel.tiede>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: janousek.jiri
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Example Files none

Description Marcel Tiede 2014-07-06 13:20:59 PDT
Hi,

I created a vala GTK3 Application using a WebView which loads a WebExtension. Now I try to call a method from the WebExtension via dbus originating from the GTK Application. The WebExtension should click via the DOM API on the loaded HTML page. Calling the click method via a dbus-inspector or separate programs works ok. But calling the click from the GTK-Application via dbus results in a timeout and afterwards the click is performed.

Probably this problem is related to webkitgtk / webkit, because by removing the actual clicking command the timeout is gone. In the Attachments you can find a sample including the valac commands.

In the File Browser.vala are two path entries which must be adjusted to the system. For my testing I used Version 2.4.3 from webkitgtk.
Comment 1 Marcel Tiede 2014-07-06 13:21:51 PDT
Created attachment 234464 [details]
Example Files
Comment 2 Marcel Tiede 2014-07-06 13:25:07 PDT
Errormessage translated: Timeout reached (g-io-error-quark, 24)
Comment 3 Jiří Janoušek 2014-07-10 13:56:05 PDT
Hi Marcel,

I've modified your code to perform DOM manipulation in an idle callback and it does work :-)

--- dbuswebkit(0)/WebExtension.vala	2014-06-30 21:35:54.000000000 +0200
+++ dbuswebkit/WebExtension.vala	2014-07-10 22:50:22.234275010 +0200
@@ -69,11 +69,15 @@
     
         public void ClickFAIL() {
             stdout.printf("Controler:ClickFAIL1\n");
+            Idle.add(() => {
+                DOMElement element = mControler.mDom.get_element_by_id("test");
+                ((DOMHTMLElement)element).click();
+                
             
-            DOMElement element = mControler.mDom.get_element_by_id("test");
-            ((DOMHTMLElement)element).click();
+                stdout.printf("Controler:ClickFAIL2\n");
+                return false;
+            });
             
-            stdout.printf("Controler:ClickFAIL2\n");
         }
         
         public void ClickOK() {
Comment 4 Marcel Tiede 2014-07-14 14:00:12 PDT
Your codes fixes the Problem. Thank you Jiří.

If this behaviour is expected from Webkit point of view this bug is solved.
Comment 5 Marcel Tiede 2014-10-18 05:27:12 PDT
Fixed for me.