sony / flutter-elinux

Flutter tools for embedded Linux (eLinux)
BSD 3-Clause "New" or "Revised" License
428 stars 43 forks source link

icudtl.dat size #145

Closed psstoyanov closed 1 year ago

psstoyanov commented 1 year ago

Hi, I'm looking at a few of the commands and how elinux is extending the default Flutter ones. --analyze-size caught my eye.

Understandably, it doesn't work with flutter-elinux however this is interesting: icudtl.dat with flutter-elinux has a size of 10MB:

➜  data git:(main) ✗ ls -lh
total 10M
drwxr-xr-x 1 pak0stpc pak0stpc 140 Nov  3 12:36 flutter_assets
-rw-r--r-- 1 pak0stpc pak0stpc 10M Nov  3 12:36 icudtl.dat

Comparing this with the generic GTK wrapper:

➜  ecommerce_app git:(main) ✗ flutter build linux --analyze-size
Running "flutter pub get" in ecommerce_app...                    1,473ms

💪 Building with sound null safety 💪
Building Linux application...                                           
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  bundle                                                                   62 MB
  bundle/
    ecommerce_app                                                          28 KB
    data/
      icudtl.dat                                                          796 KB

Why would there be such a drastic difference in the size between the two files?

HidenoriMatsubayashi commented 1 year ago

Thanks. Both issues need to be investigated.

HidenoriMatsubayashi commented 1 year ago

Understandably, it doesn't work with flutter-elinux however this is interesting:

Fixed.

psstoyanov commented 1 year ago

Understandably, it doesn't work with flutter-elinux however this is interesting:

Fixed.

Absolutely amazing!

I will try to look at the method you've used for --analyze-size and see if it can give me ideas on how to pass flutter-embedded-linux variables to build and run command.

psstoyanov commented 1 year ago

With the fix to --analyze-size it's now easier to see a patter:

$ flutter-elinux build elinux --analyze-size
...
...
Building an eLinux application with wayland backend in release mode for x64 target...         19.4s
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  bundle                                                                   28 MB
  bundle/
    test_analyze                                                          113 KB
    data/
      icudtl.dat                                                           10 MB
      flutter_assets                                                      362 KB
    lib/
      libflutter_engine.so                                                 14 MB
      libflutter_elinux_wayland.so                                        896 KB
      libapp.so (Dart AOT)                                                  3 MB
      Dart AOT symbols accounted decompressed size                          3 MB

vs the GTK Linux build:

$ flutter-elinux build linux --analyze-size
...
...
Building Linux application...                                           
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  bundle                                                                   20 MB
  bundle/
    test_analyze                                                           28 KB
    data/
      icudtl.dat                                                          796 KB
      flutter_assets                                                        2 MB
    lib/
      libflutter_linux_gtk.so                                              14 MB
      libapp.so (Dart AOT)                                                  3 MB
      Dart AOT symbols accounted decompressed size                          3 MB

icudtl.dat is larger with flutter-elinx while the assets are smaller.

As a note, the above 2 readings were gather with the default project: flutter-elinux create <project_name>

HidenoriMatsubayashi commented 1 year ago

icudtl.dat is one of the flutter engine build artifacts. The engine build options may have an effect. Current build options: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-Engine-from-source

psstoyanov commented 1 year ago

I'm waiting for a build to complete with: https://github.com/flutter/engine/blob/main/ci/builders/linux_host_engine.json#L184

Not sure if that's comparable but it seemed like a good idea to start with whatever the main CI builder uses and then drone to the next option.

psstoyanov commented 1 year ago

Hmm.... I don't get it - I always get 10MB for icudtl.dat in the resulting local build regardless of architecture or options for any Linux output.

How is it that the officially released GTK build has a footprint of just a few KB :confused:

psstoyanov commented 1 year ago

Update: I believe this is the source of information relevant to the above observations: https://flutter-review.googlesource.com/c/recipes/+/9740

Ohhh... the GTK wrapper doesn't need to bundle fontconfig as it's already part of the GTK deps - https://github.com/flutter/engine/pull/23663#issuecomment-759848028

Anecdotal comparison with fontconfig package on my x64 tower (Plasma) being roughly 1100 KiB in size, appears to be in the right ball-park in terms of size.

I'm not sure if the above would have anything to do with a potential Wayland session for flutter-elinux but it might have something to do with the fonts not being rendered in debug mode.

I don't believe there is something else that may be discovered by this ticket, @HidenoriMatsubayashi . Closing it down.

HidenoriMatsubayashi commented 1 year ago

Thanks, @psstoyanov