Status of issue PDFNEWNET-39309

What is the status of issue PDFNEWNET-39309? In our environment, we are seeing symptoms similar to those mentioned in the following topics:

We periodically see multiple threads stuck at the same method in the PngDevice internals. See the following JVM thread dump:

"activiti-app-rest-Executor-2" #88 prio=5 os_prio=0 tid=0x00007fdb6e1ea000 nid=0xb17 runnable [0x00007fdb106c8000]
   java.lang.Thread.State: RUNNABLE
	at com.aspose.pdf.internal.p558.z2.containsKey(Unknown Source)
	at com.aspose.pdf.internal.p14.z4.m1(Unknown Source)
	at com.aspose.pdf.internal.p32.z20.m1(Unknown Source)
	at com.aspose.pdf.internal.p32.z7.m1(Unknown Source)
	at com.aspose.pdf.internal.p32.z7.m1(Unknown Source)
	at com.aspose.pdf.internal.p32.z7.m2(Unknown Source)
	at com.aspose.pdf.internal.p45.z1.m1(Unknown Source)
	at com.aspose.pdf.internal.p32.z20.m2(Unknown Source)
	at com.aspose.pdf.internal.p32.z20.m4(Unknown Source)
	at com.aspose.pdf.internal.p32.z7.m2(Unknown Source)
	at com.aspose.pdf.internal.p32.z7.m1(Unknown Source)
	at com.aspose.pdf.devices.z1.m1(Unknown Source)
	- locked <0x00000007641c54d8> (a com.aspose.pdf.Document)
	at com.aspose.pdf.devices.z1.m1(Unknown Source)
	at com.aspose.pdf.devices.ImageDevice.m1(Unknown Source)
	at com.aspose.pdf.devices.PngDevice.processInternal(Unknown Source)
	at com.aspose.pdf.facades.PdfConverter.getNextImage(Unknown Source)
	at com.aspose.pdf.facades.PdfConverter.getNextImage(Unknown Source)
	at com.activiti.content.transform.aspose.impl.PdfTransformationHandler.transform(PdfTransformationHandler.java:76)
	at com.activiti.content.transform.aspose.impl.AsposeTransformationServiceImpl.transformContent(AsposeTransformationServiceImpl.java:66)
	at com.activiti.service.runtime.ContentRenditionProcessor.processRendition(ContentRenditionProcessor.java:97)
	at com.activiti.service.runtime.ContentRenditionProcessor.renderContentAndCleanTemporaryFile(ContentRenditionProcessor.java:64)
	at com.activiti.service.runtime.ContentRenditionProcessor$$FastClassBySpringCGLIB$$a46f2f86.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.interceptor.AsyncExecutionInterceptor$1.call(AsyncExecutionInterceptor.java:110)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

@lakeward70,

The ticket ID PDFNET-39309 (old: PDFNEWNET-39309) is not resolved yet. However, we recommend you please share all details of the scenario, including source PDF and code. We will investigate your scenario in our environment and share our findings with you.

@imran.rafique,

Thanks for the response.

The below JVM thread dumps are from the production environment taken <10 minutes apart. CPU usage was at 100% for more than 10 hours. We ended up having to restart tomcat in order to clear the thread pool for other processing. If you search on activiti-app-rest-Executor-1 and activiti-app-rest-Executor-2, you will see two threads that are both stuck at at com.aspose.pdf.internal.p558.z2.containsKey(Unknown Source).

jvm-thread-dump-1-post-patch.pdf (134.6 KB)
jvm-thread-dump-2-post-patch.pdf (132.2 KB)

It was not clear which PDFs triggered the issue, so I reprocessed the PDFs uploaded to the system around this period. I was unable to reproduce the issue in the development environment. The 35 PDFs ranged from 38 KB to 20 MB. I cannot include the PDFs here because of export restrictions.

The transformation is triggered in the below method. The threads are managed by Spring and are configured to processes a single file per thread. The symptoms seemed similar to Multithreading issue PNGDevice with both implementations executing com.aspose.pdf.devices.PngDevice.processInternal()

   public TransformationResult transform(TransformationMimeType sourceType, InputStream source, TransformationMimeType targetType) throws TransformationException {

        TemporaryFile tempFile = null;
        try {

            setLicense();

            tempFile = new TemporaryFile();

            if(targetType == TransformationMimeType.PDF) {
                SaveOptions saveOptions = new PdfSaveOptions();
                Document doc = new Document(source);
                doc.save(tempFile.getOutputStream(), saveOptions);
            } else {
                Document doc = new Document(source);

                // Get an image for the first page of the PDF
                PdfConverter converter = new PdfConverter(doc);
                if(!converter.hasNextImage()) {
                    throw new TransformationException("Cannot create thumbnail for PDF without any pages");
                }

                converter.getNextImage(tempFile.getOutputStream(), ImageType.getPng());
                converter.close();
            }


            // Return InputStream exposed by temporary file, which is removed when stream is closed
            TransformationResult result = new TransformationResult();
            result.setInputStream(tempFile.getInputStream());
            result.setLength(tempFile.getLength());
            return result;

        } catch (Exception e) {
            // When an exception occurs during transformation, no need to keep the temp file
            if(tempFile != null) {
                tempFile.closeAndRemove();
            }
            throw new TransformationException("Error while converting " + sourceType.getMimeType() + " to PDF", e);
        }
    }

@lakeward70,

We require your source PDF documents to replicate these errors in our environment, once the errors are replicated, and then we could investigate and fix the root cause. Please also share the complete code like how you are calling transform method.