Bug 530678 - [webkit2] UI hangs after navigating through Javadoc hover, when clicking an icon or link to an image (Webkit deadlock during callback)
Summary: [webkit2] UI hangs after navigating through Javadoc hover, when clicking an i...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.8   Edit
Hardware: PC Linux
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: Leo Ufimtsev CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression, triaged, usability
Depends on:
Blocks:
 
Reported: 2018-02-02 17:47 EST by Aidan Yaklin CLA
Modified: 2020-10-22 15:51 EDT (History)
6 users (show)

See Also:


Attachments
Thread dump after Javadoc hovers go blank (22.09 KB, text/plain)
2018-02-18 15:12 EST, Aidan Yaklin CLA
no flags Details
Thread dump after UI becomes unresponsive (26.46 KB, text/plain)
2018-02-18 15:13 EST, Aidan Yaklin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aidan Yaklin CLA 2018-02-02 17:47:24 EST
-- Configuration Details --
Product: Eclipse 4.7.2.20171218-0600 (org.eclipse.epp.package.java.product)Installed Features:
 org.eclipse.platform 4.7.2.v20171130-0510
Running on Ubuntu 16.04

Error occurs at times when Code Recommenders window opens:

Exception in thread "EclipseProjectCoordinateAdvisorService STARTING" java.lang.IllegalArgumentException: assertion failed.
	at org.eclipse.recommenders.utils.Throws.throwIllegalArgumentException(Throws.java:29)
	at org.eclipse.recommenders.utils.Checks.ensureIsTrue(Checks.java:254)
	at org.eclipse.recommenders.utils.Checks.ensureIsTrue(Checks.java:249)
	at org.eclipse.recommenders.coordinates.DependencyInfo.<init>(DependencyInfo.java:52)
	at org.eclipse.recommenders.internal.coordinates.rcp.DependencyInfoJsonTypeAdapter.deserialize(DependencyInfoJsonTypeAdapter.java:57)
	at org.eclipse.recommenders.internal.coordinates.rcp.DependencyInfoJsonTypeAdapter.deserialize(DependencyInfoJsonTypeAdapter.java:1)
	at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
	at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
	at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:173)
	at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:145)
	at com.google.gson.Gson.fromJson(Gson.java:887)
	at com.google.gson.Gson.fromJson(Gson.java:852)
	at com.google.gson.Gson.fromJson(Gson.java:801)
	at org.eclipse.recommenders.coordinates.rcp.EclipseProjectCoordinateAdvisorService.startUp(EclipseProjectCoordinateAdvisorService.java:172)
	at com.google.common.util.concurrent.AbstractIdleService$2$1.run(AbstractIdleService.java:54)
	at com.google.common.util.concurrent.Callables$3.run(Callables.java:93)
	at java.lang.Thread.run(Thread.java:748)

UI becomes partially unresponsive: 
* Error/warning underlines are not updated.
* Mouse input is ignored in main editor. Menus can still be opened and buttons can be clicked (although most don't do anything).
* The editor does not scroll when scrolling, only the scrollbar.
* Save and Exit buttons in the File menu and toolbar still work
* Keyboard input still works, and progress can be saved through Ctrl+Shift+S
* Sometimes the main editor keeps Eclipse from closing (all other editors close, but the main one stays as a large white rectangle in the middle of the window.
Restarting Eclipse fixes the problem temporarily, but it re-appears rather quickly.

Any help would be appreciated, since I prefer using Code Recommenders to reading Javadocs and this bug is quite annoying. :)
Comment 1 Aidan Yaklin CLA 2018-02-02 17:54:44 EST
Update: The stack trace provided appears every time the Code Recommenders popup opens
Comment 2 Aidan Yaklin CLA 2018-02-02 17:57:49 EST
(In reply to Aidan Yaklin from comment #1)
> Update: The stack trace provided appears every time the Code Recommenders
> popup opens

* It actually happens only the first time, sorry :)
Comment 3 Andreas Sewe CLA 2018-02-06 07:23:21 EST
Hi Aidan,

(In reply to Aidan Yaklin from comment #0)
> Any help would be appreciated, since I prefer using Code Recommenders to
> reading Javadocs and this bug is quite annoying. :)

thanks for the compliments and your bug report, of course.

To help us analyze what went wrong, can you please provide the following information:

- Please attach the following file to this bug:
  $WORKSPACE/.recommenders/caches/identified-project-coordinates.json

- Disable Code Recommenders (Preferences > Code Recommenders > Completions > Enable Code Recommenders code completion) and see if the responsiveness of the UI improves. I can't imagine why the error (IAE while parsing a file) results in a sluggish UI.

(In reply to Aidan Yaklin from comment #1)
> Update: The stack trace provided appears every time the Code Recommenders
> popup opens

What exactly do you mean by Code Recommenders popup (content assist aka code completion)? Or something like the "Code Recommenders is enabled" proposal [1] (which should only appear once)?

[1] <https://www.eclipse.org/recommenders/manual/#installation>
Comment 4 Aidan Yaklin CLA 2018-02-12 10:34:30 EST
The identified_project_coordinates.json file looks like this:

[[{"location":"C:\\Program Files\\Java\\jdk1.8.0_101","type":"JRE","hints":{"EXECUTION_ENVIRONMENT":"JavaSE-1.8"}},"jre:jre:1.8.0"]]

The path is a Windows path because I migrated this workspace from Windows to Ubuntu (this may be causing the exception!)

I have found that the exception is unrelated to the bug, so here are some steps to reproduce the problem:

1. Open a Java file and hover over a class or method name to show the Javadoc.
2. Click on the small icon next to the name of the class or method to navigate to it.
3. Hover over another class or method name to show the Javadoc popup. Note that it is blank, and focusing it will turn it black.
4. Open up a code completion popup somewhere.
5. The editors will become unresponsive except the scrollbar. You can save and close Eclipse.
6. Sometimes Eclipse hangs when closing; you may need to kill the process.
Comment 5 Andrey Loskutov CLA 2018-02-17 02:54:52 EST
Please create few jstack dumps during Eclipse is not responsible, and attach those dumps here.
Comment 6 Aidan Yaklin CLA 2018-02-18 15:12:38 EST
Created attachment 272725 [details]
Thread dump after Javadoc hovers go blank

I have created two thread dumps at the critical points in the bug:
(1) After the Javadoc hovers stop displaying content
(2) After the UI becomes unresponsive
Comment 7 Aidan Yaklin CLA 2018-02-18 15:13:33 EST
Created attachment 272726 [details]
Thread dump after UI becomes unresponsive
Comment 8 Andrey Loskutov CLA 2018-02-18 15:15:38 EST
I believe there was a webkit bug causing UI hang-ups. Moving to SWT.
Comment 9 Alexander Kurtakov CLA 2018-02-19 08:58:54 EST
Cna you try whether this happend with Photon M5? There have been significant updates in SWT Webkit port.
Comment 10 Aidan Yaklin CLA 2018-02-19 21:29:08 EST
I tried Photon M5. The glitch occurs, but the UI only lags a bit instead of completely hanging. Javadoc hovers are still glitchy.
Comment 11 Leo Ufimtsev CLA 2018-02-21 16:50:12 EST
(In reply to Aidan Yaklin from comment #10)
> I tried Photon M5. The glitch occurs, but the UI only lags a bit instead of
> completely hanging. Javadoc hovers are still glitchy.

Sounds like this occurred due to dead-lock in the evaluation logic. (Recursive evaluate).

In 4.8 M6 I've fixed a situation where a recursive evaluate() could cause a hang:
527564 – [Webkit2] Deadlock due to blocking javascript execution in a synchronous callback from webkit2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=527564

The fix is to ignore return value in the case where evaluate() is called recursively, this preventing the first evaluate waiting on the second one and the second one not starting because the first one is still waiting for the second one to finish.
~This is what's happening on OSX/Win32, so I don't expect issues.

I've also resolved other such issues (looking at initial thread dump).

Can you please test with nightly:
(like Integration build):
http://download.eclipse.org/eclipse/downloads/

If issue persists, you should see a trace in the console. Please post here along with detailed steps to reproduce.


-----
As a note, if you see a momentary (3 second) ii-unresponsiveness with Webkit.evaluate involved, I should be told about it along with a stack trace. But to my knowledge there shouldn't be any such issues as of recent builds.
Comment 12 Aidan Yaklin CLA 2018-02-25 17:18:58 EST
Tried eclipse-platform-M20180221-0535-linux-gtk-x86_64 for the bug. Javadoc hovers still become blank after clicking the icon, and the hangup still appears when using code completion. Eclipse does not hang when closing, however. 

Here are steps to reproduce this:
1. Create a Java project
2. Add a HelloWorld class with this code:

    public class HelloWorld {
        public static void main(String[] args) {
            System.out.println("Hello World!");
        }
    }

3. Hover over System to view its Javadoc 
4. Click on the small green 'C' icon next to 'java.lang.System' in the hover. The source code for System (if JDK source code is installed) will appear.
5. Go back to the HelloWorld class and hover over an element to show its Javadoc. The hover will be blank.
6. Try adding another System.out.println() to the main method. This will cause the editor window and much of the UI to become unresponsive.
Comment 13 Leo Ufimtsev CLA 2018-02-26 11:11:17 EST
(In reply to Aidan Yaklin from comment #12)
> Tried eclipse-platform-M20180221-0535-linux-gtk-x86_64 for the bug. Javadoc
> hovers still become blank after clicking the icon, and the hangup still
> appears when using code completion. Eclipse does not hang when closing,
> however. 
> 
> Here are steps to reproduce this:
> 1. Create a Java project
> 2. Add a HelloWorld class with this code:
> 
>     public class HelloWorld {
>         public static void main(String[] args) {
>             System.out.println("Hello World!");
>         }
>     }
> 
> 3. Hover over System to view its Javadoc 
> 4. Click on the small green 'C' icon next to 'java.lang.System' in the
> hover. The source code for System (if JDK source code is installed) will
> appear.
> 5. Go back to the HelloWorld class and hover over an element to show its
> Javadoc. The hover will be blank.
> 6. Try adding another System.out.println() to the main method. This will
> cause the editor window and much of the UI to become unresponsive.

Thank you for steps to reproduce. 
When I click the icon, I can reproduce the issue. Will investigate.
Comment 14 Leo Ufimtsev CLA 2018-03-01 14:04:13 EST
I think this bug and this guy are related:
494158 – [Webkit1][Webkit2] JVM crash when javadoc hover has <embed> tags
https://bugs.eclipse.org/bugs/show_bug.cgi?id=494158

Icons are probably using <embed svg> of sort, which for some reason kills webkit, but only if it's in a javadoc, not in a regular browser window.
Comment 15 Leo Ufimtsev CLA 2018-03-15 21:25:35 EDT
I noticed that if a link links to an image, it also kills Webkit. E.g:

/**
 *  <a href="https://bugs.eclipse.org/bugs/attachment.cgi?id=272647">Screenshot </a>
 */
Comment 16 Leo Ufimtsev CLA 2018-03-19 15:08:18 EDT
The issue seems to be specific to Javadoc Hover. The issue doesn't occur in the Javadoc View.

Seems like there is some race condition between browser trying to load the image and browser being closed.

~Investigating.
Comment 17 Leo Ufimtsev CLA 2018-04-02 12:22:22 EDT
I setup a Fedora 26 vm. 
The issue doesn't occur on Webkit1 but (on the same VM) occurs on Webkit2.

So this is a regression. ~Investigating.
Comment 18 Leo Ufimtsev CLA 2018-04-03 12:28:29 EDT
Observations:
- The issue only occurs starting with WebkitGtk 2.18. (I.e, does not occur with 2.16).

- Further, webkit doesn't crash, but instead seems to deadlock on disposal.
If I manually kill off the WebKitNetworkProcess & WebKitWebProcess then new javadoc instances display correctly.

- I checked, not-adding the reference from fix:
522733 – [Gtk][Webkit2] Crash on close with webkitgtk 2.18
https://bugs.eclipse.org/bugs/show_bug.cgi?id=522733
Doesn't change the behaviour, but it looks like disposal changes in WebKitGtk2.18 somehow influence this issue as well.

I will continue to investigate the disposal deadlock.
Comment 19 Eclipse Genie CLA 2018-04-04 14:10:43 EDT
New Gerrit change created: https://git.eclipse.org/r/120730
Comment 21 Leo Ufimtsev CLA 2018-04-04 15:13:22 EDT
Fixed via:
https://git.eclipse.org/r/#/c/120730/

(see description for details).

Thank you for this bug report.