I can replicate this issue by hitting "reply" to a message in a local folder, with lots of broken-up quotes, like so: ``` ... > a quoted line ..blank... > another quoted line ... etc etc... ``` The slowdown occurs when the message I'm replying to is being inserted into the HTML editor DOM, using `HTMLEditor::InsertAsCitedQuotation()`. It quickly creates a documentFragment with the HTML elements it wants to insert, then loops through, adding them into the DOM. It's inserting elements into the DOM which seems to be slow. My test message takes 10 mins or so. The test email I'm using is a pretty awful one, but it's a form you'd often find out in the wild - a long thread with lots of top-posting, and all the quoted lines interleaved with blank lines somewhere along the way by some . It comes out as about 80000 HTML elements (Mostly `<pre>` and `<blockquote>` elements I think). There's a similar story with plain-text composition - it still generates HTML elements in a similar way for each bit of quoted content, so it's not just a matter of inserting one big element. You still end up with a comparable number of elements to insert. You can see the elements being added with the log - `MOZ_LOG="EditorTransaction:5"` Now. 80000 DOM nodes is a good number... but it still seems *awfully* slow to me. From what I can tell it's spending the bulk of it's time in [InsertNodeTransaction::DoTransaction()](https://searchfox.org/mozilla-central/source/editor/libeditor/InsertNodeTransaction.cpp#84), which spends all it's time inside Selection::CollapseInLimiter(), which ends up dividing the time between [nsINode::SetBoolFlag()](https://searchfox.org/mozilla-central/source/dom/base/nsINode.h#1728) and [nsINode::ClearBoolFlag()](https://searchfox.org/mozilla-central/source/dom/base/nsINode.h#1728). So, my guess is something selection-related slowing it down. I thought it might be registered Selection listeners causing trouble, but that doesn't seem to be the case (I commented out the notification call and it was still slow). I'm out of ideas for now. Magnus: this would benefit from having some input from someone who knows about HTMLEditor - any thoughts who?
Bug 289644 Comment 30 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
I can replicate this issue by hitting "reply" to a message in a local folder. The message contains lots of broken-up quotes, like so: ``` ... > a quoted line ..blank... > another quoted line ... etc etc... ``` The slowdown occurs when the message I'm replying to is being inserted into the HTML editor DOM, using `HTMLEditor::InsertAsCitedQuotation()`. It quickly creates a documentFragment with the HTML elements it wants to insert, then loops through, adding them into the DOM. It's inserting elements into the DOM which seems to be slow. My test message takes 10 mins or so. The test email I'm using is a pretty awful one, but it's a form you'd often find out in the wild - a long thread with lots of top-posting, and all the quoted lines interleaved with blank lines somewhere along the way by some . It comes out as about 80000 HTML elements (Mostly `<pre>` and `<blockquote>` elements I think). There's a similar story with plain-text composition - it still generates HTML elements in a similar way for each bit of quoted content, so it's not just a matter of inserting one big element. You still end up with a comparable number of elements to insert. You can see the elements being added with the log - `MOZ_LOG="EditorTransaction:5"` Now. 80000 DOM nodes is a good number... but it still seems *awfully* slow to me. From what I can tell it's spending the bulk of it's time in [InsertNodeTransaction::DoTransaction()](https://searchfox.org/mozilla-central/source/editor/libeditor/InsertNodeTransaction.cpp#84), which spends all it's time inside Selection::CollapseInLimiter(), which ends up dividing the time between [nsINode::SetBoolFlag()](https://searchfox.org/mozilla-central/source/dom/base/nsINode.h#1728) and [nsINode::ClearBoolFlag()](https://searchfox.org/mozilla-central/source/dom/base/nsINode.h#1728). So, my guess is something selection-related slowing it down. I thought it might be registered Selection listeners causing trouble, but that doesn't seem to be the case (I commented out the notification call and it was still slow). I'm out of ideas for now. Magnus: this would benefit from having some input from someone who knows about HTMLEditor - any thoughts who?