0

I'm packaging an application I have written into an AppImage so that it can be delivered to Linux users.

One of the key features of the GUI toolkit I'm using is that it is small and lightweight, allowing me to compile a build which is statically linked to the GUI library of around 6Mb.

However, after building the AppImage - where I do what the instructions say - use all the functionality (which basically includes only using file browser dialogues to load files) - it generates an absolutely enormous AppImage of around 200Mb!

I know that AppImages are supposed to be a "little bit" big, but this is completely mad as a proposed solution for portability when the natively compiled binary including a statically linked GUI toolkit is only 6Mb.

However, I'm not convinced at all that I need all of that 200Mb. A very similar piece of software to mine, but that additionally uses Qt (which is pretty bloated in comparison) is only about 30Mb. I actually suspect that appimage-builder is doing something very wrong - I think it is listing the files in the directory I explore when using the file browser dialogue as dependencies (they are big files). I have no real other explanation. But if so how do I stop it doing that?

Why is mine so big? What can I do about it?

For the record I am using this method for building my AppImage

  1. Building my binary separately
  2. Running appimage-builder --generate and completing the form
  3. Running appimage-builder --recipe AppImageBuilder.yml --skip-tests

Edit: Removing the obviously not needed files that were being packaged have reduced the size of the appimage to just 140Mb, but this is still almost 5 times bigger than equivalent appimages I've seen. Are there some tricks/options I'm not aware of?

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
user3353819
  • 911
  • 2
  • 8
  • 21
  • Have you considered looking at the files in the appimage and seeing which ones contribute to the size? – that other guy Sep 24 '21 at 17:44
  • Ok, so I had a look by mounting it. It certainly is including a bunch of non-dependency files like I thought but they amounted to about 20Mb, not 200Mb. The issue is that the process makes *so many* subdirectories its quite hard to see where all the heft is coming from – user3353819 Sep 24 '21 at 18:00
  • It's also unclear to me what the procedure is. The AppDir file is even bigger than 200Mb so not eveything in there is included. The manifest looks quite modest. Its really weird. For sure it shouldn't be including files that just happen to be in the background though. – user3353819 Sep 24 '21 at 18:03
  • You can use `du | sort -n` to see the largest directories by size, or `ncdu` to interactively explore them – that other guy Sep 24 '21 at 18:50
  • Ok, I've done that. There is nothing bigger than around 3Mb individually. There's just a lot of them, and I guess the issue is I'm not sure which ones are essential, which ones aren't and how I would specify what to include in the manifest which built it (which is relatively simple). Or can I build the image from the AppDir directly, not from the manifest? – user3353819 Sep 25 '21 at 02:59

1 Answers1

1

In few recent days got started with AppImage and faced the same problem.

Shortly: check dependencies of your app by any possible ways and configure recipe to include only concrete dependencies and avoid includings of any theme/icon/etc packages which are not realy used :)

My case is a small app, written in Dart (with Flutter). The built project itself weights about 22MB (du -sh . in output directory). My host os is Linux Mint (Cinnamon).

First time I run appimage-builder --generate it generated me the "recipe" with 17 packages to be installed and bunch of libraries to be copied from /lib/x86_64-linux-gnu/. When I generated AppImage from this recipe, result was about 105MB, which are extremely large in my opinion for small app.

My first experiments was to cleanup included files section, as I guess "all necessary" libraries should be installed from apt. I referred to a few configs from network where were marked only few libraries for include and was exclude section, which contains some DE related files (themes, fonts, icons and etc.)

Using that I got result about 50MB (which are still large enough).

Next experiments were referred to from this issue - https://github.com/AppImageCrafters/appimage-builder/issues/130#issuecomment-843288012 Shortly - after generating an AppImage file, there appeared file .bundle.yml file inside AppDir folder, which contains deployed libraries. Advice is to try exclude something from that. May be it's a good enough advice, but it takes too long time to check for each package/library if it breaks resulted AppImage file at least with official tests of appimage-builder (docker containers). I faced more broken results than any sane size reduction.

My next experiment was to reduce dependencies which should be installed from package manager and use files from host system. I deleted AppDir and appimage-builder-cache folders and regenerated the recipe. At next step I commented all packages which should be installed from package manager and leaved only included files. Result was fail, because of needing one package, but after adding it I got AppImage result in 36MB. That sounds much better than starting 105MB or even previous result of 50MB.

Here I got small "boost" - Flutter project built into AOT binaries, without runtime. So I checked output of ldd for my app, and then mapped list of required libraries to list of library files which were detected by appimage-builder. Finally some of them was correct, some not found in ldd output and some was in ldd output, but were not detected by appimage-builder. I added all undetected, removed all unused. My final result is 26MB and it passed all appimage-builder tests (running in docker images of fedora, cent, debian, ubuntu and arch)

I understand that it's bad enough for continuous building, because it will require to always check for used libraries and adapt config if something changed, but for rare enough builds I guess it's has some kind of balance between good and bad.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    that's my example - https://github.com/NEK-RA/flutter_material_palette/blob/main/AppImageBuilder.yml I didn't deleted unused files and packages, but just commented them with explanations – Ryoidenshi Aokigahara Nov 12 '21 at 18:53