Skip to content

Reduce Android startup critical path work #91

Description

@danielchalmers

Summary

Focus this issue on the measured startup critical path that keeps Android users on the native splash / Blazor Getting things ready... screen. The latest debug launch logs show that the biggest known delay is database preparation and seeding work performed before the MAUI app is built, not the home page render or font loading.

This issue should stay measurement-led: optimize the work we can see in launch timings, re-measure, then decide whether broader Blazor rendering or app responsiveness work deserves separate follow-up issues.

Current evidence

From the Android debug launch captured after the lightweight logging work:

  • PrepareDatabase took 1042ms.
    • CheckPendingMigrations took 911ms even though pending migrations: False.
  • SeedCategories took 443ms.
    • added: 0, existing: 14, save changes calls: 14.
  • SeedDebugDays took 1140ms in DEBUG.
    • requested: 1833, existing: 1793, 40 new days, 360 points.
  • Created MAUI app logged at 3610ms.
  • Home initialization was much smaller by comparison.
    • Home initialized in 113ms.
    • Loaded day took 111ms.
  • Android Choreographer skipped-frame and Davey! duration=1157ms lines are real responsiveness symptoms, but they line up with startup work plus WebView/Blazor/debug loading.
  • The log was a Debug/FastDev/debugger run, so it is useful for finding app-level work but is not a Release cold-start baseline.

Primary work

  • Add lightweight startup and home-load logging using the existing Microsoft.Extensions.Logging setup. Add targeted startup logging #93
  • Capture a true Release Android cold-start baseline on device.
    • Normal launch with an existing database.
    • First launch after clean install.
    • First launch after an app/schema upgrade.
  • Avoid paying GetPendingMigrations().Any() on every normal launch.
    • Consider an app/schema version gate, migration marker, or equivalent cheap check before invoking EF migration discovery.
  • Batch or gate category seeding.
    • Avoid one query/save cycle per default category.
    • Make an unchanged database do near-zero seed work.
  • Make Debug day seeding opt-in or empty-database-only.
    • It should not dominate normal Debug startup or obscure Release behavior.
  • Re-measure with the same logging after each startup-path change.

Secondary work after startup is remeasured

Only pursue these if the updated measurements show they are still material:

  • Move any remaining database preparation or seed work off the CreateMauiApp() critical path.
  • Optimize GetOrCreateDayAndAddPoints() if home load becomes a significant startup contributor.
  • Review EF lazy loading and Razor query enumeration in hot render paths.
  • Remove synchronous save calls from navigation/window lifecycle paths where they affect interaction latency.
  • Make calendar and trends load/render incrementally if those screens show measurable latency.

Not pursuing as a startup fix right now

  • Google Fonts removal as a standalone Android startup optimization.
  • Debug/FastDev assembly-load warnings.
  • libpenguin.so, Chromium DNS, Bluetooth/media, and similar WebView/platform warnings unless they appear in Release traces with measurable impact.
  • Broad Blazor rendering cleanup before the startup database work has been addressed and remeasured.

Measurement notes

Track separate timings for:

  • process start to MAUI app built
  • database context creation
  • migration check / migration application
  • category seeding
  • Debug sample-data seeding
  • Blazor WebView first document load
  • home page initialization and first render
  • first interaction latency after load

Compare Debug vs Release, clean install vs existing database, and first launch after upgrade vs normal launch.

References reviewed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions