Ben created FOP-3313:
------------------------

             Summary: Multi-threaded FOP usage breaks FontLoader
                 Key: FOP-3313
                 URL: https://issues.apache.org/jira/browse/FOP-3313
             Project: FOP
          Issue Type: Bug
          Components: unqualified
    Affects Versions: 2.4
            Reporter: Ben


I'm trying to convert our usage of Apache FOP from a single-threaded 
implementation to a multi-threaded one.

We have a process that generates PDF documents for every item in a large 
dataset, and this is creating a performance bottleneck: each item takes about 
200ms to generate using FOP in out single-threaded implementation.

The wrapper class by which we use FOP, FopConfiguration, declares a 
{{FopFactory}} field. I've now converted it to a {{{}private 
ThreadLocal<FopFactory> factory{}}}.

I have a font directory that the FOP factory needs to load custom fonts from. 
This directory is initialised once, and then passed to the code that 
instantiates the ThreadLocal.

I would expect switching to ThreadLocal for the FopFactory would be sufficient, 
but what I'm instead seeing is that when {{agent.newFop}} is called, it's 
causing {{org.apache.fop.fonts.FontLoader#read}} to be called within that 
thread.

There seems to be some resource contention within that method, because in 
contrast to the single-threaded wrapper, the multi-threaded wrapper is failing 
at {{OpenFont.readCMAP}} with the following error:

Unsupported TrueType font: No Unicode or Symbol cmap table not present. Aborting

So it seems like the FOP agent is lazy-loading some fonts, and doing so isn't 
thread-safe?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to