Skip to content

perf(inspector): detect, format and minify large JSON/XML cells on a worker isolate - #1688

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
perf/inspector-large-text-off-ui-thread
Oct 17, 2026
Merged

ZhuchkaTriplesix merged 1 commit into
devfrom
perf/inspector-large-text-off-ui-thread

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

From a review of the component library.

In the cell inspector, jsonDecode (and the XML validator/formatter) ran on the UI thread: once when the dialog opened to decide whether to show the Format/Minify buttons (after #1680, once per text, but on every edit), and again inside the Format JSON / Minify / Format XML handlers. On a multi-megabyte cell that is whole frames. The size and the freeze (the review said 100-400 ms for 5-10 MB) are not measured here.

Change (grid_cell_popover_inspector.dart)

  • Text of at least 256 KB (inspectorIsolateThreshold, UTF-16 units) is checked and rewritten with compute. Below it, nothing changes: the work is still synchronous, so the buttons and the result appear in the same frame as before.
  • Detection: until the worker answers, a large JSON/XML-looking text shows no Format buttons; they appear when it does. One check runs at a time, and if the text was edited meanwhile the newest text is checked next.
  • Format JSON / Minify / Format XML: the buttons show a spinner and are disabled while the worker runs. If the user edits the text in the meantime, the edit wins and the result is dropped. Invalid text is still left as it is.
  • Plain large text (not {..}, [..] or <..>) never starts a worker.

Tests (the threshold is lowered to 64 characters): large JSON gets its button after the worker answers, formats, and Apply returns the pretty text; plain large text gets no JSON/XML buttons. The existing small-JSON test is unchanged and covers the synchronous path.

@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit 26abaa2 into dev Oct 17, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant