Closed Bug 1909171 Opened 2 years ago Closed 1 year ago

Copy-paste of text from local text editor to a Codepen demo appears to spend 10s around CSS parsing and memory usage grows to 3GB. Copy-paste from the browser is instant.

Categories

(Core :: DOM: Editor, defect)

defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: mayankleoboy1, Unassigned)

References

()

Details

Attachments

(3 files)

  1. Download the attached sample text file to yoir local machine. Open the sample text file in your local editor.
  2. Open attached testcase (original demo at https://codepen.io/dark_mefody/pen/PoLdPoY)
    1.1 Delete all the text in the demo area of the testcase
  3. Copy-paste the sample text from the local editor into the demo area of the testcase
  4. Now open the sample text in the browser and copy-paste its contents into the demo area of the testcase

AR:
Copy-paste from local file: profile with single style thread: https://share.firefox.dev/3zSoh5O (10s)
Copy-paste from firefox: https://share.firefox.dev/4fahuEL (instant)

Chrome is instant in both cases

Attached file Sample CSS text.css —
See Also: → 1892514
Summary: Copy-paste of text from local text editor to a Codepen demo appears to spend 10s around CSS parsing and memory usage grows to 3GB → Copy-paste of text from local text editor to a Codepen demo appears to spend 10s around CSS parsing and memory usage grows to 3GB. Copy-paste from the browser is instant.
Attachment #9414068 - Attachment description: memory-report.json.gz → memory-report.json.gz . Look at PID=1928

Ok, simpler STR:

On attachment 9414069 [details], select all (Ctrl+A) and copy (Ctrl+C).

On attachment 9414067 [details], paste without formatting (Ctrl+Shift+V).

The test-case is effectively a <style contenteditable spellcheck="false">. It seems the editor, instead of a single plain text node, will create a bunch of <br> elements, which means thousands of nodes. Every time a node is appended we need to re-parse the stylesheet.

Masayuki, it seems the editor could notify of all nodes at once? That'd make this fast. This one is a very extreme case but it's likely it matters for smaller subtrees too...

Component: CSS Parsing and Computation → DOM: Editor
Flags: needinfo?(masayuki)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #4)

The test-case is effectively a <style contenteditable spellcheck="false">. It seems the editor, instead of a single plain text node, will create a bunch of <br> elements, which means thousands of nodes.

Right.

Every time a node is appended we need to re-parse the stylesheet.

Masayuki, it seems the editor could notify of all nodes at once? That'd make this fast. This one is a very extreme case but it's likely it matters for smaller subtrees too...

mozAutoDocUpdate is what you think the editor should put before touching the DOM?

Flags: needinfo?(masayuki) → needinfo?(emilio)

Well, it might fix the issue in first edit, but not so for undo and redo unfortunately... It might be possible to make a new transaction for making a set of document update API calls, though.

Not necessarily just that (even tho that would help), but maybe even something along the lines of bug 1882417.

Flags: needinfo?(emilio)

(Marking S3 for now because the test case seems rather obscure. Feel free to change)

Severity: -- → S3

Thank you.

I think that including for saving foot print, there should be new transaction to insert multiple line text. Then, the transaction should do everything to touch the DOM with suppressing the notification. Then, undo/redo can also prevent the notifications too. And if we do that in same order, we can make the undo faster than now.

See Also: → 1912069
See Also: → 1913253

Pasting normally: https://share.firefox.dev/44HEtUq
Pasting without formatting: https://share.firefox.dev/4lIwMUb

This is pretty much instantanous now. Calling it WFM.

Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: