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
Problem
The
HttpMarketplaceRepositoryandGitHubReleasesClientcurrently decode potentially large JSON responses (like marketplace trending extensions and release metadata) synchronously on the main UI isolate usingjsonDecode(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
Impact
Isolate.runhandles the background spawn and return securely.lib/core/market/http_marketplace_repository.dartlib/core/updater/github_releases_client.dart