[webkit-changes] [WebKit/WebKit] 4464c3: Web Inspector: Enable Memory profiling in Workers

Devin Rousso noreply at github.com
Tue Feb 4 19:23:10 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4464c381ec4f5eed56465fd656bf37b3835b9a4a
      https://github.com/WebKit/WebKit/commit/4464c381ec4f5eed56465fd656bf37b3835b9a4a
  Author: Devin Rousso <hi at devinrousso.com>
  Date:   2025-02-04 (Tue, 04 Feb 2025)

  Changed paths:
    M LayoutTests/inspector/heap/getPreview.html
    M LayoutTests/inspector/heap/getRemoteObject.html
    M LayoutTests/inspector/heap/imported-snapshot.html
    M LayoutTests/inspector/heap/snapshot.html
    M LayoutTests/inspector/unit-tests/heap-snapshot-collection-event.html
    M LayoutTests/inspector/unit-tests/heap-snapshot.html
    M Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
    M Source/WebInspectorUI/UserInterface/Controllers/HeapManager.js
    M Source/WebInspectorUI/UserInterface/Models/HeapAllocationsInstrument.js
    M Source/WebInspectorUI/UserInterface/Models/HeapAllocationsTimelineRecord.js
    M Source/WebInspectorUI/UserInterface/Protocol/ConsoleObserver.js
    M Source/WebInspectorUI/UserInterface/Protocol/HeapObserver.js
    M Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotDiffProxy.js
    M Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotNodeProxy.js
    M Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotProxy.js
    M Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotWorkerProxy.js
    M Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineView.js
    M Source/WebInspectorUI/UserInterface/Views/HeapSnapshotClusterContentView.js
    M Source/WebInspectorUI/UserInterface/Views/HeapSnapshotDataGridTree.js
    M Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceDataGridNode.js
    M Source/WebInspectorUI/UserInterface/Views/TextNavigationItem.css
    M Source/WebInspectorUI/UserInterface/Views/TimelineTabContentView.js
    M Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshot.js
    M Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshotWorker.js

  Log Message:
  -----------
  Web Inspector: Enable Memory profiling in Workers
https://bugs.webkit.org/show_bug.cgi?id=167323

Reviewed by BJ Burg.

The Web Inspector frontend always assumes the main target when interacting with `Heap`, meaning that even though `Heap` is already enabled inside `Worker` (i.e. there's even a `WebHeapAgent`) it'll never communicate with any other `WI.Target`.

Note that there are still a few things missing from full support as `Timelines` currently only supports the main target (e.g. auto-capture in `Worker` on page load won't happen).

* Source/WebInspectorUI/UserInterface/Models/HeapAllocationsInstrument.js:
(WI.HeapAllocationsInstrument.prototype.startInstrumentation):
(WI.HeapAllocationsInstrument.prototype.stopInstrumentation):
(WI.HeapAllocationsInstrument.prototype._takeHeapSnapshot):
Start and stop `Heap` for each `WI.Target` instead of just the main target.

* Source/WebInspectorUI/UserInterface/Protocol/ConsoleObserver.js:
(WI.ConsoleObserver.prototype.heapSnapshot):
* Source/WebInspectorUI/UserInterface/Protocol/HeapObserver.js:
(WI.HeapObserver.prototype.trackingStart):
(WI.HeapObserver.prototype.trackingComplete):
* Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotDiffProxy.js:
(WI.HeapSnapshotDiffProxy):
(WI.HeapSnapshotDiffProxy.deserialize):
(WI.HeapSnapshotDiffProxy.prototype.get target): Added.
(WI.HeapSnapshotDiffProxy.prototype.instancesWithClassName):
(WI.HeapSnapshotDiffProxy.prototype.nodeWithIdentifier):
* Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotNodeProxy.js:
(WI.HeapSnapshotNodeProxy):
(WI.HeapSnapshotNodeProxy.deserialize):
(WI.HeapSnapshotNodeProxy.prototype.get target): Added.
(WI.HeapSnapshotNodeProxy.prototype.shortestGCRootPath):
(WI.HeapSnapshotNodeProxy.prototype.dominatedNodes):
(WI.HeapSnapshotNodeProxy.prototype.retainedNodes):
(WI.HeapSnapshotNodeProxy.prototype.retainers):
* Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotProxy.js:
(WI.HeapSnapshotProxy):
(WI.HeapSnapshotProxy.deserialize):
(WI.HeapSnapshotProxy.prototype.get target): Added.
(WI.HeapSnapshotProxy.prototype.get imported):
(WI.HeapSnapshotProxy.prototype.instancesWithClassName):
(WI.HeapSnapshotProxy.prototype.nodeWithIdentifier):
Pass along the `WI.Target` when handling events or creating new proxies.

* Source/WebInspectorUI/UserInterface/Controllers/HeapManager.js:
(WI.HeapManager.prototype.snapshot):
(WI.HeapManager.prototype.getPreview):
(WI.HeapManager.prototype.getRemoteObject):
(WI.HeapManager.prototype.garbageCollected):
Use the relevant `WI.Target` instead of just the main target.

* Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotWorkerProxy.js:
(WI.HeapSnapshotWorkerProxy.prototype.createImportedSnapshot):
* Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshot.js:
(HeapSnapshot):
(HeapSnapshot.prototype.updateDeadNodesAndGatherCollectionData):
(HeapSnapshot.prototype.serialize):
(HeapSnapshot.prototype._isNodeGlobalObject):
* Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshotWorker.js:
(HeapSnapshotWorker.prototype.createSnapshot):
Pass along a `targetId` so that when new heap snapshots are captured we can determine which previous snapshots to update for what's still live.
Keep a separate identifier counter for each title instead of a single global one (e.g. "Page 1" and "Worker 1" instead of "Page 1" and "Worker 2").
Drive-by: Fix an exception after 284791 at main caused by `_roots` (and `_labels`) not always being set.

* Source/WebInspectorUI/UserInterface/Models/HeapAllocationsTimelineRecord.js:
(WI.HeapAllocationsTimelineRecord.async fromJSON):
Imported heap snapshots won't have a target.

* Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineView.js:
(WI.HeapAllocationsTimelineView):
(WI.HeapAllocationsTimelineView.prototype._importButtonNavigationItemClicked):
(WI.HeapAllocationsTimelineView.prototype._takeHeapSnapshotClicked):
(WI.HeapAllocationsTimelineView.prototype._dataGridNodeSelected):
Allow for heap snapshots to be sorted by name since there's now more than just "Snapshot #".

* Source/WebInspectorUI/UserInterface/Views/HeapSnapshotClusterContentView.js:
(WI.HeapSnapshotClusterContentView.iconStyleClassNameForClassName):
* Source/WebInspectorUI/UserInterface/Views/HeapSnapshotDataGridTree.js:
(WI.HeapSnapshotObjectGraphDataGridTree.prototype.populateTopLevel):
* Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceDataGridNode.js:
(WI.HeapSnapshotInstanceDataGridNode.logHeapSnapshotNode):
(WI.HeapSnapshotInstanceDataGridNode.prototype.createCellContent):
(WI.HeapSnapshotInstanceDataGridNode.prototype._populateWindowPreview):
(WI.HeapSnapshotInstanceDataGridNode.prototype._populatePreview):
(WI.HeapSnapshotInstanceDataGridNode.prototype._mouseoverHandler):
(WI.HeapSnapshotInstanceDataGridNode.prototype._mouseoverHandler.appendPath):
(WI.HeapSnapshotInstanceDataGridNode.prototype._mouseoverHandler.appendPathRow):
Don't assume that the root is named "Window", as `Worker` should be "DedicatedWorkerGlobalScope".

* Source/WebInspectorUI/UserInterface/Views/TimelineTabContentView.js:
(WI.TimelineTabContentView.displayNameForRecord):
Change how heap snapshots are named now that they're captured in the page and `Worker`.

* Source/WebInspectorUI/UserInterface/Views/TextNavigationItem.css:
(@media (prefers-color-scheme: dark) .navigation-bar .item.text): Added.
Drive-by: Fix heap snapshot diff text color not being visible in dark mode.

* LayoutTests/inspector/heap/getPreview.html:
* LayoutTests/inspector/heap/getRemoteObject.html:
* LayoutTests/inspector/heap/imported-snapshot.html:
* LayoutTests/inspector/heap/snapshot.html:
* LayoutTests/inspector/unit-tests/heap-snapshot.html:
* LayoutTests/inspector/unit-tests/heap-snapshot-collection-event.html:

Canonical link: https://commits.webkit.org/289847@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list