readium / readium-sdk

A C++ ePub renderer SDK
BSD 3-Clause "New" or "Revised" License
387 stars 164 forks source link

Memory leaks and slow content rendering in Android #135

Open SebDubuis opened 9 years ago

SebDubuis commented 9 years ago

We are dealing with a very heavy reflowable EPUB 3 file that features long chapter and high amount of images for each chapter. Some chapters account more than 300 images. When rendering the file in our Reader (Android Readium SDK), the content is hanging and sometime it's not even possible to open the chapter. We suspect the amount of images more than the length of the chapter to be causing this issue. An extract of the file has been shared with Ric.

danielweck commented 9 years ago

Thank you @SebDubuis Ric privately shared the EPUB with me (I am a Readium developer), and I can see that iBooks on OSX takes a really long time to open the chapter (which does not bode well for mobile devices!). The Readium iOS and OSX launcher apps also struggle with the content load.

rkwright commented 9 years ago

Right. And I took a quick look at the contents. In the two chapters there are almost 700 images. And they seem to have been down-sampled appropriately, i.e. they are not print-ready images that got repurposed (which I have seen too often). But in this case, the EPUB is well-formed, it's just immense.

rkwright commented 9 years ago

Worth taking a look at this issue as well. Massive leaks on Windows and there is a very detailed dump showing what is leaking and where. The leaks all appear to be in the Core, which is pretty worrisome.

https://github.com/readium/SDKLauncher-Windows/issues/15

danielweck commented 9 years ago

I do not think that the memory leaks are caused by ReadiumSDK core per-say, but that they are instead a byproduct of badly-configured libxml hooks (as per my technical description in https://github.com/readium/SDKLauncher-Windows/issues/15 ). To be investigated further...the iOS and OSX launcher apps seem fine, but we definitely need to profile / trace the memory (de)allocations in the Android launcher app.

danielweck commented 9 years ago

@SebDubuis by the way, the EPUB3 contains XHTML5 files that use the .html extension instead of .xhtml. Because of how web browsers work, and if you need to use XML namespaces in your documents (e.g. epub:type attribute, CSS styling with namespace selectors), it is recommended to use the correct file extension.

rkwright commented 9 years ago

Not much we can do here in the short term, but keeping it alive as a test case.