JDK-8164438 : JavaFX changes Windows interrupt frequency to 1ms
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: other
  • Affected Version: 7u6,8,9,10
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2016-08-15
  • Updated: 2020-01-31
  • Resolved: 2019-11-14
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
1.8.0_73

ADDITIONAL OS VERSION INFORMATION :
Windows 7
Windows 10

A DESCRIPTION OF THE PROBLEM :
Running a trivial JavaFX app which opens a single, blank, WebView, causes Windows to switch to 1ms interrupt frequency from its default 15.6ms frequency. This is causing battery drain on partable devices. There does not appear to be a way to prevent this behaviour.

Note this may not be WebView-specific, that is just what our app uses.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Write a trivial JavaFX program which opens a WebView. Use the ClockRes tool from MSDN to check the Windows interrupt frequency. You will see it switch from 15.6ms to 1ms



REPRODUCIBILITY :
This bug can be reproduced always.


Comments
This is an enhancement request rather than a bug. We deliberately set the clock interrupt frequency to 1 ms in the glass timer code that runs our animations and rendering loop. Additionally, our use of Direct3D for HW accerlerated rendering switches to 1ms accuracy. We can't just change our implementation to stop doing this without negatively impacting performance. It seems we have two ways we could address this: 1. Provide an option to disable this, probably via a system property. This would either need to disable D3D hardware acceleration, or we would need to do work to initialize D3D differently when high-resolution timers were enabled. 2. Dynamically detect when animation or some other task that needs low latency interrupts is running, set the clock frequency to 1 ms when needed, and restore it when no longer needed. This would require a lot of work and testing to find the right balance between performance and battery life.
25-08-2016

I can reproduce this, and confirm that it is not a regression. It happens in every release since at least 8 GA.
23-08-2016

Note that this happens without WebView, so I changed the synopsis and Subcomponent accordingly.
19-08-2016

According to submitter, the issue is that when running on Windows, JavaFX changes the Windows timer resolution from its default of 15.6ms to 1ms, irrespective of whether this accuracy of timer is required or not. Changing the timer resolution in this way decreases device battery life by approx. 22% Consider the following trivial JavaFX code: import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.stage.Stage; public class Main extends Application { @Override public void start(final Stage stage) { Scene scene = new Scene(new Group()); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(args); } } If you use the ClockRes tool (https://technet.microsoft.com/en-us/sysinternals/bb897568.aspx) you will see that when the above code is run, the system timer resolution switches from 15.6ms to 1ms
19-08-2016

We will need a simple test application with steps to investigate the issue.
17-08-2016