[ https://issues.apache.org/jira/browse/PDFBOX-3080?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14992496#comment-14992496 ]
Tilman Hausherr commented on PDFBOX-3080: ----------------------------------------- I got this twice in my test set: {code} java.io.EOFException: null at org.apache.fontbox.ttf.TTFDataStream.readUnsignedInt(TTFDataStream.java:136) at org.apache.fontbox.ttf.IndexToLocationTable.read(IndexToLocationTable.java:63) at org.apache.fontbox.ttf.TrueTypeFont.readTable(TrueTypeFont.java:382) at org.apache.fontbox.ttf.TrueTypeFont.getIndexToLocation(TrueTypeFont.java:251) at org.apache.fontbox.ttf.GlyphTable.read(GlyphTable.java:67) at org.apache.fontbox.ttf.TrueTypeFont.readTable(TrueTypeFont.java:382) at org.apache.fontbox.ttf.TrueTypeFont.getGlyph(TrueTypeFont.java:267) at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.getPath(PDCIDFontType2.java:454) at org.apache.pdfbox.pdmodel.font.PDType0Font.getPath(PDType0Font.java:503) at org.apache.pdfbox.rendering.TTFGlyph2D.getPathForGID(TTFGlyph2D.java:141) at org.apache.pdfbox.rendering.TTFGlyph2D.getPathForCharacterCode(TTFGlyph2D.java:93) at org.apache.pdfbox.rendering.PageDrawer.drawGlyph2D(PageDrawer.java:343) at org.apache.pdfbox.rendering.PageDrawer.showFontGlyph(PageDrawer.java:324) at org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph(PDFStreamEngine.java:750) at org.apache.pdfbox.contentstream.PDFStreamEngine.showText(PDFStreamEngine.java:707) at org.apache.pdfbox.contentstream.PDFStreamEngine.showTextString(PDFStreamEngine.java:570) at org.apache.pdfbox.contentstream.operator.text.ShowText.process(ShowText.java:50) at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:821) at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:478) at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:452) at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:156) at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:179) at org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:208) at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:139) at org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:80) at org.apache.pdfbox.rendering.TestPDFToImage.doTestFile(TestPDFToImage.java:246) at org.apache.pdfbox.rendering.TestPDFToImage.testRenderImage(TestPDFToImage.java:120) {code} > TrueTypeFont synchronization > ---------------------------- > > Key: PDFBOX-3080 > URL: https://issues.apache.org/jira/browse/PDFBOX-3080 > Project: PDFBox > Issue Type: Improvement > Components: FontBox > Affects Versions: 2.0.0 > Environment: Debian, java version "1.8.0_60" > Java(TM) SE Runtime Environment (build 1.8.0_60-b27) > Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode) > Reporter: ccouturi > Priority: Minor > Attachments: 0001-PDFBOX-3080-excessive-synchronization.patch > > > The use case is rasterize pdf to png. > On high load, a lot of threads are blocked in the > TrueTypeFont.getHorizontalMetrics() or getHorinzontalHeader() methods. > Jstack snippet: > {code} > Thread 21999: (state = BLOCKED) > - org.apache.fontbox.ttf.TrueTypeFont.getHorizontalMetrics() @bci=6, > line=231 (Compiled frame) > - org.apache.fontbox.ttf.TrueTypeFont.getAdvanceWidth(int) @bci=1, line=439 > (Compiled frame) > - org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.getWidthFromFont(int) > @bci=11, line=324 (Compiled frame) > - > org.apache.pdfbox.rendering.PageDrawer.drawGlyph2D(org.apache.pdfbox.rendering.Glyph2D, > org.apache.pdfbox.pdmodel.font.PDFont, int, org.apache.pdfbox.util.Vector, > java.awt.geom.AffineTransform) > @bci=39, line=350 (Compiled frame) > - > org.apache.pdfbox.rendering.PageDrawer.showFontGlyph(org.apache.pdfbox.util.Matrix, > org.apache.pdfbox.pdmodel.font.PDFont, int, java.lang.String, > org.apache.pdfbox.util.Vector) @bci=34, line=32 > 5 (Compiled frame) > - > org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph(org.apache.pdfbox.util.Matrix, > org.apache.pdfbox.pdmodel.font.PDFont, int, java.lang.String, > org.apache.pdfbox.util.Vector) @bci=32, li > ne=728 (Compiled frame) > - org.apache.pdfbox.contentstream.PDFStreamEngine.showText(byte[]) @bci=240, > line=685 (Compiled frame) > - org.apache.pdfbox.contentstream.PDFStreamEngine.showTextString(byte[]) > @bci=2, line=553 (Compiled frame) > - > org.apache.pdfbox.contentstream.operator.text.ShowText.process(org.apache.pdfbox.contentstream.operator.Operator, > java.util.List) @bci=45, line=50 (Compiled frame) > - > org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(org.apache.pdfbox.contentstream.operator.Operator, > java.util.List) @bci=35, line=799 (Compiled frame) > - > org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(org.apache.pdfbox.contentstream.PDContentStream) > @bci=69, line=461 (Compiled frame) > - > org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(org.apache.pdfbox.contentstream.PDContentStream) > @bci=63, line=438 (Compiled frame) > - > org.apache.pdfbox.contentstream.PDFStreamEngine.showForm(org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject) > @bci=19, line=178 (Interpreted frame) > - > org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(org.apache.pdfbox.contentstream.operator.Operator, > java.util.List) @bci=162, line=70 (Interpreted frame) > - > org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(org.apache.pdfbox.contentstream.operator.Operator, > java.util.List) @bci=35, line=799 (Compiled frame) > - > org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(org.apache.pdfbox.contentstream.PDContentStream) > @bci=69, line=461 (Compiled frame) > - > org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(org.apache.pdfbox.contentstream.PDContentStream) > @bci=63, line=438 (Compiled frame) > - > org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(org.apache.pdfbox.pdmodel.PDPage) > @bci=19, line=149 (Interpreted frame) > - org.apache.pdfbox.rendering.PageDrawer.drawPage(java.awt.Graphics, > org.apache.pdfbox.pdmodel.common.PDRectangle) @bci=93, line=180 (Interpreted > frame) > - > org.apache.pdfbox.rendering.PDFRenderer.renderPage(org.apache.pdfbox.pdmodel.PDPage, > java.awt.Graphics2D, int, int, float, float) @bci=160, line=208 (Interpreted > frame) > - org.apache.pdfbox.rendering.PDFRenderer.renderImage(int, float, > org.apache.pdfbox.rendering.ImageType) @bci=166, line=139 (Interpreted frame) > - org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(int, float, > org.apache.pdfbox.rendering.ImageType) @bci=7, line=94 (Interpreted frame) > [...] > {code} > These methods are synchronized. (I think because of initialization block.) > When I change from: > {code:title=actual|borderStyle=solid} > public synchronized HorizontalHeaderTable getHorizontalHeader() throws > IOException { > HorizontalHeaderTable horizontalHeader = > (HorizontalHeaderTable)tables.get( HorizontalHeaderTable.TAG ); > if (horizontalHeader != null && !horizontalHeader.getInitialized()) { > readTable(horizontalHeader); > } > return horizontalHeader; > } > {code} > to: > {code:title=patch|borderStyle=solid} > public HorizontalHeaderTable getHorizontalHeader() throws IOException { > HorizontalHeaderTable horizontalHeader = (HorizontalHeaderTable) > tables.get(HorizontalHeaderTable.TAG); > if (horizontalHeader != null && !horizontalHeader.getInitialized()) { > synchronized (this) { > if (!horizontalHeader.getInitialized()) { > readTable(horizontalHeader); > } > } > } > return horizontalHeader; > } > {code} > the lock disappears. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org