Skip to content

Defer JSON preview parsing to avoid main-thread jank #39

@lynnswap

Description

@lynnswap

Summary:

  • WINetworkBodyPreviewData.previewData eagerly parses JSON and builds the full node tree on each access.
  • WINetworkBodyPreviewView reads previewData every render, so multi-MB JSON can block the main thread even when JSON mode isn't selected.

Proposed direction:

  • Cache parsed JSON nodes on WINetworkBody and only parse when JSON mode is selected.
  • Parse off the main actor and publish results back on the main actor.
  • Invalidate the cache when preview/full/base64 state changes.
  • Use a lightweight JSON eligibility check (content-type or leading '{'/'[') to decide whether to show the JSON mode without parsing.

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