Testcase creating nodes, ranges and selections is 2050x slower in Firefox. Spends all the time in nsContentUtils::AddScriptRunner / SelectionChangeEventDispatcher (STR in comment 3)
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
People
(Reporter: mayankleoboy1, Unassigned, NeedInfo)
References
(Blocks 1 open bug)
Details
Attachments
(2 files)
STR:
- Open testcase
- Click on "1. Init nodes" --> fast
- Click on "2a. Bind N ranges" -->fast
- Click on "2b. Bind ranges to selection" -->fast
- Click on "Insert M front" --> Slow
Measure the time for the 5th step
Firefox Samply: https://share.firefox.dev/49gg7mC (205s)
Firefox gecko profiler (Partial): https://share.firefox.dev/4uzMFAz
Chrome: https://share.firefox.dev/4dpQv9i (100ms?)
This kinda looks bad. :masayuki, what do you think?
| Reporter | ||
Comment 1•2 months ago
|
||
needinfo for comment #0
| Reporter | ||
Updated•2 months ago
|
| Reporter | ||
Updated•2 months ago
|
Comment 2•2 months ago
•
|
||
The test is using selection.addRange(activeRanges[i]);. Other browsers support only 1 range per selection currently.
But currently, isn't the test basically testing behavior which other browsers don't support, so of course they are way faster?
(but that is may change soon https://github.com/w3c/selection-api/issues/358 )
Updated•2 months ago
|
| Reporter | ||
Comment 3•2 months ago
|
||
Nodes=100000, Insertions= 20000
Chrome: https://share.firefox.dev/3Rqgvsz (19s) - Insert M end + Delete M end
Firefox: https://share.firefox.dev/4tRvbhZ (150s) - insert M end + Delete M front
| Reporter | ||
Updated•2 months ago
|
Comment 4•2 months ago
|
||
It seems that SelectionChangeEventDispatcher::OnSelectionChange() should enqueue its job and dispatch selectionchange event once unless we need to dispatch selectionchange per mutation if each one changes the range.
Currently, the spec defines that as dispatched every mutation, but I'm not sure whether the other browsers behave so. From web app's point of view, only one selectionchange event should be reasonable.
| Reporter | ||
Updated•2 months ago
|
Comment 5•1 month ago
|
||
Oh, the spec was changed in https://github.com/w3c/selection-api/pull/172 to schedule only one selectionchange event. So, we should be able to improve the performance.
Description
•