Snap size increase over 100MB

Hi All,
thanks to some kind help from members of this forum, I managed to get my first Snap published last year, and have done a few re-releases, the last being in December 2020, the snap weighing in at 289MB.

My latest version weighs in at a whopping 394MB!
I had some problems with “content clashes” between two key elements of my snap

Failed to stage: Parts 'desktop-gtk3' and 'photonotebook' have the following files, but with different contents:
    usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-ani.so
    usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-bmp.so
    usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-gif.so
    usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-icns.so
    usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-ico.so
    usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-jpeg.so
    usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-png.so
    usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-pnm.so
    usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-qtif.so
    usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-svg.so
    usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-tga.so
    usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-tiff.so
    usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-xbm.so
    usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-xpm.so
    usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders
    usr/lib/x86_64-linux-gnu/libasound.so.2.0.0
    usr/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0.4000.0
    usr/lib/x86_64-linux-gnu/libgdk_pixbuf_xlib-2.0.so.0.4000.0
    usr/lib/x86_64-linux-gnu/libtiff.so.5.5.0
    usr/share/doc/libasound2/changelog.Debian.gz
    usr/share/doc/libavahi-common-data/changelog.Debian.gz
    usr/share/doc/libgdk-pixbuf2.0-0/changelog.Debian.gz
    usr/share/doc/libtiff5/changelog.Debian.gz
    usr/share/doc/libx11-data/changelog.Debian.gz

Snapcraft offers some capabilities to solve this by use of the following keywords:
    - `filesets`
    - `stage`
    - `snap`
    - `organize`

To learn more about these part keywords, run `snapcraft help plugins`.

I solved this problem by cleaning the desktop-gtk3 snap and re-running the build process, which delivered a valid snap . However my snap size has gone up by 50%!

I suspect this size increase may be due to some duplication of GTK3 libraries or some similar problem, or a change in the GTK3 support system, but I do not have the knowledge of libraries to make a judgement. The App has not increased significantly in size or in range of functionality.

The App is built on JAVAFX 11.0.2 built in a IntelliJ IDEA toolset, JLINK-ed to produce a completely self-contained JAVA environment, and it has been running successfully in the wild for about a year from the store.

My snapcraft.yaml file is unchanged, and is below.

I would be very grateful if someone could help wityh a solution to this issue.
Many thanks in advance.

Alan

name: photonotebook
title: PhotoNoteBook
version: "1.4.2"
summary: A digital photography library manager and notebook 
license: Proprietary
description: PhotoNoteBook is a digital photograph library manager enabling collections of images and the making of notes and memo's for the collections and the photographs. 
icon: photonotebook.png 

confinement: strict
grade: stable
base: core20 

# this line enables LZO compression for the snap and speed up first start time - hopefully!
compression: lzo
 
apps:
  photonotebook:
    command: bin/photonotebook
    command-chain: [bin/desktop-launch]
    
    plugs: [home, unity7,  opengl, network, removable-media, optical-drive ,desktop, desktop-legacy, gsettings, x11, wayland]
     
parts:
  photonotebook:
    plugin: dump
    source: ./photonotebook/
    stage-packages: [libgif7, libx11-6, libxext6, libxi6, libxrender1, libxtst6, libasound2, libjpeg8, liblcms2-2, libfreetype6, libpng16-16, libcanberra-gtk-module]

  desktop-gtk3:
    source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
    source-type: git
    source-subdir: gtk
    plugin: make
    make-parameters: ["FLAVOR=gtk3"]
    build-packages:
      - libgtk-3-dev
    stage-packages:
      - libxkbcommon0  # XKB_CONFIG_ROOT
      - ttf-ubuntu-font-family
      - dmz-cursor-theme
      - light-themes
      - adwaita-icon-theme
      - gnome-themes-standard
      - shared-mime-info
      - libgtk-3-0
      - libgdk-pixbuf2.0-0
      - libglib2.0-bin
      - libgtk-3-bin
      - unity-gtk3-module
      - libappindicator3-1
      - locales-all
      - xdg-user-dirs
      - ibus-gtk3
      - libibus-1.0-5
      - fontconfig-config # start of my additions
      - fonts-liberation
      - ttf-dejavu-core
      - hicolor-icon-theme
      - libgtk2.0-0
      - libcanberra-gtk-module
      - libcanberra-gtk0
      - libcanberra0 

well, you are shipping half a desktop in your stage-packages … re-work it to use one of the gnome extensions instead …

you just add extensions: [ gnome-3.34 ] to your snap like:

make sure to add a cleanup part to the end of your snapcraft.yaml to remove any duplicated files like:

1 Like

Hi Ogra,

yeah, thats what I used in an early form of my snap, (extensions: [gnome-3-34]) but I found that it didn’t work when I went from core18 to core20, so I was advised by a forum member to go with the snapcraft.yaml as I have posted here.

Is gnome-3-34 now proven with Core20?

The snapcraft.yaml has not changed between the two version, but we have the massive increase.
I’ll check out cleanup options, but the initial question regarding why the increase has happened remains.

any further advice greatly valued!

cheers
Alan

ah, no, you might still need to use a core18 base, but is there any problem with that ?

regarding the size, switching to lzo compression grows the snap typically by a third … (but massively decreases startup time)

Hi, having a go with gnome-3-38 … lets see if the experinmental version works …

As for core18 - I thought we were supposed to work with the latest? :joy:

I’ll let you know how it goes!

well … core18 is still supported until 2023, there is no hurry to upgrade to 20 if 18 works …

Just snapped the App with this version of snapcraft.yaml

name: photonotebook
title: PhotoNoteBook
version: "1.4.2"
summary: A digital photography library manager and notebook 
license: Proprietary
description: PhotoNoteBook is a digital photograph library manager enabling collections of images and the making of notes and memo's for the collections and the photographs. 
icon: photonotebook.png 

confinement: strict
grade: stable
base: core20 

# this line enables LZO compression for the snap and speed up first start time - hopefully!
compression: lzo
 
apps:
  photonotebook:
    command: bin/photonotebook
    extensions:
      - gnome-3-38
    
    plugs: [home, unity7,  opengl, network, removable-media, optical-drive ,desktop, desktop-legacy, gsettings, x11, wayland]
     
parts:
  photonotebook:
    plugin: dump
    source: ./photonotebook/
    stage-packages: [libgif7, libx11-6, libxext6, libxi6, libxrender1, libxtst6, libasound2, libjpeg8, liblcms2-2, libfreetype6, libpng16-16, libcanberra-gtk-module]

… and has reduced back to the size it was … however, does it still work!

… I seem to remember that Core20 solved a JAVAFX issue … I need to check back on my notes!
Cheers
Alan

… just for completion, the “new” snap started and seems to be functional.
Time for some serious testing, and examination on how to properly clean up!

thanks again
Alan

2 Likes

Most of these are included in the gnome extension snap so you don’t need to stage them in your snap as well. At the very least, I suspect you can drop libx11-6, libxext6, libxi6, libxrender1, libxtst6, libjpeg8, libfreetype6, libpng16-16, and libcanberra-gtk-module. The only one I’m fairly sure you need to retain is libasound2. I would need to double check to confirm the need or not of staging liblcms2-2 and libgif7.

Although are you sure your app needs libasound2 to function? It looks like you’re not plugging the alsa interface nor are you plugging audio-playback to be able to pipe alsa sound through pulseaudio.

Hi diddledani,
yep, that worked a treat! taken 30MB out of the snap image!
Many thanks
Alan

1 Like