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

APK is markedly larger #88

Closed
snelltheta opened this issue Apr 19, 2015 · 8 comments
Closed

APK is markedly larger #88

snelltheta opened this issue Apr 19, 2015 · 8 comments

Comments

@snelltheta
Copy link

Was this the result of the font pack being included? Storage isn't cheap.

@tuxor1337
Copy link

No, the font pack has not been included into the main package.

The increase in size is due to the new MuPdf build process. If you inspect the apk, the *.so libraries alone account for the biggest part of the package. The MuPdf build process has been copied from the MuPdf for Android app, hence the *.so files in their APKs are just as big. But they split the APK according to the supported architectures, so that they don't have four different *.so in one APK (for armeabi, armeabi-v7a, mips, x86).

I confirm your bug report, since an increase from 9.7 MB (v2.5) up to 23.7 MB (v2.7) is surely remarkable. But I actually don't know how to cope with it. Of course, the easiest solution seems to be having separate packages for the different arches (like we temporarily had with v2.6). But I don't know how to do this.

Probably also this might help: https://blog.algolia.com/android-ndk-how-to-reduce-libs-size/

@KrasnayaPloshchad
Copy link
Contributor

Well, when I access the MuPDF website, I got source tarball from their download link, then I found several large font files inside. I think these files may cause the problem, maybe some of them can be split from their source code and move to DV Font Pack.

@tuxor1337
Copy link

No, the APK does not contain any part of the MuPdf source tarball - especially no fonts or other resources. Instead, the increase is entirely due to a larger *.so file. You can simply check this yourself by comparing the file size of v2.6 (6.7 MB, containing only armeabi-v7a) and v2.6.1 (22.7 MB, containing armeabi, armeabi-v7a, mips, x86, but same code base apart from that).

@consp1racy
Copy link

Had the very same issue. Fortunately splitting .apk is fairly easy lately. Se here:
http://stackoverflow.com/questions/28940743/ndk-support-in-androidstudio-and-choosing-between-android-studio-and-eclipse/28943840#28943840

EDIT: You wrote you already build the .sos yourself. Try adding

LOCAL_CFLAGS += -DNOCJK

in Core.mk to exclude fonts from the .so (that's right). Just went from 9266 kB to 2155 kB for armeabi-v7a unpacked (may be even less when you put it to .apk).

@tuxor1337
Copy link

@consp1racy Thank you very much!

The NOCJK flag bring's the size of our shared objects down to roughly the size it used to have at the time of v2.5. I will release this and wait for complaints from Asian users ;-)

It seems to me like it's more elegant switching to splitted .apk files once we upgrade compileSdkVersion to at least 21 (cf. #92).

@consp1racy
Copy link

No problem at all!

You can always make another flavor specifically for Asian market, which will have native libraries with CJK fonts. Where are the days of a single .apk ... :D

@lawrence615
Copy link

Hello everyone, Sorry for asking this question even after the thread has been dormant for some time. I am also facing the problem of size with the lib and even after adding LOCAL_CFLAGS += -DNOCJK it is still quite big. May be am adding that line at the wrong point of Core.mk...I just wanted to ask where in Core.mk should I add that line and at what point of building mupdf from source.

@ericwa
Copy link
Contributor

ericwa commented Jan 9, 2016

@lawrence615 hey, here's the Core.mk for document-viewer: https://github.com/SufficientlySecure/document-viewer/blob/master/document-viewer/jni/mupdf/Core.mk

Also keep in mind that even with no CJK fonts, there are still about 800KB of fonts that need to be embedded in mupdf (the PDF core fonts).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants