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

Epub viewer: The page contains the following errors #86

Open
vitaliynester opened this issue May 23, 2023 · 13 comments
Open

Epub viewer: The page contains the following errors #86

vitaliynester opened this issue May 23, 2023 · 13 comments

Comments

@vitaliynester
Copy link

Hello all! When opening some pages in some workbooks, the following error may occur. What to do?

Screenshot_1684850306

@vitaliynester
Copy link
Author

This is only in the version with inappwebview, older versions with webview work correctly

@jmgeffroy
Copy link
Contributor

Hi @vitaliynester, can you provide us with a sample epub? Do you see some logs? This really suggests a malformed Epub... But your comment about the previous version (based on WebView) contradicts this feeling...

@vitaliynester
Copy link
Author

Here is an example epub file. Error occurs from second page

example.epub.zip

@jmgeffroy
Copy link
Contributor

OK, I can reproduce the issue on Android and iOS. On iOS, the Webview appears white, without the red paragraph. The chapter2.xhtml source code looks good, I don't see for now what can cause this issue. Investigating...

@vitaliynester
Copy link
Author

I think the problem is in chapter1.xhtml. When you open it through the editor (VSCode), you can see that block a is highlighted in red. If you open this file in a browser, then the DOM tree looks different. First image - VSCode, second - chrome

image
image

@jmgeffroy
Copy link
Contributor

jmgeffroy commented May 23, 2023

Thank you for the feedback. These differences are just a pretty-print artifact. VS displays a compact form when the element has no child, I think (<a id:"n_1"/>), while Chrome doesn't. In the book source code, it's written in this compact mode, too.
I checked with validators, chapter1.xhtml is theoretically OK. And it shouldn't impact other chapters (each one is opened in a different webview)... For now, I'm perplexed. But I see an error in the logs:


WebViewScreenState.buildWebViewComponent.<ac>:	 WebView[ERROR]: Uncaught ReferenceError: readium is not defined

Digging...

@jmgeffroy
Copy link
Contributor

OK. Clue. I see (by adding ) that we are inserting Readium stuff at the wrong place (see the <<link below:

   <head><<link rel="stylesheet" type="text/css" href="/readium/readium-css/ReadiumCSS-before.css"/>

Weird. Never happened. I have to check the pattern matching in the HtmlInjector code...

@jmgeffroy
Copy link
Contributor

jmgeffroy commented May 23, 2023

More precisely, the wrong generated code is:

      <
      <link rel="stylesheet" type="text/css" href="/readium/readium-css/ReadiumCSS-before.css"/>
      <style>
         audio[controls] {
         width: revert;
         height: revert;
         }
      </style>
      link rel="stylesheet" href="../Styles/book.css" type="text/css" />

Both Readium-specific injected elements are inserted inside the element of the book instead of being inject outside of it!!!

The issue happens somewhere around these lines.

@vitaliynester
Copy link
Author

I wonder why then it does not work with a particular instance, and not in general? How can this be fixed?

@jmgeffroy
Copy link
Contributor

The structure of your HTML seems to defeat our pattern matching. Should be pretty easy to fix, but I need time. I have to switch to other tasks for now, but I'll fix that shortly, probably tomorrow. Sorry for the trouble.

@jmgeffroy
Copy link
Contributor

jmgeffroy commented May 23, 2023

Hi @vitaliynester, I tried a quick fix that seems to work well on your book: on this line, remove the "+ 1", as follows:

    var beginHeadIndex = head.end;

I don't push it for now, I'll wait for your feedback.
I need to have a deep look at this part of the code globally; it definitely requires some love :-)

@vitaliynester
Copy link
Author

This is wonderful! I will try this fix and test it on similar books. Thanks a lot!

@Khaled-ElDeeb
Copy link

I have tried this solution and it fixed all the books that I had an issue with, will be testing it for the upcoming week and tell you my feedback, Thanks !

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

3 participants