Skip to content

Perf: Offload heavy JSON decoding to Isolate #538

Description

@ZhuchkaTriplesix

Problem

The HttpMarketplaceRepository and GitHubReleasesClient currently decode potentially large JSON responses (like marketplace trending extensions and release metadata) synchronously on the main UI isolate using jsonDecode(response.body).

In Dart, parsing large JSON strings is a CPU-intensive operation. Doing this on the main isolate blocks the event loop, causing UI stutter (jank) and skipped frames, which degrades the perceived performance of the app.

Proposed Solution

Wrap these JSON decoding operations in Isolate.run(() => jsonDecode(body)) to offload the parsing work to a background worker isolate.

Trade-offs

  • Pros: Prevents UI freezes and dropped frames, resulting in a buttery-smooth scrolling and navigation experience even during background network tasks.
  • Cons: Spawning an isolate has a small overhead (typically a few milliseconds). For very tiny JSON payloads, the overhead might exceed the parsing time, but for API responses (like extensions and releases), the benefit heavily outweighs the cost.

Impact

  • Risk: Low. Dart's Isolate.run handles the background spawn and return securely.
  • Affected Files:
    • lib/core/market/http_marketplace_repository.dart
    • lib/core/updater/github_releases_client.dart

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