Repository navigation
fix: a million-character line cut by the capture edge no longer freezes the tab - #9
Merged
Merged
Conversation
…es the tab
trimToClip read one rect per character of the line, to its end: a raw .js
or .json file shown as one line took minutes in both engines (measured:
over 120 s for 1 MB). For a line that is one bidi fragment the scan now
stops at the first glyph outside the clip after one inside; a bidi line is
still scanned to its end, and a collapsed space (no glyph rect) does not
end the scan. No time budget: one would have thrown away the text a
many-line file still yields after the per-line binary search.
Red before the fix: long-line.spec.ts, 30 s timeout in Firefox and
Chromium for the clipped 1 MB line; the glyph and monotonic operands
each go red when dropped ("word" / "abc" instead of the full run).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
trimToClipincollect.tsreads one glyph rect per character of a line that the capture edge cuts, and read on to the line's end. A raw.jsor.jsonfile shown by the browser is one line of a million characters: measured, the content script took longer than 120 s in both engines — the tab froze. The scan now stops where it cannot find anything more. No time budget: a review measurement showed one would throw away the text layer a many-line 1 MB file still yields after its per-line binary search (main: 13 runs after 8.5 s; with a 5 s budget: 0 runs).Claims
<pre>line in a 400 px clipped container yields its first words in well under a second instead of minutes (trimToClip,monotonicfromline.parts.length === 1)splitIntoLines) is still scanned to its end, so the right-to-left part that re-enters the clip is keptVerification
Tests
tests/layout/long-line.spec.ts— the clipped 1 MB line (first words,stats.ms < 3000), collapsed triple spaces inside the clip, a bidi line whose Hebrew part re-enters the clipmainwithout this change: yes — 30 s test timeout in Firefox and Chromium for the 1 MB line (the same scenario measured at >120 s); dropping theglyphoperand yields"word", dropping themonotonicoperand yields"abc"instead of the full run; thefirst >= 0operand is pinned by the existingclip-partial.htmlfixture (6 specs go red without it)Public contracts
<image>tiles under an invisible text layer — one<text>withtextLengthper run,fill-opacity="0", OCR words in<g id="ocr">, linked runs wrapped in<a href><snapii:capture>keepsschema: 1and every field ofcaptureRecord()insrc/shared/svg/metadata.ts(no field removed, renamed or retyped); the Dublin Core fields stay as they areactiveTab,scripting,downloads,clipboardWrite,storage— nohost_permissions, nocontent_scripts(decision D1, docs/development.md)storage.synckeep their keys, types and meaning (Settingsinsrc/shared/types.ts); a value stored by an older version still loadssnapii@qmmq.dedata_collection_permissionsstaysnone, the saved file reveals nothing new about the userdist/— orNOTICEand the license texts are updated with itSaved-file impact
tests/unit/golden/simple.svgchanged: no. Ten edge inputs (Devanagari, Arabic, RTL with digits,unicode-bidi: plaintext, bidi-override, ligatures, a ZWJ emoji,::first-letter, tabs, negative letter-spacing), each cut left and right, give byte-identical runs in both engines (review measurement)Risk and rollback
Out of scope
splitIntoLineson a many-line 1 MB file (8 s on Chromium) is untouchedAssistance