Closed Bug 1913253 Opened 1 year ago Closed 11 months ago

"Paste without formatting" immediately after "Paste" causes the editor testcase to take infinite time

Categories

(Core :: DOM: Editor, defect)

defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: mayankleoboy1, Unassigned)

References

Details

Attachments

(3 files)

This is a sort of part2 of bug 1892514

  1. Open the attached testcase
  2. Open the attched sample text.
  3. Select all and copy (Ctrl+A, Ctrl+C)

Good scenario:
4. On the testcase Right Click -> Paste without Formatting
AR: Text is pasted in 2 seconds which is good
5. Now delete the whole text. Then Right Click -> Paste
AR: Text is pasted very fast which is good.

Bad scenario
4. On the testcase Right Click -> Paste
once the text is pasted, delete it all.
5. Go to the testcase and Right Click -> Paste without Formatting
AR: The browser will take infinite amount of time

Nightly : https://share.firefox.dev/4diITD0 / https://share.firefox.dev/4fJ3fHc (130s+)


To summarize, you can keep on doing EITHER "paste without formatting" OR "Paste" in a loop. But as soon as you do a "Paste" and immediately do a "Paste without formatting", the testcase blows up.

Attached file Sample text.txt
See Also: → 1909171, 1912069

FWIW, this bug does not repro on simple testcases like : data:text/html, <html style contenteditable spellcheck="false">

Profile with this smaller sample : https://share.firefox.dev/3AluPdg

  1. The tiny blip at the 2.5s mark is the first action i take which is to "Paste" the text. (https://share.firefox.dev/4dLKcdI)
  2. The small area at 3s mark is when i select all the text (https://share.firefox.dev/4cqgeuE)
  3. Tiny blip here is when I delete the elected text. (https://share.firefox.dev/3WOyBDt)
    • Why does it have so many "NotifySelectionListenersAfterRangeSet" runnables and not when i paste the text in #1 ?
  1. The large area starting from 5.2 is when I "Paste without formatting" as the second action.

Looks like both nsINode::ComputeIndexOf(nsINode const*) const and nsRange::DoSetRange<nsINode *,nsIContent *,nsINode *,nsIContent *>(mozilla::Range… are problematic.

jjaschke, can you take a look, please?

Severity: -- → S3
Flags: needinfo?(jjaschke)

I think the issue here is that our editor fires mutation events for each inserted node during paste instead of doing so once at the end.

Masayuki, we've coincidentally discussed this in the course of Bug 1503581. Can we apply batching here?

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

I want to stop dispatching the legacy DOM mutation events even partially while our editor touches the DOM because the other browsers already stopped dispatching in the cases. However, partially doing it may make some legacy editor app uses confused since legacy app would be broken only in the pasting operations.

Smaug: Do you think it's okay to stop dispatching the legacy DOM mutation events only in specific edit command handler in our editor for the performance?

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

(IIRC, we need to make some event dispatchers use AsyncEventDispatcher if we block to run script. E.g., error event dispatchers of some elements.)

I'd rather try to stop dispatching mutation events at all, and not add any special cases https://github.com/whatwg/html/pull/10573

Flags: needinfo?(smaug)

Curious, is there a timeline for this?

Flags: needinfo?(smaug)

Chrome has disabled mutation events by default now. So we should also try to investigate that option on Nightly asap.
(Mutation Events have been deprecated in Firefox since 2012.)

Flags: needinfo?(smaug)

Retesting with enabling/disabling mutation events (bug 1914513)

dom.mutation_events.enabled= False : https://share.firefox.dev/3zc97bp
dom.mutation_events.enabled= True : https://share.firefox.dev/4cRHNwU

Is there a plan or timeline to disable mutation events in Firefox?

(In reply to Mayank Bansal from comment #12)

Is there a plan or timeline to disable mutation events in Firefox?

Flags: needinfo?(smaug)

We know that web sites use still mutation events, so we can't disable them now. But disabling is part of interop-25, so hopefully it will happen later this year (since finally all the browsers are trying to disable them, not only Firefox).

Flags: needinfo?(smaug)

The testcase with the original STR is basically good enough now.
Profile: https://share.firefox.dev/46suGCX

I will close this as WFM, but please reopen if you see anything worth improving more.

Status: NEW → RESOLVED
Closed: 11 months ago
Resolution: --- → WORKSFORME

There is this profile though, which seems different (to me): https://share.firefox.dev/4lLo4V5
Will file a new bug for this.

See Also: → 1979244
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: