JDK-8315653 : Certain characters in Text node prevent later characters from rendering
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: jfx11,8,jfx17,jfx20,jfx21,jfx22
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2023-08-30
  • Updated: 2023-09-18
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
Description
ADDITIONAL SYSTEM INFORMATION :
OpenJDK 22-ea+12
OpenJFX 22-ea+6
Bug has been present since at least OpenJFX 17.0.1

A DESCRIPTION OF THE PROBLEM :
Certain characters (such as `த` or `ம` from the Tamil alphabet), when followed by a large number of characters without line breaks in the same `Text` node, break the rendering of later characters in the same line and `Text` node.

For example, when a `Text` node has contents `"த" + "a".repeat(32_001)`, the Text node only renders as `த`. When the number of characters following `த` is reduced to 32,000, then the paragraph renders correctly.

The bug still occurs when there is whitespace after `த`, only the number at which the bug occurs is slightly different. Inserting ASCII characters at the start of the paragraph doesn't appear to change anything.

`文` is a non-ASCII character that doesn't trigger the bug, but the behaviour is a bit different when it is used instead of `a`. For example, `"த" + "文".repeat(32_001) + "b"` renders as `தb`, but `"த" + "a".repeat(32_001) + "b"` renders as `த`.

The bug affects `TextArea`s as well. You may find more information here, where I first reported the bug before seeing it was caused by the `Text` node: https://github.com/FXMisc/RichTextFX/issues/1188

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run `Launcher.main()` in the code below.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
`த` followed by a long sequence of `a`s is displayed.
ACTUAL -
`த` is displayed with no `a`s.

---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class TextCutOffBug extends Application {
	
	public static void main(String[] args) {
		TextCutOffBug.launch(args);
	}
	
	@Override
	public void start(Stage stage) {
		String text = "த" + "a".repeat(32_001);
		Text textNode = new Text(text);
		Scene scene = new Scene(new ScrollPane(textNode), 500, 300);
		stage.setScene(scene);
		stage.show();
	}
	
	public static class Launcher {
		public static void main(String[] args) {
			TextCutOffBug.main(args);
		}
	}
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
The bug only appears to occur when a `Text` node has over 32,000 characters. So a workaround is to use multiple `Text` nodes each with 32,000 characters or fewer instead of a single node.

FREQUENCY : always



Comments
As already noted this reproduces all the way back to JDK 8 which is when support for complex text was added. Also it seems to be windows-specific, which rather suggests a problem in the Direct Write code - or perhaps even a limitation of that API. Note that adding a linebreak after the Tamil char "cures" the problem pointing towards some kind of limit in that layout code, but a 32,000 character paragraph with no hard line breaks seems rare .. it corresponds to maybe 10 full pages of text.
18-09-2023

A single string with > 32,000 characters is not a common scenario, so I am lowering the priority to P4.
11-09-2023

Checked with attached testcase in Windows 10, Issue is reproducible, attached screenshot Test Result ========= 8u381: Fail jfx11: Fail jfx17: Fail jfx20: Fail jfx21ea: Fail Moving to JDK Project for more evaluation.
11-09-2023