readium / swift-toolkit

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

[Bug] ReadiumNavigation Unexpectedly found nil while implicitly unwrapping an Optional value paginationView in EPUBNavigatorViewModel #488

Open TechWilk opened 3 weeks ago

TechWilk commented 3 weeks ago

Describe the bug

Upon working to upgrade to 3.0.0-alpha.2 for testing or integration I have started to receive the following error when opening a publication.

Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value

image

How to reproduce?

I feel like I haven't initialised something correctly, but as far as I'm aware I have correctly followed the steps from the migration guide.

Readium version

3.0.0-alpha.2

OS version

iOS 16.7.10 and iOS

Testing device

iPhone X (physical device) and iPhone 15 (simulator)

Environment

macOS: 14.3.1
platform: arm64
carthage: 0.40.0
Xcode 15.4
Build version 15F31d

Additional context

In order to continue my testing, if I check the variable first I can get the ebook to load, but this doesn't feel like this is fixing the root cause.

case .loadedResources:
  await withTaskGroup(of: Void.self) { tasks in
    if (paginationView != nil) {
      for (_, view) in paginationView.loadedViews {
          tasks.addTask {
              await (view as? EPUBSpreadView)?.evaluateScript(script)
          }
      }
    }
  }
mickael-menu commented 17 hours ago

Thanks for reporting this issue, I'll try to tackle it next week.