Joey
Joey

Reputation: 37

JavaFX: hostservices.showDocument() bad perfomance

For a JavaFX standalone desktop application I am using hostservices.showDocument() to open URLs in the default web browser. But in most cases if I try to open URLs with this method, it takes a lot of time (20-30 secs) until browser opens. Is there any known performance bug regarding this or does anyone have the same problem? I don't have this issue with awt.Desktop.getDesktop.browse() (browser opens immediately) but I don't want to use AWT stack in a JavaFX application.

Upvotes: 1

Views: 914

Answers (1)

trashgod
trashgod

Reputation: 205855

It's hard to say where your application goes awry, but it may help to study the problem in isolation. Try the complete example below to help you isolate the latency. It opens at least as fast as Desktop#browse() on my platform, i.e. within a second.

import javafx.application.Application;
import javafx.application.HostServices;
import javafx.event.ActionEvent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
 * @see http://stackoverflow.com/a/37839898/230513
 */
public class Test extends Application {

    private final HostServices services = this.getHostServices();

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("Test");
        Button button = new Button("Example");
        button.setOnAction((ActionEvent e) -> {
            services.showDocument("http://example.com/");
        });
        StackPane root = new StackPane();
        root.getChildren().add(button);
        Scene scene = new Scene(root, 320, 240);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Addendum: Using the isolated test case, @Joey was able to determine that the problem

  • Did occur with showDocument(); did not occur with direct browser access.

  • Did occur with long URLs; did not occur with short URLs.

  • Did occur on one computer; did not occur on others.

The culprit appears to be GDA G Data InternetSecurity "behavioral analysis proxy," avkbap64.exe, discussed here.

Upvotes: 3

Related Questions