Why is JavaFX WebView blinking red and green?

I am just starting with JavaFX and I would like to put a WebView in a window:

public static class HelloJavaFXWeb extends Application { @Override public void start(Stage stage) throws Exception { final Group root = new Group(); Scene scene = new Scene(root, Color.DODGERBLUE); WebView webView = new WebView(); webView.getEngine().load("http://www.google.com"); root.getChildren().add(webView); stage.setTitle("HelloWorld in JavaFX 2.0"); stage.setScene(scene); stage.show(); } } Application.launch(HelloJavaFXWeb.class); 

It looks so simple, but for some reason, the drawing areas are highlighted in red and green when you move the mouse. How to disable blinking colors?

moving mouse over the webview

Update: issue related to Groovy / Gradle interaction

Here's an extremely minimal reproducer (put it all in build.gradle and run gradle tasks --no-daemon ):

 buildscript { dependencies { def jvm = org.gradle.internal.jvm.Jvm.current() if (jvm.javaVersion.isJava7()) { classpath files("${jvm.jre.homeDir}/lib/jfxrt.jar") } } } import javafx.application.*; import javafx.scene.*; import javafx.scene.paint.Color; import javafx.scene.web.WebView; import javafx.stage.Stage; class HelloJavaFXWeb extends Application { @Override public void start(Stage stage) throws Exception { final Group root = new Group(); Scene scene = new Scene(root, Color.DODGERBLUE); WebView webView = new WebView(); webView.getEngine().load("http://www.google.com"); root.getChildren().add(webView); stage.setTitle("HelloWorld in JavaFX 2.0"); stage.setScene(scene); stage.show(); } } Application.launch(HelloJavaFXWeb.class); 

I just noticed that it displays some entries after completion
(this was hidden earlier, probably because I used the Gradle daemon that swallowed it):

============ Performance statistics ==============

Amount of time / bills:
com.sun.webpane.perf.WCFontPerfLogger. *: ...
com.sun.webpane.perf.WCGraphicsPerfLogger. *: ...

I am using jdk1.7.0_80_x64/jre/lib/jfxrt.jar for Windows 7 x64 Ultimate.

I tried the following versions of Java that I had on my computer:

 +-----------------+-----------+---------+ | version | flashing | logging | +-----------------+-----------+---------+ | jdk1.7.0_05_x86 | no JavaFX | | jdk1.7.0_80_x64 | yes | yes | | jdk1.7.0_80_x86 | yes | no | | jre1.7.0_80_x86 | yes | no | | jre1.7.0_80_x64 | yes | no | | jre1.8.0_45_x86 | no | no | | jre1.8.0_45_x64 | no | no | +-----------------+-----------+---------+ 
+5
source share
1 answer

After several hours of immersion in jfxrt.jar , trial and error and using @NwDx, here is a brief description of what is happening.

The Gradle build system works with the root JUL logger and sets the default FINER level to FINER from the source INFO . This activates many of the internal mechanisms inside the JavaFX runtime. Most noticeably:

  • Clip area debugging dependent on JUL Logger
  • PerfLogger Some JUL Logger Levels
  • many other unnecessary protocols, possibly for / dev / null

If you are careless, you can use: LogManager.getLogManager().reset() to fix everything. More careful patients may continue to read.

Click Area Debugging

There is visual debugging code protected by log.isLoggable(Level.FINE) in com.sun.webpane.sg.prism.WCGraphicsPrismContext .

This is a known bug registered here: https://bugs.openjdk.java.net/browse/JDK-8096483 Looking at the fix version: everyone up to 1.8.0u40 is susceptible to this unwanted visual debugging (see the table in the question). In 1.8.0u40 + you can -Dcom.sun.webkit.debugDrawClipShape=true enable this "function".

To be safe, you should turn off logging for this class either by configuring JUL, or:

 String name = com.sun.webpane.sg.prism.WCGraphicsPrismContext.class.getName(); java.util.logging.Logger.getLogger(name).setLevel(java.util.logging.Level.OFF); 

PerfLogger Logging

As mentioned in this question, some diagnostic data is spit out in stdout. PerfLogger checks the FINE level . The source of these messages is as follows:

  • com.sun.webpane.perf.WCGraphicsPerfLogger
  • com.sun.webpane.perf.WCFontPerfLogger
  • com.sun.webpane.platform.Invoker named Locks
  • TextBreakIteratorJava in jfxwebkit.dll is called XXXX via LOG_PERF_RECORD
    ... someone literally took an example, why ?: (

The easiest way to disable this:

 java.util.logging.Logger.getLogger('com.sun.webpane.perf').setLevel(Level.OFF) 

because the package name is hard-coded or Logger instances are in that package.

Other

It is probably worth making the log level higher (INFO-OFF) for all com.sun.* And javafx.* to prevent further strangeness or performance degradation.

For more information, see our chat .

+2
source

All Articles