devtools: Fix id collisions by using incrementing counters (#35971)

Devtools clients need a `browserId`, `browsingContextID`, and
`outerWindowID`, which correspond to WebViewId, BrowsingContextId, and
PipelineId in Servo. These u32 values were previously derived from our
sharded (u32,u32) id values by taking only the `index` (second u32) and
ignoring the `namespace_id` (first u32), leading to collisions.

This patch fixes that by mapping those Servo ids to sequential u32
values.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by
`[X]` when the step is complete, and replace `___` with appropriate
data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #35954

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox
is checked, so that we can help you if you get stuck somewhere along the
way.-->

<!-- Pull requests that do not address these steps are welcome, but they
will require additional verification as part of the review process. -->

---------

Signed-off-by: Delan Azabani <dazabani@igalia.com>
This commit is contained in:
Delan Azabani 2025-04-01 17:00:40 +08:00 committed by GitHub
parent fcef1dff9d
commit 30b712aaf9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 219 additions and 33 deletions

View file

@ -146,18 +146,15 @@ impl TabDescriptorActor {
pub fn encodable(&self, registry: &ActorRegistry, selected: bool) -> TabDescriptorActorMsg {
let ctx_actor = registry.find::<BrowsingContextActor>(&self.browsing_context_actor);
let browser_id = ctx_actor.browser_id.0.index.0.get();
let browsing_context_id = ctx_actor.browsing_context_id.index.0.get();
let outer_window_id = ctx_actor.active_pipeline.get().index.0.get();
let title = ctx_actor.title.borrow().clone();
let url = ctx_actor.url.borrow().clone();
TabDescriptorActorMsg {
actor: self.name(),
browser_id,
browsing_context_id,
browser_id: ctx_actor.browser_id.value(),
browsing_context_id: ctx_actor.browsing_context_id.value(),
is_zombie_tab: false,
outer_window_id,
outer_window_id: ctx_actor.active_outer_window_id.get().value(),
selected,
title,
traits: DescriptorTraits {