Skip to content

Reduce size of ObjectEditor #267

Description

@LeftofZen

TL;DR: from AI investigation, the large size of the binaries is from the included .NET runtime for the --self-contained build option. An easy win would be to produce a second set of build artefacts without this flag applied and the user can decide which version they want.

Why the compiled GUI binaries are ~100 MB

The size is dominated by a few things, in order of impact:

  1. Bundled .NET runtime (largest cost, ~55–70 MB). build.sh publishes with --self-contained --PublishSingleFile, so every binary packs the entire .NET 10 runtime. The GUI is even forced to be self-contained: it references GuiUpdater as a self-contained executable (confirmed — a framework-dependent publish fails with NETSDK1151). That's why the tiny ObjectEditorUpdater is still 82 MB.

  2. EF Core / ASP.NET / SQLite dead weight pulled in via Definitions (~10–20 MB). The GUI talks to the ObjectService purely over HTTP (ObjectServiceClient uses HttpClient — see Gui/ObjectServiceClient.cs). But because the GUI references the Definitions project, it transitively inherits Microsoft.EntityFrameworkCore + .Relational + .Sqlite, System.Linq.Expressions (3.6 MB), System.Data.Common, e_sqlite3.dll, ASP.NET Authorization/Identity, migrations, etc. The JIT can't strip them from the bundle. None of it is used at runtime by the GUI.

  3. Avalonia + SkiaSharp backend (~15 MB .NET parts + native libSkiaSharp.dll 11 MB, av_libglesv2.dll 5.4 MB, HarfBuzz, etc.), plus Material.Icons.dll (5.7 MB embedded font), SixLabors.ImageSharp, NAudio.

  4. ~100 MB of debug symbols (.pdb) in the published/archived outputlibSkiaSharp.pdb (84 MB) and libHarfBuzzSharp.pdb (21 MB) ship as package content and were being zipped into the release.

Measured sizes (win-x64): ObjectEditor.exe 108.7 MiB, ObjectEditorUpdater.exe 78 MiB, publish folder 307.8 MB, of which 100.7 MB is .pdb.

What I changed (verified with real builds)

Gui/Gui.csproj — gated the Avalonia DiagnosticsSupport dev-tool package to Debug only (the existing comment already said this was intended). Verified: Release ObjectEditor.exe dropped 108.7 → 107.3 MiB, and AvaloniaUI.DiagnosticsSupport.Avalonia.dll no longer ships.

build.sh — added a step that deletes *.pdb from all three publish folders before archiving. Verified the Windows publish folder has 100.7 MB of .pdb; removing them cuts the distributed folder from ~307.8 MB → ~207 MB, and the release zip/TAR shrinks correspondingly.

What I tested and rejected (so I didn't add noise)

  • -p:StripSymbols=true for Linux/macOS: measured zero effect (identical 108.5 MB binary), so I left it out.
  • Dropping self-contained / framework-dependent build: not possible without product changes (NETSDK1151) and would require users to install .NET 10.

Recommendations (higher-risk; not applied)

  • Split the database/server-only deps out of Definitions (e.g., a Definitions.Database module for the EF Core models/migrations). The GUI only needs the DTOs/ObjectModels, so removing EFC/SQLite/ASP.NET from its dependency closure could save ~10–20 MB per binary. This is the biggest remaining reducible win, but it's a moderate-to-large refactor shared with the server side, so it needs the module's test coverage to validate.
  • If end-user UX allows it, shipping framework-dependent would save ~55–70 MB per binary (at the cost of requiring a .NET 10 install).
  • Avoid Avalonia --enable-trimming; Avalonia doesn't recommend it for correctness.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions