Bug 505418

Summary: [GTK3][webkit] Support Javascript 'evalute()' in Webkit2
Product: [Eclipse Project] Platform Reporter: Leo Ufimtsev <lufimtse>
Component: SWTAssignee: Leo Ufimtsev <lufimtse>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: akurtakov, Lars.Vogel, lshanmug, peter
Version: 4.5Keywords: noteworthy
Target Milestone: 4.7 M5   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/85316
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=ea85779fb50e4628c61ce5f53d28e02f93ad8e31
https://git.eclipse.org/r/87283
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=dbde08a1d4b99e0f38e4d2d8f833c2341bb605f7
https://git.eclipse.org/r/94319
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=6b0dce3bb2a15fb540f4a2398d36e784b68b60fa
Whiteboard:
Bug Depends on: 505591    
Bug Blocks: 441568    

Description Leo Ufimtsev CLA 2016-10-07 11:45:27 EDT
Currently evalute() doesn't return anything. Need to implement this functionality. This bug is to track progress.
Comment 1 Eclipse Genie CLA 2016-11-18 12:49:52 EST
New Gerrit change created: https://git.eclipse.org/r/85316
Comment 3 Lars Vogel CLA 2016-11-22 04:54:41 EST
Should this be added to our N&N M4?
Comment 4 Leo Ufimtsev CLA 2016-11-22 10:04:38 EST
(In reply to Lars Vogel from comment #3)
> Should this be added to our N&N M4?

Evaluate in Webkit2 is not fully finished just yet. It now works for primitive return types and Strings, but I have yet to implement support for returning arrays.
Comment 5 Alexander Kurtakov CLA 2016-11-29 11:49:13 EST
Moving to M5 as it will not be finished in time for M4.
Comment 6 Eclipse Genie CLA 2016-12-15 20:14:00 EST
New Gerrit change created: https://git.eclipse.org/r/87283
Comment 8 Alexander Kurtakov CLA 2016-12-20 05:22:29 EST
Resolving the bug - all code is in.
Comment 9 Leo Ufimtsev CLA 2017-01-27 10:18:34 EST
While investigating Bug 510183 (hang), I found a situation where the webkitgtk_custom.c logic an cause a deadlock.

- If Webkit triggers a signal (e.g locationChange signal)
- If in this SWT (java) signal handler, an execute(..) evaluate(...) call is made, 
  then in the webkitgtk_custom.c logic, it will wait for the javascript execution to run,
  (webkit_web_view_run_javascrip(....))
  but webkit_web_view_run_javascript(..) [btw which is async] is never ran. It is put on top of the
  event queue to be ran, but it's not ran until the signal is finished.
- But the signal does not finish until webkit_web_view_run_javascript(...) is ran.

Like:
Webkit ---signal--> Java ---- evaluate()-----
           ^                  	           |
	   |(waiting on signal to finish)---	

The only solution I can think of is not to wait on webkit_web_view_run_javascript(..) to complete if it's called during a signal from webkit. I.e, execute()/evaluate(..) would still work, but it would not provide a return value in the corner case when it's called from a signal. 
This is a limitation of SWT and Webkit's api not being compatible. (SWT expects a sync exec, but webkit2 only provides async exec).

~Patch en-route
Comment 10 Lakshmi P Shanmugam CLA 2017-01-30 03:58:48 EST
M5 is done, moving to M6.
Comment 11 Leo Ufimtsev CLA 2017-01-30 11:26:16 EST
(In reply to Lakshmi Shanmugam from comment #10)
> M5 is done, moving to M6.

Thank you for picking up on that.

In the mean time:

I found a better fix that doesn't involve disabling evaluate():
https://git.eclipse.org/r/#/c/89875/

As such, this bug is not affected any more. Since it was meregd in M5, I'll set the Target milestone back to when this patch was originally merged.
Comment 12 Leo Ufimtsev CLA 2017-04-03 12:59:02 EDT
Need to modify previous debug_flag in makefile a bit.
Comment 13 Eclipse Genie CLA 2017-04-03 12:59:22 EDT
New Gerrit change created: https://git.eclipse.org/r/94319