mirror of
https://github.com/servo/servo
synced 2026-04-26 01:25:32 +02:00
Currently, `script` and `devtools` use a node's unique id to identify it
across requests. The unique ID is part of a node's rare data field and
is really only meant for debugging. Instantiating it on a node causes
it's memory usage to go up significantly. Now, when the devtools ask for
information about a specific `Node` then they send the unique ID to
`script`, and the script thread then walks the whole DOM tree searching
for that specific ID. This happens here:
6d0b651218/components/script/devtools.rs (L142-L153)
So, in the worst case, all of the nodes in the tree now have a unique
ID. That's not great!
Also, when `script` notifies `devtools` about changes to a DOM node then
`devtools` expects a `NodeActor` to exist for that Node. The actor might
not exist if the inspector doesn't know about that node yet - that
happens when the user hasn't expanded their parent yet.
That is an oversight from https://github.com/servo/servo/pull/42601 and
causes problems now(https://github.com/servo/servo/issues/42784) because
for the longest time, `devtools` was mostly the one sending requests. Of
course, we could make `devtools` simply ignore updates for nodes that it
doesn't know about, but ideally we shouldn't send these updates in the
first place.
This change implements a lookup map on the `ScriptThread` that contains
all nodes that have been sent to the devtools inspector. The map allows
us to efficiently resolve a unique ID to a `Node` in O(1), without
creating unique IDs for the whole tree. It also allows us to only send
DOM updates for nodes that the inspector cares about.
For now, entries from the cache are not evicted unless the relevant
pipeline is closed. That reflects reality, because the inspector also
keeps using them forever.
In the future we will tell the inspector when nodes are removed from the
tree - then it can't interact with them anymore, and we can remove them
from the script-side map.
This is change is not all that complicated but it involves moving a lot
of code around, so feel free to ask for clarification when something is
unclear!
Testing: This change adds a test
Fixes part of https://github.com/servo/servo/issues/42784
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This directory contains various Python modules used to support servo development.
servo
servo-specific python code e.g. implementations of mach commands. This is the canonical repository for this code.
tidy
servo-tidy is used to check licenses, line lengths, whitespace, ruff on Python files, lock file versions, and more.
wpt
servo-wpt is a module with support scripts for running, importing, exporting, updating manifests, and updating expectations for WPT tests.