JDK-8286633 : Loading a website with long script tasks freezes the UI
  • Type: Bug
  • Component: javafx
  • Sub-Component: web
  • Affected Version: openjfx19
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2022-05-12
  • Updated: 2022-11-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
Using a WebView to display a website that contains some (poorly designed) scripts that take too long to complete, can block and freeze completely the JavaFX Application Thread.

The attached test loads a simple local web page and after one second executes a simple script that takes 5 seconds to complete. 

The animation timer is added for the purpose of measuring the lapse between pulses, and when running the test it will show a value of 5 seconds (like 5002 ms), which is the lapse of time with the application totally unresponsive (the spinning wait cursor can be seen too).

It can be reproduced with any JavaFX version.
  
 
Comments
I have modified the test program as !DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Test long js task</title> <script> function test() { const start = Date.now(); for (;;) { if (Date.now() - start > 5000) { break; } } document.body.append("done"); } var promise = new Promise(function(resolve, reject) { setTimeout(test, 1000); }); promise.then(function(data) { }); </script> </head> <body> <br>Running test, please wait...<br> </body> </html> The behavior is same. As JS is single threaded and in our current architecture webkit runs in java process. Further investigation is required.
17-05-2022