-
Notifications
You must be signed in to change notification settings - Fork 107
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
Crash when opening a book #489
Comments
You can download the crash reports here. |
We are experiencing the same issue. When building with Xcode 16, some users experience the same crash. Unfortunately(?), the crash is not consistant, for some users it never crashes. I have yet to have any workaround. |
I have new information about this "bug" It seems that the application only crashes in Relaese mode, so when downloaded from TestFlight. Building through xcode doesn't cause the code to crash. Any idea? I tried several combos, I tried using xcode 15.4, xcode 16, I tried using my iPhone 15 Plus and another iPhone x and even an iPhone 7. Maybe the problem is around the optimization level or something? I would be glad to hear any tip. |
Okay, I found the issue. For my defense, I got this project from others and it is an old one :) It looks like the library was updated from 2.2.0 to 2.6.0 at some point without doing the 2.5.0 migratin guide. Although it worked at that time, it looks like now this is causing this crash. I changed the implementation to use the GCDHTTPServer.shared as shown in the guide and the crash seems to go away. |
@grighakobian Was it the same issue as described by @tnorbert above for you? |
@mickael-menu We haven't migrated to 2.5.0 yet; we're currently using version 2.7.3. Everything works fine when building on Xcode 15.4, but we're encountering crashes when building on Xcode 16. |
@grighakobian Could you share your code creating an instance of |
@grighakobian @mickael-menu So, basically, my steps were to update the library to 2.7.3 and resolve every deprecated message. This includes using a new initializer in EPUBNavigatorViewController (and switching to GCDHTTPServer.shared) and reimplementing the user preferences (saving the preferences by our own logic and applying these values directly to the reader). After these steps, all our crashed went away. Although, these changes made us rework some of our epubs as the new reader did not apply several user preferences such as font sizes. It turned out that some epubs needed to be changed. |
@mickael-menu Here is the EPUBNavigatorViewController initialization code. let navigatorViewController = EPUBNavigatorViewController(publication: publication, initialLocation: initialLocation, resourcesServer: publicationServer) Note that we are using the old PublicationServer API. |
Okay that's probably why this is crashing on Xcode 16. Let me know if you still have the issue after migrating the HTTP server. |
@mickael-menu Unfortunately, I started getting these crashes, too. At first, I though I solved this but it looks like I was wrong. Right now, I am getting the exact same crashes as @grighakobian. Any idea on that? The user's download it from TestFlight and when the device is fully offline (airplane mode and wifi off), the app crashes when trying to open an epub. |
No but it's actually crashing in one of our third-party dependencies. Maybe you can take a look on Fuzi's repository to see if something similar was mentioned, and/or open an issue there: https://github.com/cezheng/Fuzi Please let me know if you do so I can track the answers. |
The project looks pretty dead actually. Maybe it's time to look for another XML parser. If someone wants to contribute a solution with an alternative XML parser, you need to implement the following protocol: https://github.com/readium/swift-toolkit/blob/develop/Sources/Shared/Toolkit/XML/XML.swift Here's an example using Fuzi: https://github.com/readium/swift-toolkit/blob/develop/Sources/Shared/Toolkit/XML/Fuzi.swift And there are tests here, you just need to copy and adjust the swift-toolkit/Tests/SharedTests/Toolkit/XML/XMLTests.swift Lines 94 to 107 in f53630f
|
@mickael-menu It looks like somebody opened a new issue here and it is the same fuzi crash as we are experiencing. I think this is going to be a bigger issue now, I don't think that there is an easy solution but I am going to try to solve it somehow, without switching the parser (we kinda need it to be fixed asap as we are using this in production :) ) |
What's your plan to fix it? I guess we can't without fixing the issue in Fuzi. Forking it in Readium is a possibility if you find the solution by modifying Fuzy directly. |
@mickael-menu I wrote a temporary solution in the other ticket but it is only a band aid for production crashes. @grighakobian What was your situation? Did you manage to solve this? |
@tnorbert We fixed the crash by compiling the project on Xcode 15.4. |
Describe the bug
We recently released a new version that included bug fixes for iOS 18. However, after the update, we noticed a significant drop in crash-free users—over 10%. In an attempt to resolve the issue, we downgraded the Readium version to 2.6.0, which previously did not cause any crashes. Unfortunately, this did not resolve the problem. Finally, we tried building the project with Xcode 15.4 instead of Xcode 16.0, and the crash issue was eliminated.
How to reproduce?
Readium version
2.6.0 ... 2.7.3
OS version
Mainly iOS 17 and 18
Testing device
Any Device
Environment
Additional context
Crashed: com.apple.root.default-qos
0 libsystem_platform.dylib 0x2a54 platform_memmove + 52
1 libxml2.2.dylib 0x18638 + 216
2 libxml2.2.dylib 0x6a58 xmlParserInputBufferCreateMem + 92
3 libxml2.2.dylib 0x67d4 xmlCreateMemoryParserCtxt + 72
4 libxml2.2.dylib 0x6610 xmlReadMemory + 60
5 0x101c55c XMLDocument.__allocating_init(string:encoding:) + 130 (Document.swift:130)
6 0x1171cb4 FuziXMLDocument.init(string:namespaces:) + 14 (Fuzi.swift:14)
7 0x1161dc8 MediaTypeSnifferContext.contentAsXML.getter + 74 (MediaTypeSnifferContext.swift:74)
8 0x115d170 specialized static MediaType.sniffHTML(context:) + 115 (MediaTypeSniffer.swift:115)
9 0x115b028 implicit closure #1 in variable initialization expression of static MediaType.sniffers + 32
10 0x115c704 specialized static MediaType.of(content:mediaTypes:fileExtensions:sniffers:) + 804 (Archive.swift:804)
11 0x115ca88 specialized static MediaType.of(:mediaTypes:fileExtensions:sniffers:) + 280 (MediaTypeSnifferContent.swift:280)
12 0x115a6e8 static MediaType.of(:mediaTypes:fileExtensions:sniffers:) + 28 (:28)
13 0x11c1a84 PublicationServer.resourceHandler(:) + 341 (PublicationServer.swift:341)
14 0xd81ddc thunk for @escaping @callee_guaranteed (@guaranteed GCDWebServerRequest) -> (@owned GCDWebServerResponse?) + 48 (:48)
15 0x122b680 __82-[GCDWebServer(Handlers) addHandlerForMethod:pathRegex:requestClass:processBlock:]_block_invoke + 923 (GCDWebServer.m:923)
16 0x122f704 -[GCDWebServerConnection(Subclassing) processRequest:completion:] + 762 (GCDWebServerConnection.m:762)
17 0x122cb94 -[GCDWebServerConnection _startProcessingRequest] + 152 (GCDWebServerConnection.m:152)
18 0x122d960 __45-[GCDWebServerConnection _readRequestHeaders]_block_invoke + 346 (GCDWebServerConnection.m:346)
19 0x122e2c8 __64-[GCDWebServerConnection(Read) readHeaders:withCompletionBlock:]_block_invoke + 461 (GCDWebServerConnection.m:461)
20 0x122e044 __68-[GCDWebServerConnection(Read) readData:withLength:completionBlock:]_block_invoke + 432 (GCDWebServerConnection.m:432)
21 libdispatch.dylib 0x31234 + 60
22 libdispatch.dylib 0x213c + 32
23 libdispatch.dylib 0x3dd4 + 20
24 libdispatch.dylib 0x15a6c + 864
25 libdispatch.dylib 0x1609c + 156
26 libsystem_pthread.dylib 0x48f8 _pthread_wqthread + 228
27 libsystem_pthread.dylib 0x10cc start_wqthread + 8
The text was updated successfully, but these errors were encountered: