[ 
https://issues.apache.org/jira/browse/PDFBOX-3071?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14982069#comment-14982069
 ] 

John Hewson edited comment on PDFBOX-3071 at 10/30/15 7:47 AM:
---------------------------------------------------------------

It's official still true. But we've been trying to move towards thread safe 
rendering as an afterthought when working on other rendering code - so stuff 
should kind of work, but YMMV. PDFRenderers are actually just there because we 
moved the AWT code out of PDDocument, nothing to do with thread safety.

Indeed FontBox's fonts are required to be thread safe now to facilitate static 
caching of fonts in PDFBox. The cache itself is also required to be thread 
safe, for the same reason. Beyond that PDFBox doesn't make any guarantees but 
as I say, you should probably be ok. We're doing multithreaded rendering in 
PDFDebugger and it's pretty stable.

{quote}
Is it safe to assume that I can render different documents at the same time?
{quote}

Yes. Though if you're hitting issues with the static font cache then that could 
be affected too (I don't think you are) - and we'd want to fix it ASAP.


was (Author: jahewson):
It's official still true. But we've been trying to move towards thread safe 
rendering as an afterthought when working on other rendering code - so stuff 
should kind of work, but YMMV. PDFRenderers are actually just there because we 
moved the AWT code out of PDDocument, nothing to do with thread safety.

Indeed FontBox's fonts are required to be thread safe now to facilitate static 
caching of fonts in PDFBox. The cache itself is also required to be thread 
safe, for the same reason. Beyond that PDFBox doesn't make any guarantees but 
as I say, you should probably be ok. We're doing multithreaded rendering in 
PDFDebugger and it's pretty stable.

{quote}
Is it safe to assume that I can render different documents at the same time?
{quote}

Yes. Though if you're hitting issues with the static font cache then that could 
be affected to (I don't think you are) - and we'd want to fix it ASAP.

> Possible thread safety issue RE: Can't read the embedded Type1C font 
> ILCMJJ+TimesNewRomanPSMT
> ---------------------------------------------------------------------------------------------
>
>                 Key: PDFBOX-3071
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3071
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 2.0.0
>         Environment: JDK 1.7.0_79 on RHEL7 x86_64
>            Reporter: Stan R
>         Attachments: PDFBOX-3071.pdf
>
>
> Further testing reveals that this specific error crops up randomly, and 
> sometimes simultaneously, while rendering multiple pages from the same 
> document concurrently. Possibly a thread safety issue with Fontbox?
> The rendering happens inside a batch of Callable's running inside a 32-thread 
> Executor. The code snippet from inside the body of the Callable.call() is 
> really trivial:
> ...
> PDFRenderer renderer = new PDFRenderer(document); // referring to the same 
> document object
> BufferedImage image = renderer.renderImage(pageIdx); // exception thrown from 
> here
> ...
> ===== ORIGINAL ISSUE REPORT FOLLOWS ====
> Got an exception when rendering page 2 of the file.
> The file shows up fine in evince and pdfjs;  it appears to be the same font 
> as everywhere else in the file (but I haven't looked inside the PDF).
> The exception is listed below:
> WARN   [11:19:10.057] [pool-3-thread-3] o.a.p.f.FlateFilter -  FlateFilter: 
> premature end of stream due to a DataFormatException 
> ERROR  [11:19:10.073] [pool-3-thread-3] o.a.p.p.f.PDType1CFont -  Can't read 
> the embedded Type1C font ILCMJJ+TimesNewRomanPSMT 
> java.io.IOException: illegal offset value 8238 in CFF font
>       at org.apache.fontbox.cff.CFFParser.readIndexData(CFFParser.java:158) 
> ~[fontbox-2.0.0-20151027.193416-1850.jar:2.0.0-SNAPSHOT]
>       at org.apache.fontbox.cff.CFFParser.parseFont(CFFParser.java:393) 
> ~[fontbox-2.0.0-20151027.193416-1850.jar:2.0.0-SNAPSHOT]
>       at org.apache.fontbox.cff.CFFParser.parse(CFFParser.java:115) 
> ~[fontbox-2.0.0-20151027.193416-1850.jar:2.0.0-SNAPSHOT]
>       at 
> org.apache.pdfbox.pdmodel.font.PDType1CFont.<init>(PDType1CFont.java:101) 
> ~[pdfbox-2.0.0-20151027.193546-1797.jar:2.0.0-SNAPSHOT]
>       at 
> org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(PDFontFactory.java:60)
>  [pdfbox-2.0.0-20151027.193546-1797.jar:2.0.0-SNAPSHOT]
>       at org.apache.pdfbox.pdmodel.PDResources.getFont(PDResources.java:123) 
> [pdfbox-2.0.0-20151027.193546-1797.jar:2.0.0-SNAPSHOT]
>       at 
> org.apache.pdfbox.contentstream.operator.text.SetFontAndSize.process(SetFontAndSize.java:60)
>  [pdfbox-2.0.0-20151027.193546-1797.jar:2.0.0-SNAPSHOT]
>       at 
> org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:811)
>  [pdfbox-2.0.0-20151027.193546-1797.jar:2.0.0-SNAPSHOT]
>       at 
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:468)
>  [pdfbox-2.0.0-20151027.193546-1797.jar:2.0.0-SNAPSHOT]
>       at 
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:442)
>  [pdfbox-2.0.0-20151027.193546-1797.jar:2.0.0-SNAPSHOT]
>       at 
> org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:149)
>  [pdfbox-2.0.0-20151027.193546-1797.jar:2.0.0-SNAPSHOT]
>       at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:179) 
> [pdfbox-2.0.0-20151027.193546-1797.jar:2.0.0-SNAPSHOT]
>       at 
> org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:208) 
> [pdfbox-2.0.0-20151027.193546-1797.jar:2.0.0-SNAPSHOT]
>       at 
> org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:139) 
> [pdfbox-2.0.0-20151027.193546-1797.jar:2.0.0-SNAPSHOT]
>       at 
> org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:68) 
> [pdfbox-2.0.0-20151027.193546-1797.jar:2.0.0-SNAPSHOT]
>       at 
> org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:55) 
> [pdfbox-2.0.0-20151027.193546-1797.jar:2.0.0-SNAPSHOT]
>       at 
> com.example.core.pdf.AsyncPDFRenderer$RenderPDFPageTask.call(AsyncPDFRenderer.java:109)
>  [classes/:na]
>       at 
> com.example.core.pdf.AsyncPDFRenderer$RenderPDFPageTask.call(AsyncPDFRenderer.java:90)
>  [classes/:na]
>       at java.util.concurrent.FutureTask.run(FutureTask.java:262) 
> [na:1.7.0_79]
>       at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>  [na:1.7.0_79]
>       at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>  [na:1.7.0_79]
>       at java.lang.Thread.run(Thread.java:745) [na:1.7.0_79]
> WARN   [11:19:10.350] [pool-3-thread-3] o.a.p.p.f.FileSystemFontProvider -  
> New fonts found, font cache will be re-built 
> WARN   [11:19:10.350] [pool-3-thread-3] o.a.p.p.f.FileSystemFontProvider -  
> Building font cache, this may take a while
> ...



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to