Details
-
Bug
-
Status: Closed
-
P3
-
Resolution: Duplicate
-
9, 11, 12
Description
ADDITIONAL SYSTEM INFORMATION :
Windows 8.1
Java 11.0.1
A DESCRIPTION OF THE PROBLEM :
Layouting text glyph vectors takes considerably longer in Java 11, compared to Java 8.
For example, use the attached source code(it is from another JDK bug, I am not the author).
REGRESSION : Last worked in version 8u192
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the source code on either all fonts in Fonts dir, or copy a smaller subset of fonts, e.g. "Arial" fonts to a different directory and run the code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
At least similar text glyph layout performance when comparing Java8 to Java 11.
ACTUAL -
Layout is slower 2-5 times.
Profiling for all fonts in Fonts dir.
In Java 11.0.1:
java.awt.Font.layoutGlyphVector 182s
sun.font.GlyphLayout.layout 182s
sun.font.GlyphLayout$EngineRecord.layout 180s
sun.font.SunLayoutEngine.layout 180s
sun.font.SunLayoutEngine.shape 180s
Java8:
java.awt.Font.layoutGlyphVector 73s
sun.font.GlyphLayout.layout 73s
sun.font.GlyphLayout$EngineRecord.layout 73s
sun.font.SunLayoutEngine.layout 73s
sun.font.SunLayoutEngine.nativeLayout 72s
For a font like Arial:
Java11.0.1:
c:\windows\fonts\arial.ttf;Arial; 493ms
c:\windows\fonts\arialbd.ttf;Arial Bold; 492ms
c:\windows\fonts\arialbi.ttf;Arial Bold Italic; 392ms
Java 8:
c:\windows\fonts\arial.ttf;Arial; 90ms
c:\windows\fonts\arialbd.ttf;Arial Bold; 91ms
c:\windows\fonts\arialbi.ttf;Arial Bold Italic; 89ms
The layout time difference is ~5 times.
---------- BEGIN SOURCE ----------
This is the code, that was previously used is bug description.
public class GVT
{
//Adapt FONT_DIRECTORY for other OSs or specific folders with a selected sets of fonts ("Arial" and "Arial Unicode MS" highly recommended)
private static final String FONT_DIRECTORY = "c:\\windows\\fonts\\";
private static final int REPETITIONS = 5_000;
private static final char[] TEXT = "X sosofts 0,0 Steffieie Y".toCharArray();
private static final FontRenderContext FRC = new FontRenderContext(null, true, true);
public static void main(String[] args) throws Throwable
{
System.out.println("Java " + System.getProperty("java.version") + " on " + System.getProperty("os.name") + "\n");
for (File fontFile : new File(FONT_DIRECTORY).listFiles())
{
if (fontFile.toString().toLowerCase().endsWith(".ttf"))
{
Font font = Font.createFont(Font.TRUETYPE_FONT, fontFile).deriveFont(123f)
.deriveFont(Collections.singletonMap(TextAttribute.KERNING, TextAttribute.KERNING_ON))
.deriveFont(Collections.singletonMap(TextAttribute.LIGATURES, TextAttribute.LIGATURES_ON));
System.out.print(fontFile.toString() + ";" + font.getName() + ";");
long start = System.nanoTime();
for (int i = 0; i < REPETITIONS; i++)
{
font.layoutGlyphVector(FRC, TEXT, 0, TEXT.length, 0);
}
System.out.println((System.nanoTime() - start) / REPETITIONS / 1000);
}
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround
FREQUENCY : always
Windows 8.1
Java 11.0.1
A DESCRIPTION OF THE PROBLEM :
Layouting text glyph vectors takes considerably longer in Java 11, compared to Java 8.
For example, use the attached source code(it is from another JDK bug, I am not the author).
REGRESSION : Last worked in version 8u192
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the source code on either all fonts in Fonts dir, or copy a smaller subset of fonts, e.g. "Arial" fonts to a different directory and run the code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
At least similar text glyph layout performance when comparing Java8 to Java 11.
ACTUAL -
Layout is slower 2-5 times.
Profiling for all fonts in Fonts dir.
In Java 11.0.1:
java.awt.Font.layoutGlyphVector 182s
sun.font.GlyphLayout.layout 182s
sun.font.GlyphLayout$EngineRecord.layout 180s
sun.font.SunLayoutEngine.layout 180s
sun.font.SunLayoutEngine.shape 180s
Java8:
java.awt.Font.layoutGlyphVector 73s
sun.font.GlyphLayout.layout 73s
sun.font.GlyphLayout$EngineRecord.layout 73s
sun.font.SunLayoutEngine.layout 73s
sun.font.SunLayoutEngine.nativeLayout 72s
For a font like Arial:
Java11.0.1:
c:\windows\fonts\arial.ttf;Arial; 493ms
c:\windows\fonts\arialbd.ttf;Arial Bold; 492ms
c:\windows\fonts\arialbi.ttf;Arial Bold Italic; 392ms
Java 8:
c:\windows\fonts\arial.ttf;Arial; 90ms
c:\windows\fonts\arialbd.ttf;Arial Bold; 91ms
c:\windows\fonts\arialbi.ttf;Arial Bold Italic; 89ms
The layout time difference is ~5 times.
---------- BEGIN SOURCE ----------
This is the code, that was previously used is bug description.
public class GVT
{
//Adapt FONT_DIRECTORY for other OSs or specific folders with a selected sets of fonts ("Arial" and "Arial Unicode MS" highly recommended)
private static final String FONT_DIRECTORY = "c:\\windows\\fonts\\";
private static final int REPETITIONS = 5_000;
private static final char[] TEXT = "X sosofts 0,0 Steffieie Y".toCharArray();
private static final FontRenderContext FRC = new FontRenderContext(null, true, true);
public static void main(String[] args) throws Throwable
{
System.out.println("Java " + System.getProperty("java.version") + " on " + System.getProperty("os.name") + "\n");
for (File fontFile : new File(FONT_DIRECTORY).listFiles())
{
if (fontFile.toString().toLowerCase().endsWith(".ttf"))
{
Font font = Font.createFont(Font.TRUETYPE_FONT, fontFile).deriveFont(123f)
.deriveFont(Collections.singletonMap(TextAttribute.KERNING, TextAttribute.KERNING_ON))
.deriveFont(Collections.singletonMap(TextAttribute.LIGATURES, TextAttribute.LIGATURES_ON));
System.out.print(fontFile.toString() + ";" + font.getName() + ";");
long start = System.nanoTime();
for (int i = 0; i < REPETITIONS; i++)
{
font.layoutGlyphVector(FRC, TEXT, 0, TEXT.length, 0);
}
System.out.println((System.nanoTime() - start) / REPETITIONS / 1000);
}
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround
FREQUENCY : always
Attachments
Issue Links
- duplicates
-
JDK-8202131 LineBreakMeasurer is 10 times slower in JDK10 than in JDK8
-
- Open
-