Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Ufimtsev2018-05-11 11:09:54 -0400
committerEric Williams2018-05-14 10:40:09 -0400
commit52d6905fa13fe1fd24008b62655420ba524f8b47 (patch)
tree5760af29979be3fbb506f0797d99f8ff9174ddaf
parent58a421c273b06ca51a7f574393d46543a7a71a2d (diff)
downloadeclipse.platform.swt-52d6905fa13fe1fd24008b62655420ba524f8b47.tar.gz
eclipse.platform.swt-52d6905fa13fe1fd24008b62655420ba524f8b47.tar.xz
eclipse.platform.swt-52d6905fa13fe1fd24008b62655420ba524f8b47.zip
Bug 534555 - [GTK] Browser stops responding and throws an error on
dispose (Browser crash) I found an subtle issue in javascript execution logic. The javascript execution logic is canceled if browser's *shell* is disposed. This is wrong, the javascript logic should check if the *browser* is disposed, not the browser's shell because you can have the situation where the shell is not disposed but the browser is. Also updating error message to clarify slow javascript execution for users. I can't reproduce the issue locally, so I can only assume this fixes the reported issue. But I tested jUnits and child Eclipse and didn't have issues. Change-Id: Icae4ec6c28dd17fb1e555f24fbd5b0b984702917 Signed-off-by: Leo Ufimtsev <lufimtse@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
index f8aebf6ff3..f987f90f65 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
@@ -148,7 +148,7 @@ class WebKit extends WebBrowser {
* https://www.nczonline.net/blog/2009/01/05/what-determines-that-a-script-is-long-running/
* https://stackoverflow.com/questions/3030024/maximum-execution-time-for-javascript
*/
- static final int ASYNC_EXEC_TIMEOUT_MS = 3000; // Webkit2.
+ static final int ASYNC_EXEC_TIMEOUT_MS = 10000; // Webkit2.
static boolean bug522733FirstInstanceCreated = false; //Webkit2 workaround for Bug 522733
@@ -418,7 +418,7 @@ class WebKit extends WebBrowser {
}
private static String getInternalErrorMsg () {
- String reportErrMsg = "Please report this issue with steps to reproduce via:\n"
+ String reportErrMsg = "Please report this issue *with steps to reproduce* via:\n"
+ " https://bugs.eclipse.org/bugs/enter_bug.cgi?"
+ "alias=&assigned_to=platform-swt-inbox%40eclipse.org&attach_text=&blocked=&bug_file_loc=http%3A%2F%2F&bug_severity=normal"
+ "&bug_status=NEW&comment=&component=SWT&contenttypeentry=&contenttypemethod=autodetect&contenttypeselection=text%2Fplain"
@@ -1557,7 +1557,7 @@ private static class Webkit2AsyncToSync {
/** Object used to return data from callback to original call */
private static class Webkit2AsyncReturnObj {
boolean callbackFinished = false;
- Object returnValue;
+ Object returnValue = null; // As note, if browser is disposed during excution, null is returned.
/** 0=no error. >0 means error. **/
int errorNum = 0;
@@ -1687,6 +1687,7 @@ private static class Webkit2AsyncToSync {
} else if (retObj.errorNum != 0) {
throw new SWTException(retObj.errorNum, retObj.errorMsg +"\nScript that was evaluated:\n" + script);
} else {
+ // This is also the implicit case where browser was disposed while javascript was executing. It returns null.
return retObj.returnValue;
}
}
@@ -1775,10 +1776,9 @@ private static class Webkit2AsyncToSync {
Webkit2AsyncReturnObj retObj = new Webkit2AsyncReturnObj();
int callbackId = CallBackMap.putObject(retObj);
asyncFunc.accept(callbackId);
- Shell shell = browser.getShell();
Display display = browser.getDisplay();
final Instant timeOut = Instant.now().plusMillis(ASYNC_EXEC_TIMEOUT_MS);
- while (!shell.isDisposed()) {
+ while (!browser.isDisposed()) {
boolean eventsDispatched = OS.g_main_context_iteration (0, false);
if (retObj.callbackFinished)
break;
@@ -1787,9 +1787,11 @@ private static class Webkit2AsyncToSync {
+ "ms. No return value will be provided.\n"
+ "Possible reasons:\n"
+ "1) Problem: Your javascript needs more than " + ASYNC_EXEC_TIMEOUT_MS +"ms to execute.\n"
- + " Solution: Don't run such javascript, it blocks UI. Instead register a BrowserFunction\n"
- + " and call the BrowserFunction upon completion"
- + "2) Deadlock in swt/webkit2 logic. This is probably a bug in SWT.\n"
+ + " Solution: Don't run such javascript, it blocks Eclipse's UI. SWT currently allows such code to complete, but this error is thrown \n"
+ + " and the return value of execute()/evalute() will be false/null.\n\n"
+ + "2) However, if you believe that your application should execute as expected (in under" + ASYNC_EXEC_TIMEOUT_MS + " ms),\n"
+ + " then it might be a deadlock in SWT/Browser/webkit2 logic.\n"
+ + " I.e, it might be a bug in SWT (e.g this does not occur on Windows/Cocoa, but occurs on Linux). If you believe it to be a bug in SWT, then\n"
+ getInternalErrorMsg()
+ "\n Additional information about the error is as following:\n"
+ additionalErrorInfo);

Back to the top