Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 527564 (webkit2ExecHang)

Summary: [Webkit2] Deadlock due to blocking javascript execution in a synchronous callback from webkit2
Product: [Eclipse Project] Platform Reporter: Leo Ufimtsev <lufimtse>
Component: SWTAssignee: Leo Ufimtsev <lufimtse>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P2 CC: platform-swt-inbox
Version: 4.8   
Target Milestone: 4.8 M6   
Hardware: PC   
OS: Linux   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=510905
https://git.eclipse.org/r/112522
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=5f801a066f2bfd52d2b48ed6accfe4be88a67ac6
Whiteboard:
Bug Depends on: 527737    
Bug Blocks: 514859, 516838    
Attachments:
Description Flags
snippet to reproduce
none
Snippet with minimum set of code to reproduce. none

Description Leo Ufimtsev CLA 2017-11-21 11:23:46 EST
With attached snippet, webkit2 hangs on Javascript execution when creating a new BrowserFunction.

Need to investigate.

This is independent of the gdbus/webextension implementation.
Comment 1 Leo Ufimtsev CLA 2017-11-21 11:24:48 EST
Created attachment 271575 [details]
snippet to reproduce
Comment 2 Leo Ufimtsev CLA 2017-11-21 11:33:12 EST
Using different Function classes still hangs on webkit2.
Need to dig deeper into this one.
Comment 3 Leo Ufimtsev CLA 2017-11-21 11:38:06 EST
I should also make a junit for this.
Comment 4 Leo Ufimtsev CLA 2017-11-21 11:39:22 EST
Multiple functions in a single browser works, but multiple once seem to cause the hang.
Comment 5 Leo Ufimtsev CLA 2017-11-21 15:08:54 EST
Created attachment 271576 [details]
Snippet with minimum set of code to reproduce.

The pattern that reproduces the issue seems to be:

Browser b1
b1.settext(..)
new CustomFunction(..)

Browser b2
b2.settext(..)
new CustomFunction2(..)  << hang occurs here. In 'execute()', never comes back.

(attaching minimum snippet).

Notes:
- hang only occurs for BrowserFunction registration function, a sole evalute() doesn't trigger it. (But fault could be some javascript syntax).
- hang only occurs if statements are executed in that order, if you first initialize both browsers and then both functions, the issue doesn't occur.

Not quite sure if bug in Webkitgtk or if in SWT logic. Need to investigate further.
Comment 6 Leo Ufimtsev CLA 2017-11-28 17:38:08 EST
After investigation, I found that the deadlock occurred because javascript was being executed from a synchronous callback, which lead to a deadlock.

I'll implement relevant logic to prevent this and other such issues in the future.
Comment 7 Eclipse Genie CLA 2017-11-28 17:44:17 EST
New Gerrit change created: https://git.eclipse.org/r/112522
Comment 9 Leo Ufimtsev CLA 2018-03-07 16:12:23 EST
Verified against master. Fixed.