ADDITIONAL SYSTEM INFORMATION :
LINUX_X86_64
Java 8 or 11 or 13
JavaFX: 11.0.3 or 13.0.x
A DESCRIPTION OF THE PROBLEM :
Dear JavaFX support team,
The exception happens only on Linux, JavaFX 8, 11+ (Java 11 or 13 not relevant). Important in standalone scenario - without embedding inside Eclipse works fine.
Somehow JavaFX thread check fails inside "SWT" environment.
Stacktraces:
java.lang.IllegalStateException: Not on FX application thread; currentThread = main
at javafx.graphics/com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:291)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:424)
at javafx.web/javafx.scene.web.WebEngine.checkThread(WebEngine.java:1207)
at javafx.web/javafx.scene.web.WebEngine.<init>(WebEngine.java:839)
at javafx.web/javafx.scene.web.WebEngine.<init>(WebEngine.java:826)
at javafx.web/javafx.scene.web.WebView.<init>(WebView.java:260)
at com.sap.components.controls.html.utils.Browser$1.call(Browser.java:87)
at com.sap.components.controls.html.utils.Browser$1.call(Browser.java:83)
at com.sap.components.controls.html.utils.Helpers$1.run(Helpers.java:36)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:1600)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4349)
...
Exception in thread "JavaFX Application Thread" org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:4711)
at org.eclipse.swt.SWT.error(SWT.java:4626)
at org.eclipse.swt.SWT.error(SWT.java:4597)
at org.eclipse.swt.widgets.Widget.error(Widget.java:532)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:470)
at org.eclipse.swt.widgets.Control.isVisible(Control.java:4462)
at org.eclipse.swt.widgets.ProgressBar.timerProc(ProgressBar.java:307)
at org.eclipse.swt.widgets.Display.windowTimerProc(Display.java:5811)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
at java.base/java.lang.Thread.run(Thread.java:834)
Code related to "com.sap.components.controls.html.utils.Helpers":
package com.sap.components.controls.html.utils;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import javafx.application.Platform;
/**
* Title: <TBD>
* Description: <TBD>
* Copyright: Copyright (c) 2004-2014
* Company: SAP AG
*
* @author Mykola Gorbarov (d043357)
* @version 1.0 (In Support since 2014)
*/
public class Helpers {
/**
* Synchronously execute task on FX user thread and return result.
*
* @param task to execute on FX user thread
* @return result of the task
*/
public static <T> T doTask(final Callable<T> task) {
final CountDownLatch barrier = new CountDownLatch(1);
final AtomicReference<T> resultRef = new AtomicReference<T>();
Runnable r = new Runnable() {
public void run() {
try {
resultRef.set(task.call());
} catch (Throwable t) {
t.printStackTrace();
} finally {
barrier.countDown();
}
}
};
if (Platform.isFxApplicationThread()) {
r.run();
} else {
Platform.runLater(r);
}
while (barrier.getCount() > 0) {
try {
barrier.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return resultRef.get();
}
REGRESSION : Last worked in version 11.0.5
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Bit complex, need Eclipse, GUI with JavaFX - you can embed easy swing applicaiton with javafx html control via jfxpanel.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception
CUSTOMER SUBMITTED WORKAROUND :
So far, no workaround
FREQUENCY : always
LINUX_X86_64
Java 8 or 11 or 13
JavaFX: 11.0.3 or 13.0.x
A DESCRIPTION OF THE PROBLEM :
Dear JavaFX support team,
The exception happens only on Linux, JavaFX 8, 11+ (Java 11 or 13 not relevant). Important in standalone scenario - without embedding inside Eclipse works fine.
Somehow JavaFX thread check fails inside "SWT" environment.
Stacktraces:
java.lang.IllegalStateException: Not on FX application thread; currentThread = main
at javafx.graphics/com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:291)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:424)
at javafx.web/javafx.scene.web.WebEngine.checkThread(WebEngine.java:1207)
at javafx.web/javafx.scene.web.WebEngine.<init>(WebEngine.java:839)
at javafx.web/javafx.scene.web.WebEngine.<init>(WebEngine.java:826)
at javafx.web/javafx.scene.web.WebView.<init>(WebView.java:260)
at com.sap.components.controls.html.utils.Browser$1.call(Browser.java:87)
at com.sap.components.controls.html.utils.Browser$1.call(Browser.java:83)
at com.sap.components.controls.html.utils.Helpers$1.run(Helpers.java:36)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:1600)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4349)
...
Exception in thread "JavaFX Application Thread" org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:4711)
at org.eclipse.swt.SWT.error(SWT.java:4626)
at org.eclipse.swt.SWT.error(SWT.java:4597)
at org.eclipse.swt.widgets.Widget.error(Widget.java:532)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:470)
at org.eclipse.swt.widgets.Control.isVisible(Control.java:4462)
at org.eclipse.swt.widgets.ProgressBar.timerProc(ProgressBar.java:307)
at org.eclipse.swt.widgets.Display.windowTimerProc(Display.java:5811)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
at java.base/java.lang.Thread.run(Thread.java:834)
Code related to "com.sap.components.controls.html.utils.Helpers":
package com.sap.components.controls.html.utils;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import javafx.application.Platform;
/**
* Title: <TBD>
* Description: <TBD>
* Copyright: Copyright (c) 2004-2014
* Company: SAP AG
*
* @author Mykola Gorbarov (d043357)
* @version 1.0 (In Support since 2014)
*/
public class Helpers {
/**
* Synchronously execute task on FX user thread and return result.
*
* @param task to execute on FX user thread
* @return result of the task
*/
public static <T> T doTask(final Callable<T> task) {
final CountDownLatch barrier = new CountDownLatch(1);
final AtomicReference<T> resultRef = new AtomicReference<T>();
Runnable r = new Runnable() {
public void run() {
try {
resultRef.set(task.call());
} catch (Throwable t) {
t.printStackTrace();
} finally {
barrier.countDown();
}
}
};
if (Platform.isFxApplicationThread()) {
r.run();
} else {
Platform.runLater(r);
}
while (barrier.getCount() > 0) {
try {
barrier.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return resultRef.get();
}
REGRESSION : Last worked in version 11.0.5
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Bit complex, need Eclipse, GUI with JavaFX - you can embed easy swing applicaiton with javafx html control via jfxpanel.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception
CUSTOMER SUBMITTED WORKAROUND :
So far, no workaround
FREQUENCY : always