JDK-8129582 : Controls slow considerably when displaying RTL-languages text on Linux
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 8,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2015-06-22
  • Updated: 2020-07-07
  • Resolved: 2018-06-04
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.
JDK 8 Other
8u271Fixed openjfx11Fixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
openjdk version "1.8.0_45-internal"
OpenJDK Runtime Environment (build 1.8.0_45-internal-b14)
OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1 (2015-05-24) x86_64 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
JavaFX controls will slow down considerably when displaying text in RTL languages such as Arabic or Hebrew. This is _not_ an issue with NodeOrientation, only with the actual language text. 

Same code with text in English or other non-latin languages (Such as Japanese or Russian for example) work fine. 

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a ComboBox (this is probably happening in other controls too, but is most notable in a ComboBox). 
2. Add >10 items with text in either Hebrew or Arabic. 
3. Try to scroll through the items in the ComboBox.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Opening the ComboBox and scrolling through it should be as fast as when the strings inside are in any other language. 
ACTUAL -
Opening and scrolling through items is extremely slow and laggy. 

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;



public class MainApp extends Application{

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

	}

	@Override
	public void start(Stage mainStage) throws Exception {
		Pane p = new Pane();
		ComboBox<String> cb = new ComboBox<String>();
		for (int i=0; i<30; i++)
		{
			cb.getItems().add("��������");
		}
		p.getChildren().add(cb);
		
		Scene s = new Scene(p);
		
		mainStage.setScene(s);
		mainStage.show();
		
	}

}

---------- END SOURCE ----------


Comments
Changeset: 46bd0ff75f66 Author: prr Date: 2018-06-01 11:01 -0700 URL: http://hg.openjdk.java.net/openjfx/jfx-dev/rt/rev/46bd0ff75f66 8129582: Controls slow considerably when displaying RTL-languages text on Linux Reviewed-by: kcr ! modules/javafx.graphics/src/main/java/com/sun/javafx/font/freetype/PangoGlyphLayout.java
04-06-2018

OK. +1
04-06-2018

A regression test for a performance problem like this is likely to be too unreliable. I'll make fontmap final when I push
01-06-2018

The fix looks fine; I note that fontmap could be final. Would it be feasible to provide a regression test?
31-05-2018

Webrev: http://cr.openjdk.java.net/~prr/8129582/
31-05-2018

The root cause was pointed out by itaisha@gmail.com here : http://mail.openjdk.java.net/pipermail/openjfx-dev/2017-January/020148.html that the fontmap is an expensive thing to create, and we were recreating it on each call to layout. By caching it we can avoid this huge overhead. The comment in the mail about the performance of g_list_nth_data() is currently unproven in practice.
24-05-2018

I can reproduce this on Linux with the ComboBox based test case. I also tested pasting the string many times into HelloTextArea and found that editing the text also slowed down significantly. Scrolling in TextArea was not affected, which is probably because TextArea doesn't use virtual nodes like the ComboBox popup does using a ListView. I have not tested on other platforms.
24-02-2016

Attached test case JDK8129582.java
24-02-2016

@Jonathan: This might be a graphics issue in text layout. If it is, you can assign it to Phil.
24-06-2015