Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Giving explicit information on MuPDF errors #376

Open
randomnoise opened this issue Sep 7, 2024 · 1 comment
Open

Giving explicit information on MuPDF errors #376

randomnoise opened this issue Sep 7, 2024 · 1 comment

Comments

@randomnoise
Copy link
Contributor

randomnoise commented Sep 7, 2024

I have an old 32 MB .cbz file that works on stock Kobo reader and on KOReader but doesn't work on Plato. Plato doesn't show preview thumbnail about the book and when I select it, nothing happens.

I've assumed this was a Plato issue because KOReader uses MuPDF on some parts and the .cbz file works on koreader application.

I looked at info.log and archive.log on Plato directory in my Kobo device, there was no information. Logs also didn't show the path of the problematic file.

At some point, I've tried mupdf-x11 and mupdf-gl with the .cbz file on my computer (MuPDF version 1.23.11), MuPDF can't open it. It turns out it is a MuPDF issue. The problem persist on the latest 1.24.9 MuPDF version too. So, upgrading the dependency won't help on this issue.

Giving some information to user or adding a line to info.log about the MuPDF errors would go a long way.

@randomnoise
Copy link
Contributor Author

I wanted to open a new issue about MuPDF errors in more general terms in case further changes are needed, but also I've traced the issue between this specific .cbz file and MuPDF.

I've debugged the problem using the emulator, I can give some pointers. Problem starts here:

let first_location = doc.resolve_location(Location::Exact(0))?;

resolve_location calls pages_count() function that also calls MuPDF's mp_count_pages function. mp_count_pages returns 0 (although .cbz file has a lot of pages), then resolve_location swallows the issue and does not give any information:

fn pages_count(&self) -> usize {
unsafe { mp_count_pages(self.ctx.0, self.doc) as usize }
}
fn resolve_location(&mut self, loc: Location) -> Option<usize> {
if self.pages_count() == 0 {
return None;
}


I wanted to try these methods and Plato with an empty text file. So, I created one with

$ touch empty.txt

and opened empty.txt in the Plato emulator. MuPDF's mp_count_pages function returns 1 and resolve_location continues its business as usual; Plato opens the empty.txt as a book with 1 empty page. Empty text file does not issue for MuPDF and Plato in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant