Improve Performance of TranslationsDocument Mutation Observation
Categories
(Firefox :: Translations, task, P3)
Tracking
()
People
(Reporter: nordzilla, Unassigned)
References
(Blocks 1 open bug)
Details
At present, the mutation observer code behaves fairly eagerly:
This is not an issue for a majority of sites that do not have a lot of mutations on page load. However, websites like YouTube will cause a significant delay in page load when auto-translate is enabled:
https://share.firefox.dev/42IGRa1
In particular, we are seeing a lot of time spent in textContent
and garbage collection:
https://share.firefox.dev/41M10L2
To improve performance on page load, we should consider options to debounce taking action on mutation observations.
We could explore doing this on a set time interval, or possibly once per requestedAnimationFrame
.
We will need a way to aggregate and de-duplicate nodes from mutations to translate on the debounce. Using a Set<Node>
may work, but there could exist edge cases where the Node is no longer on the page, or the node's parent is also in the set.
We can ensure that the translation is valid by deduplicating on the root-most Nodes.
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Comment 1•1 year ago
•
|
||
Maybe this will help with the performance related to bug 1651969.
Comment 2•1 year ago
|
||
Yes, I believe that is the root cause for that perf issue.
Comment 3•3 months ago
•
|
||
Fixed by Bug 1909632.
Description
•