devtools-protocol icon indicating copy to clipboard operation
devtools-protocol copied to clipboard

NodeId, BackendNodeId, and RemoteObjectId

Open brendyna opened this issue 7 years ago • 4 comments

Hi @pavelfeldman, @RByers,

We're planning for our next round of EDP implementations. We're digging into DOM/DOMDebugger and we've noticed something we want to get your input on.

There are three types of IDs which we're unclear about the difference between: NodeId, BackendNodeId, and RemoteObjectId.

Could you clarify how those are used within CDP/Chrome DevTools?

Cheers, Brendyn

brendyna avatar Feb 22 '18 19:02 brendyna

Thanks @brendyna ! I get the difference between RemoteObjectId and the other two, but I don't get the difference between NodeId and BackendNodeId. That's what I'm really trying to figure out.

robpaveza avatar Feb 22 '18 20:02 robpaveza

cc @dgozman while pavel is OOO

paulirish avatar Feb 22 '18 20:02 paulirish

RemoteObjectId is from a JavaScript world, and corresponds to any JavaScript object, including JS wrappers for DOM nodes. There is a way to convert between node ids and remote object ids (DOM.requestNode and DOM.resolveNode).

NodeId is used for inspection, when backend tracks the node and sends updates to the frontend. If you somehow got NodeId over protocol, backend should have pushed to the frontend all of it's ancestors up to the Document node via DOM.setChildNodes. After that, frontend is always kept up-to-date about anything happening to the node.

BackendNodeId is just a unique identifier for a node. Obtaining it does not send any updates, for example, the node may be destroyed without any notification. This is a way to keep a reference to the Node, when you don't necessarily want to keep track of it. One example would be linking to the node from performance data (e.g. relayout root node). BackendNodeId may be either resolved to inspected node (DOM.pushNodesByBackendIdsToFrontend) or described in more details (DOM.describeNode).

Does this make sense?

dgozman avatar Feb 22 '18 21:02 dgozman

Thank you for your explanation of this kind of problem. I'm studying hard

ckpocket99 avatar Sep 01 '22 01:09 ckpocket99