Bug 232699

Summary: Web Inspector: sync changes to settings across instances
Product: WebKit Reporter: Devin Rousso <hi>
Component: Web InspectorAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: hi, inspector-bugzilla-changes, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
See Also: https://bugs.webkit.org/show_bug.cgi?id=232697
https://bugs.webkit.org/show_bug.cgi?id=232698
Attachments:
Description Flags
[Patch] WIP none

Description Devin Rousso 2021-11-04 00:02:09 PDT
.
Comment 1 Devin Rousso 2021-11-04 01:49:25 PDT
Created attachment 443285 [details]
[Patch] WIP

Now that `BroadcastChannel` exists, I figured I'd give this a shot as it's something I've always wanted to try :)

Having used it briefly, however, I'm a bit conflicted.

On one hand, there definitely is something super awesome about things just magically syncing between Web Inspector instances (e.g. adding a JS breakpoint in one will make it appear (assuming you're inspecting the same page) in the other).  If not everything it would at least be nice to have more general UI things sync (e.g. Appearance, indentation style, etc.).

On the other hand, having Web Inspector instances be (mostly) isolated means that you can do different things in each while they're both simultaneously open.  As an example, when debugging two versions of the same site (e.g. the server sends back different content depending on some state) it may actually be incorrect to sync things like breakpoints as the contents of resources with the same `objectIdentifier` may not be the same (note that `objectIdentifier` is intended to be a way of uniquely identifying something within a specific Web Inspector, not globally).

Regardless, there are still some kinks to work out in this
- figure out how to guarantee that `WI.FrontendSynchronizer.close();` is called, no matter how Web Inspector is closed
- make sure all `WI.Setting` actually listen for changes (e.g. `_bootstrapScriptEnabledSetting`)
- write some tests (will likely have to be an API test as I don't think LayoutTests allow for multiple pages/inspectors)
- confirm that no extra work is being done if there are no other Web Inspector frontends to talk to
- audit the codepaths surrounding each usage of `WI.FrontendSynchronizer` to really make sure that there's no re-entrancy or infinite ping-pong (`BroadcastChannel` is only supposed to send a `"message"` to _other_ instances, but if they then turn around and send it right back then we're in a bit of a pickle)
Comment 2 Radar WebKit Bug Importer 2021-11-10 23:03:19 PST
<rdar://problem/85286040>