readium / swift-toolkit

A toolkit for ebooks, audiobooks and comics written in Swift
https://readium.org/mobile/
BSD 3-Clause "New" or "Revised" License
225 stars 96 forks source link

Error when trying to open EPUB with Fixed Layout [iOS] #337

Closed evgenTraytyak closed 9 months ago

evgenTraytyak commented 9 months ago

Bug Report

Repository with demo project in React Native to reproduce: https://github.com/evgenTraytyak/readium_app_issue

What happened?

When I'm trying to open EPUB with Fixed Layout I'm getting the error: Screenshot 2023-09-19 at 11 37 45

Expected behavior

EPUB file with Fixed Layout should opens correctly

How to reproduce?

  1. Setup and run project from repo (triggerHub_dev target)
  2. On home screen you will see two buttons (with predefined book objects): Normal and Fixed book Simulator Screenshot - iPhone 15 - 2023-09-19 at 11 32 33
  3. If you click on Normal book button you will see a working Readium viewer Simulator Screenshot - iPhone 15 - 2023-09-19 at 11 55 28
  4. If you click on Fixed button you will see loader and error in Xcode logs Simulator Screenshot - iPhone 15 - 2023-09-19 at 11 33 24

Screenshot 2023-09-19 at 11 37 45

Looks like error happens here in EPUBFixedSpreadView.swift: https://github.com/readium/swift-toolkit/blob/main/Sources/Navigator/EPUB/EPUBFixedSpreadView.swift#L98

Environment

Readium version: 2.5.1

Development environment

macOS: 14 platform: arm64 cocoapods: 1.12.1 Xcode 15.0

Testing device

mickael-menu commented 9 months ago

Unfortunately React Native is not officially supported by Readium, and I will not install a React Native environment to debug the problem. You will need to debug this integration issue yourself.

I would use a Web Inspector to debug what's loaded in the web views. Make sure that fxl-spread-two.html or fxl-spread-one.html are properly loaded, as well as readium-fixed-wrapper-one.js or readium-fixed-wrapper-two.js.

Mary-Fernandez commented 9 months ago

Our app is having this issue with children's books, as they have fixed layout showing 2 pages at a time. Is the issue the "Fixed Layout" or showing 2 pages at a time?

In other words, would a "Fixed Layout" with only 1 page work fine?

mickael-menu commented 9 months ago

Both should work. Are you able to reproduce the problem in the Readium Test App? Could you share a sample book exhibiting the issue?

Mary-Fernandez commented 9 months ago

Hi. I don't have the Readium Test App, I have our app, (BiblioApp), which runs Readium. Here's an ebook as an example. 9781789562538.epub.zip As you can see, it has a "Fixed Layout" and shows 2 pages at once, and Readium cannot open it.

mickael-menu commented 9 months ago

It loads quite slowly but this book renders fine on the Readium Test App (2.6.0). I'll investigate the slowness when I have more time, but I'm not sure this is related to the issue you have in your app.

Simulator Screenshot - iPad Pro (12 9-inch) (6th generation) - 2023-09-27 at 17 07 28

Mary-Fernandez commented 9 months ago

Thank you for testing this. I should have specified that the book opens fine on Android, but not at all on iOS. It seems "fixed layout" epub files do not open on Readium on iOS, even when you create them on "Single Page" layout. This epub file is "Single Page" "Fixed Layout", and it does not open either. Stories of the Night Sky.zip

mickael-menu commented 4 months ago

It looks like there's an issue with the legacy HTTP server preventing the FXL scripts from being loaded.

You can solve this by migrating to the new HTTP server: https://github.com/readium/swift-toolkit/blob/develop/Documentation/Migration%20Guide.md#migrating-the-http-server then, the Preferences API : https://github.com/readium/swift-toolkit/blob/develop/Documentation/Migration%20Guide.md#upgrading-to-the-new-preferences-api