readium / kotlin-toolkit

A toolkit for ebooks, audiobooks and comics written in Kotlin
https://readium.org/kotlin-toolkit
BSD 3-Clause "New" or "Revised" License
180 stars 77 forks source link

Publication Restricted Readium Error #301

Closed llemeurfr closed 7 months ago

llemeurfr commented 1 year ago

In brief: a valid LCP license, used with the proper passphrase, is ok on some Android devices, but ko on others.

Details (from a kotlin toolkit + LCP integrator): We have some customers who on opening an ebook, on various Android OS ranging from v6 to v11, receive a Publication restricted flag set as true which leads to org.readium.r2.lcp_r2.LcpException$Unknown. This prevents the individual customer from ever opening the ebook successfully whilst allowing other customers to always open the same ebook without an issue. When we review the customer license file no restriction is found and the license opens the ebook correctly. We have validated our code for the passphrase being used for acquiring License. The passphrase is neither missing or wrong as the same passphrase works for the same book on Android 11 but doesn’t works on Android 7. So, the issue is inconsistent and it behaves differently on different devices and OS.

How to reproduce the issue: We can replicate this issue in emulators but have not been able to determine the root cause.

mickael-menu commented 1 year ago

I can't reproduce this issue on an Android 7 (API 24) emulator. What are the logs tagged with LicenseValidation and LicensesService?

publication.isRestricted == true just means that the LCP license could not be unlocked. It can be for many reasons, but receiving LcpException.Unknown is weird. If you can reproduce in an emulator, try adding breakpoints here:

And check the source underlying exception (you can also get it from the cause property of the LcpException.Unknown instance).

pratyushITC commented 1 year ago

Hi @mickael-menu,

I tried using the breakpoints on the above Classes you mentioned. Please check the result below.

org.readium.lcp.sdk.DRMException with errorcode 500 at LcpClient.kt Line 104 (else -> LcpException.Unknown(e))

org.readium.r2.lcp_r2.LcpException$Unknown at LcpException.kt Line 176 (is LcpException -> e)

Line 177 was not triggered for else -> Unknown(e) in LcpException .

The cause property of LcpException.Unknown instance is giving org.readium.lcp.sdk.DRMException

llemeurfr commented 1 year ago

Hi Pratyush,

Dileep said "We can replicate this issue in emulators". Can you be more specific ? Please answer to the following questions. You cannot expect useful help without providing information that helps reproducing the issue.

1/ You've got several white labelled apps: is it an issue with every app of only a specific one? 2/ Is it reproductibe with the Android TestApp + the test LCP lib? if yes, this is an issue with the Readium dev, if not, it feels like an issue with your own app. In this case please check the difference between your code and the TestApp code. If not answer the following questions. 3/ If we want to reproduce the issue on the TestApp, which Android version should we use, not use? 4/ If we use Android 7, are we sure to get the issue with ANY license we generate? 5/ Or is it a combination of Android version + device?

pratyushITC commented 1 year ago

Hi Laurent,

Please find answers to the question you asked.

1/ You've got several white labelled apps: is it an issue with every app of only a specific one? We are getting this issue in all the apps

2/ Is it reproductibe with the Android TestApp + the test LCP lib? if yes, this is an issue with the Readium dev, if not, it feels like an issue with your own app. In this case please check the difference between your code and the TestApp code. If not answer the following questions. Yes, We are getting Unknown LCP error when using the Android TestApp + the test LCP lib

3/ If we want to reproduce the issue on the TestApp, which Android version should we use, not use? Try with these Pixel XL Android 6 (API 23) & Pixel XL Android 7.1 (API 25), don't go for Android 9 and above

4/ If we use Android 7, are we sure to get the issue with ANY license we generate? No, the issue is not there with each and every license. This will come for some licences randomly.

5/ Or is it a combination of Android version + device? Yes, I have encountered these issue on Pixel XL Android 6 (API 23) & Pixel XL Android 7.1 (API 25) emulators

mickael-menu commented 1 year ago

No, the issue is not there with each and every license. This will come for some licences randomly.

Does it happen systematically with some licenses? Could you share one of the faulty licenses that can be opened with the test LCP lib (not a production license) and its passphrase?

org.readium.lcp.sdk.DRMException with errorcode 500 at LcpClient.kt Line 104 (else -> LcpException.Unknown(e))

This is an error sent by the private liblcp, I don't know what the error code 500 means. (Any idea @danielweck @aferditamuriqi?)

danielweck commented 1 year ago

500 is "unknown" error, I am afraid :(

llemeurfr commented 1 year ago

@pratyushITC, please have a look at Mickaël's question, we are still in the dark for the reproduction of this issue.

We will have to release a version of the test liblcp with additional logs for getting more information about what happens deep in the lib.

discoverdileep commented 1 year ago

@llemeurfr I had provided all details to Mickael over slack. He did look into this but he was unable to replicate the issue on the Aldiko app. Though regarding the error which he have posted he did suggest that the exception is a low level error in the liblcp and for which he is not having the source code.

llemeurfr commented 1 year ago

@discoverdileep, since then we decided to add some logs to the low-level code, but still miss precise direction on how to reproduce the issue. We just know that the problem arises on some devices with old versions of Android (<= 8); we don't know if this is a random error or not. More info welcome on how you reproduce the issue.

discoverdileep commented 1 year ago

Thank you Laurent. Will see if we can provide some precise information to you which will help you in reproducing the issue.

llemeurfr commented 1 year ago

Hello, are there any news on that issue?

mickael-menu commented 7 months ago

Feel free to chime in if it's still an issue.