shlomif / PySolFC

A comprehensive, feature-rich, open source, and portable, collection of Solitaire games.
http://pysolfc.sourceforge.net/
GNU General Public License v3.0
445 stars 97 forks source link

Reducing Android package size #344

Closed joeraz closed 7 months ago

joeraz commented 8 months ago

@lufebe16, we've previously had discussions about concerns with the Android package size.

Outside of adding games, one of my main goals so far has been supporting more modern, higher-resolution graphics, while leaving users the ability to go back to the old style if they choose. Of course, options means more images, which means a larger package. And I've also been getting quite a few image contributions lately. So I'm trying to come up with a solution to reduce the package size, while not limiting user contributions.

First, there are a number of files in the data directory that don't look like they're being used in the Kivy version, and can probably be safely removed from the package (though this should be tested first):

Those are little things, but they add up. Now there are a couple bigger things, but might need a bit more review/work:

Currently, I do have one additional type of cardset I'm working on right now, and two more have been requested (but probably won't be added anytime soon). We also received some image contributions in issue #342, which could lead to an option to select "Pause" and "Demo" text styles. I'd rather these didn't become a problem for the Android package.

Sorry for the huge wall of text. Just let me know your thoughts, and I am willing to help out if needed.

lufebe16 commented 8 months ago

Thanks for the detailed suggestions. To say the actual apk size is not a problem. Its comparable with the actual size of firefox and chrome browser.

So there is no need to change something or to introduce complicated storage save features. My wish is only, if adding new big images (e.g. for 4K screens), they should be placed into a new folder. So they can be filtered off in the android/apk build process.

Here are my results of unpacking the current apk: (gif images have been excluded in this version. This saved about 1M)

Apk-size is ~86M (zipped) contains mainly:

libs: 44M (binaries of python, sdl and others, 32 and 64 bit versions) assets: 56M (zipped) contains mainly:

pysollib: 11M (the compiled python code of Pysol) data: 69M contains:

biggest entries in data: 16M: tiles where: 15M: save-asspect (big jpg-images) 8.9M: cardset-neo-tarock 6.7M: html 6.3M: images 4.9M: cardset-neo 4.4M: cardset-neo-hex 2.5M: data/images/cards/finder

With cardsets there is still the problem that newest Versions on Sourceforge do not match to the actual developer versions. Well for the time beeing I can fetch the PySolFC-Cardsets repo directly and then filter out, what is needed. Download size the is ~190M, out of it used about 40M.

joeraz commented 8 months ago

Okay, for the tiles, I've added subfolders separating the 4K table tiles from the normal HD and SD tiles. I was given one more 4K image, so currently, the tiles folder is 24MB, but if you remove the 4K subfolder, it goes down to about 4MB. So if you just filter out the "save-aspect-4k" and "stretch-4k" subfolders, I think that should give you what you need. I know "stretch-4k" doesn't currently exist, but it may get added at some point, depending on what other table tiles are donated, so it's probably best to account for it now.

For cardsets, the higher res cardsets aren't really intended for 4K. For them, it's more that the older cardsets look dated, and could turn users off, whereas the higher res cardsets look great when scaled to pretty much any screen size.

lufebe16 commented 8 months ago

Thanks. This will help to select or adapt these type of images, when building the apk if needed.

joeraz commented 7 months ago

No problem.

Please close this ticket when you're done with it.

shlomif commented 7 months ago

Using .webp and similar formats in the packaging (instead of JPEG or PNG) might help too: https://en.wikipedia.org/wiki/WebP .

lufebe16 commented 7 months ago

There are currently AFAIK no tablets nor smartphones in the world that have a 4k display (and also no human eyes that could benefit of it). I decided to reduce them all to 2k before building the apk.