-
Bug
-
Resolution: Incomplete
-
P3
-
8
-
Linux 32 bit, jdk8 b109
Hi, under heavy load with several threads we get following:
JavaFX Application Thread <--- Frozen for at least 57s
com.sun.glass.ui.gtk.GtkApplication._runLoop(Runnable, boolean)
com.sun.glass.ui.gtk.GtkApplication.access$200(GtkApplication, Runnable, boolean)
com.sun.glass.ui.gtk.GtkApplication$5$1.run()
java.lang.Thread.run()
in many conditions the application will run along but sometimes it stops. We developing a RCP framework where many threads are calling Platform.runLater ... on windows and mac osx it runs well but on linux we get this freeze in com.sun.glass.ui.gtl.GtkApplication.
I created a simple (but extreme) example where this error occurs most of the time:
public class HelloAsyncRunLaterSlow extends Application {
@Override public void start(Stage primaryStage) throws Exception {
System.err.println("Application.start");
final Button startButton = new Button("Start");
final HBox box = new HBox();
box.setMinHeight(600);
box.setMinWidth(800);
box.setCache(true);
box.getChildren().addAll(startButton);
startButton.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
}
});
Scene scene = new Scene(box);
primaryStage.setScene(scene);
primaryStage.show();
}
private Thread createThread(final HBox box) {
return new Thread(()->{
for(int i=0;i<100000;i++) {
final int counter =i;
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
Platform.runLater(()->{
box.setCacheHint(CacheHint.SPEED);
box.getChildren().clear();
box.getChildren().add(new Button("counter: "+counter+" in Thread:"+Thread.currentThread()));
box.setCacheHint(CacheHint.QUALITY);
}) ;
}
});
}
@Override public void stop() throws Exception {
System.err.println("Application.stop");
}
public static void main(String[] args) {
Application.launch(args);
System.err.println("return from main method");
}
}
JavaFX Application Thread <--- Frozen for at least 57s
com.sun.glass.ui.gtk.GtkApplication._runLoop(Runnable, boolean)
com.sun.glass.ui.gtk.GtkApplication.access$200(GtkApplication, Runnable, boolean)
com.sun.glass.ui.gtk.GtkApplication$5$1.run()
java.lang.Thread.run()
in many conditions the application will run along but sometimes it stops. We developing a RCP framework where many threads are calling Platform.runLater ... on windows and mac osx it runs well but on linux we get this freeze in com.sun.glass.ui.gtl.GtkApplication.
I created a simple (but extreme) example where this error occurs most of the time:
public class HelloAsyncRunLaterSlow extends Application {
@Override public void start(Stage primaryStage) throws Exception {
System.err.println("Application.start");
final Button startButton = new Button("Start");
final HBox box = new HBox();
box.setMinHeight(600);
box.setMinWidth(800);
box.setCache(true);
box.getChildren().addAll(startButton);
startButton.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
createThread(box).start();
}
});
Scene scene = new Scene(box);
primaryStage.setScene(scene);
primaryStage.show();
}
private Thread createThread(final HBox box) {
return new Thread(()->{
for(int i=0;i<100000;i++) {
final int counter =i;
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
Platform.runLater(()->{
box.setCacheHint(CacheHint.SPEED);
box.getChildren().clear();
box.getChildren().add(new Button("counter: "+counter+" in Thread:"+Thread.currentThread()));
box.setCacheHint(CacheHint.QUALITY);
}) ;
}
});
}
@Override public void stop() throws Exception {
System.err.println("Application.stop");
}
public static void main(String[] args) {
Application.launch(args);
System.err.println("return from main method");
}
}
- relates to
-
JDK-8115963 Document that applications should avoid flooding FX with Platform.runLater calls
-
- Resolved
-