We have an app that uses CompletableFuture.supplyAsync() to read/write a PDF asynchronously.
This used to work but our users reported that our app would never end reading the PDF when using Android 13.
Indeed, Spire.PDF for Android V9.10.1 has the following behaviour:
- - For Android 8-12: Everything works either synchronously or asynchronously.
- - For Android 13+: Synchronous works. When doing it asynchronously, some stuff does not work.
Things that I currently know do not work asynchronously in Android 13+ are:
- -Applying the license key. The PDF produced will have the watermark as if no license was provided.
- - Using com.spire.pdf.PdfPageBase.getImagesInfo(). This method never returns, no matter if the page has images or not.
With the attached example project this behaviour can be reproduced.
I further noticed, that asynchronous reading in Android 13 works if the document was first read synchronously.
So, in my example, there is the following code:
- Code: Select all
boolean readSync = false;
boolean readAsync = true;
if(readSync) {
readPdf(createdFile);
}
if(readAsync) {
readPdfAsync(createdFile);
}
This code works on Android 8-12 but not on Android 13.
But if you set readSync to true, then it also works on Android 13!
So, something changed with Android 13 that makes your code no longer work when called asynchronously.
And also, something happens when reading the PDF synchronously the first time, that makes the second (asynchronous) call succeed!
As stated above, I have found two cases where it doesn't work, but there might be more functionality which doesn't work as expected with Android 13+.
So, you should investigate how Spire.PDF behaves with Android 13, especially regarding the CompletableFuture.