devtools: Apply attribute modifications in the inspector to the DOM tree#42601
Merged
simonwuelker merged 3 commits intoservo:mainfrom Feb 17, 2026
Merged
Conversation
simonwuelker
commented
Feb 13, 2026
| #[serde(rename = "newValue")] | ||
| new_value: Option<String>, | ||
| }, | ||
| } |
Member
Author
There was a problem hiding this comment.
This enum may seem a bit redundant. I have a followup to this PR where more variants are added.
|
🔨 Triggering try run (#21994097619) for Linux (WPT) |
ee7de5c to
c3195ac
Compare
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
c3195ac to
18a9be4
Compare
|
Test results for linux-wpt from try job (#21994097619): Flaky unexpected result (26)
Stable unexpected results that are known to be intermittent (21)
|
|
|
9b578d9 to
b1552f7
Compare
Member
Author
|
I'm pinging you two because you reviewed my previous devtools PRs and there are not many maintainers familiar with this area of the code. Feel free to tell me if you dont want to be pinged on future PRs ^^ |
eerii
approved these changes
Feb 17, 2026
Member
eerii
left a comment
There was a problem hiding this comment.
Looks nice! And feel free to ping me for devtools code :)
atbrakhi
approved these changes
Feb 17, 2026
Member
atbrakhi
left a comment
There was a problem hiding this comment.
Thank you for adding tests, love it :)
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
b1552f7 to
8e0d714
Compare
This was referenced Feb 23, 2026
Closed
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Feb 25, 2026
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: https://github.com/servo/servo/blob/6d0b65121852e75ad9aea5cdf3f04ca186cc67f9/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 #42601 and causes problems now(#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 #42784 --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
shubhamg13
pushed a commit
to shubhamg13/servo
that referenced
this pull request
Mar 2, 2026
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: https://github.com/servo/servo/blob/6d0b65121852e75ad9aea5cdf3f04ca186cc67f9/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 servo#42601 and causes problems now(servo#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 servo#42784 --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The inspector view allows modifying the attributes of DOM elements. However, we lie to the devtools client: While it looks like the attributes change, the changes are never actually applied to the DOM.
This change fixes that, and also makes it so attribute modifications from non-inspector sources are shown in the inspector.
Testing: This change adds two tests