Changeset 218908 in webkit
- Timestamp:
- Jun 28, 2017 6:34:51 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r218893 r218908 1 2017-06-28 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Instrument active pixel memory used by canvases 4 https://bugs.webkit.org/show_bug.cgi?id=173087 5 <rdar://problem/32719261> 6 7 Reviewed by Joseph Pecoraro. 8 9 * inspector/canvas/memory-expected.txt: Added. 10 * inspector/canvas/memory.html: Added. 11 1 12 2017-06-28 Ryan Haddad <ryanhaddad@apple.com> 2 13 -
trunk/Source/JavaScriptCore/ChangeLog
r218898 r218908 1 2017-06-28 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Instrument active pixel memory used by canvases 4 https://bugs.webkit.org/show_bug.cgi?id=173087 5 <rdar://problem/32719261> 6 7 Reviewed by Joseph Pecoraro. 8 9 * inspector/protocol/Canvas.json: 10 - Add optional `memoryCost` attribute to the `Canvas` type. 11 - Add `canvasMemoryChanged` event that is dispatched when the `memoryCost` of a canvas changes. 12 1 13 2017-06-28 Joseph Pecoraro <pecoraro@apple.com> 2 14 -
trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json
r218618 r218908 39 39 { "name": "nodeId", "$ref": "DOM.NodeId", "optional": true, "description": "The corresponding DOM node id." }, 40 40 { "name": "cssCanvasName", "type": "string", "optional": true, "description": "The CSS canvas identifier, for canvases created with <code>document.getCSSCanvasContext</code>." }, 41 { "name": "contextAttributes", "$ref": "ContextAttributes", "optional": true, "description": "Context attributes for WebGL rendering contexts." } 41 { "name": "contextAttributes", "$ref": "ContextAttributes", "optional": true, "description": "Context attributes for WebGL rendering contexts." }, 42 { "name": "memoryCost", "type": "number", "optional": true, "description": "Memory usage of the canvas in bytes." } 42 43 ] 43 44 } … … 85 86 { "name": "canvasId", "$ref": "CanvasId", "description": "Removed canvas identifier." } 86 87 ] 88 }, 89 { 90 "name": "canvasMemoryChanged", 91 "parameters": [ 92 { "name": "canvasId", "$ref": "CanvasId", "description": "Identifier of canvas that changed." }, 93 { "name": "memoryCost", "type": "number", "description": "New memory cost value for the canvas in bytes." } 94 ] 87 95 } 88 96 ] -
trunk/Source/WebCore/ChangeLog
r218907 r218908 1 2017-06-28 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Instrument active pixel memory used by canvases 4 https://bugs.webkit.org/show_bug.cgi?id=173087 5 <rdar://problem/32719261> 6 7 Reviewed by Joseph Pecoraro. 8 9 Test: inspector/canvas/memory.html 10 11 * html/HTMLCanvasElement.cpp: 12 (WebCore::HTMLCanvasElement::setImageBuffer): 13 * inspector/InspectorCanvasAgent.h: 14 * inspector/InspectorCanvasAgent.cpp: 15 (WebCore::InspectorCanvasAgent::didChangeCanvasMemory): 16 (WebCore::InspectorCanvasAgent::buildObjectForCanvas): 17 * inspector/InspectorInstrumentation.h: 18 * inspector/InspectorInstrumentation.cpp: 19 (WebCore::InspectorInstrumentation::didChangeCanvasMemory): 20 (WebCore::InspectorInstrumentation::didChangeCanvasMemoryImpl): 21 1 22 2017-06-28 Alex Christensen <achristensen@webkit.org> 2 23 -
trunk/Source/WebCore/html/HTMLCanvasElement.cpp
r218440 r218908 757 757 void HTMLCanvasElement::setImageBuffer(std::unique_ptr<ImageBuffer> buffer) const 758 758 { 759 removeFromActivePixelMemory(memoryCost()); 759 size_t previousMemoryCost = memoryCost(); 760 removeFromActivePixelMemory(previousMemoryCost); 760 761 761 762 m_imageBuffer = WTFMove(buffer); 762 763 763 activePixelMemory += memoryCost(); 764 size_t currentMemoryCost = memoryCost(); 765 activePixelMemory += currentMemoryCost; 766 767 if (m_imageBuffer && previousMemoryCost != currentMemoryCost) 768 InspectorInstrumentation::didChangeCanvasMemory(const_cast<HTMLCanvasElement&>(*this)); 764 769 } 765 770 -
trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp
r218618 r218908 181 181 } 182 182 183 void InspectorCanvasAgent::didChangeCanvasMemory(HTMLCanvasElement& canvasElement) 184 { 185 CanvasEntry* canvasEntry = getCanvasEntry(canvasElement); 186 if (!canvasEntry) 187 return; 188 189 m_frontendDispatcher->canvasMemoryChanged(canvasEntry->identifier, canvasElement.memoryCost()); 190 } 191 183 192 void InspectorCanvasAgent::canvasDestroyed(HTMLCanvasElement& canvasElement) 184 193 { … … 296 305 #endif 297 306 307 if (size_t memoryCost = canvasElement.memoryCost()) 308 canvas->setMemoryCost(memoryCost); 309 298 310 return canvas; 299 311 } -
trunk/Source/WebCore/inspector/InspectorCanvasAgent.h
r218544 r218908 65 65 void didCreateCSSCanvas(HTMLCanvasElement&, const String&); 66 66 void didCreateCanvasRenderingContext(HTMLCanvasElement&); 67 void didChangeCanvasMemory(HTMLCanvasElement&); 67 68 68 69 // CanvasObserver -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r218440 r218908 1006 1006 } 1007 1007 1008 void InspectorInstrumentation::didChangeCanvasMemoryImpl(InstrumentingAgents* instrumentingAgents, HTMLCanvasElement& canvasElement) 1009 { 1010 if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent()) 1011 canvasAgent->didChangeCanvasMemory(canvasElement); 1012 } 1013 1008 1014 #if ENABLE(WEB_REPLAY) 1009 1015 void InspectorInstrumentation::sessionCreatedImpl(InstrumentingAgents& instrumentingAgents, RefPtr<ReplaySession>&& session) -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r218440 r218908 248 248 static void didCreateCSSCanvas(HTMLCanvasElement&, const String&); 249 249 static void didCreateCanvasRenderingContext(HTMLCanvasElement&); 250 static void didChangeCanvasMemory(HTMLCanvasElement&); 250 251 251 252 static void networkStateChanged(Page&); … … 423 424 static void didCreateCSSCanvasImpl(InstrumentingAgents*, HTMLCanvasElement&, const String&); 424 425 static void didCreateCanvasRenderingContextImpl(InstrumentingAgents*, HTMLCanvasElement&); 426 static void didChangeCanvasMemoryImpl(InstrumentingAgents*, HTMLCanvasElement&); 425 427 426 428 static void layerTreeDidChangeImpl(InstrumentingAgents&); … … 1194 1196 } 1195 1197 1198 inline void InspectorInstrumentation::didChangeCanvasMemory(HTMLCanvasElement& canvasElement) 1199 { 1200 FAST_RETURN_IF_NO_FRONTENDS(void()); 1201 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(&canvasElement.document())) 1202 didChangeCanvasMemoryImpl(instrumentingAgents, canvasElement); 1203 } 1204 1196 1205 inline void InspectorInstrumentation::networkStateChanged(Page& page) 1197 1206 { -
trunk/Source/WebInspectorUI/.eslintrc
r205426 r218908 35 35 "ApplicationCacheAgent": true, 36 36 "CSSAgent": true, 37 "CanvasAgent": true, 37 38 "ConsoleAgent": true, 38 39 "DOMAgent": true, -
trunk/Source/WebInspectorUI/ChangeLog
r218897 r218908 1 2017-06-28 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Instrument active pixel memory used by canvases 4 https://bugs.webkit.org/show_bug.cgi?id=173087 5 <rdar://problem/32719261> 6 7 Reviewed by Joseph Pecoraro. 8 9 * .eslintrc: 10 * UserInterface/Controllers/CanvasManager.js: 11 (WebInspector.CanvasManager.prototype.canvasMemoryChanged): 12 * UserInterface/Models/Canvas.js: 13 (WebInspector.Canvas.fromPayload): 14 (WebInspector.Canvas.prototype.get memoryCost): 15 (WebInspector.Canvas.prototype.set memoryCost): 16 * UserInterface/Protocol/CanvasObserver.js: 17 (WebInspector.CanvasObserver.prototype.canvasMemoryChanged): 18 * UserInterface/Views/CanvasDetailsSidebarPanel.js: 19 (WebInspector.CanvasDetailsSidebarPanel.prototype.initialLayout): 20 (WebInspector.CanvasDetailsSidebarPanel.prototype._refreshIdentitySection): 21 (WebInspector.CanvasDetailsSidebarPanel.prototype._formatMemoryRow): 22 (WebInspector.CanvasDetailsSidebarPanel.prototype._canvasMemoryChanged): 23 24 * Localizations/en.lproj/localizedStrings.js: 25 * UserInterface/Base/Utilities.js: 26 (Number.bytesToString.value): 27 Add support for gigabyte numbers. 28 1 29 2017-06-27 Joseph Pecoraro <pecoraro@apple.com> 2 30 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r218839 r218908 6 6 localizedStrings["%.0f B"] = "%.0f B"; 7 7 localizedStrings["%.0fms"] = "%.0fms"; 8 localizedStrings["%.1f GB"] = "%.1f GB"; 8 9 localizedStrings["%.1f KB"] = "%.1f KB"; 9 10 localizedStrings["%.1f MB"] = "%.1f MB"; … … 15 16 localizedStrings["%.1fmin"] = "%.1fmin"; 16 17 localizedStrings["%.1fms"] = "%.1fms"; 18 localizedStrings["%.2f GB"] = "%.2f GB"; 17 19 localizedStrings["%.2f KB"] = "%.2f KB"; 18 20 localizedStrings["%.2f MB"] = "%.2f MB"; … … 543 545 localizedStrings["Medium"] = "Medium"; 544 546 localizedStrings["Memory"] = "Memory"; 547 localizedStrings["Memory usage of this canvas"] = "Memory usage of this canvas"; 545 548 localizedStrings["Memory: %s"] = "Memory: %s"; 546 549 localizedStrings["Message"] = "Message"; -
trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js
r214405 r218908 1082 1082 1083 1083 let megabytes = kilobytes / 1024; 1084 if (higherResolution || Math.abs(megabytes) < 10) 1085 return WebInspector.UIString("%.2f MB").format(megabytes); 1086 return WebInspector.UIString("%.1f MB").format(megabytes); 1084 if (Math.abs(megabytes) < 1024) { 1085 if (higherResolution || Math.abs(megabytes) < 10) 1086 return WebInspector.UIString("%.2f MB").format(megabytes); 1087 return WebInspector.UIString("%.1f MB").format(megabytes); 1088 } 1089 1090 let gigabytes = megabytes / 1024; 1091 if (higherResolution || Math.abs(gigabytes) < 10) 1092 return WebInspector.UIString("%.2f GB").format(gigabytes); 1093 return WebInspector.UIString("%.1f GB").format(gigabytes); 1087 1094 } 1088 1095 }); -
trunk/Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js
r218544 r218908 73 73 } 74 74 75 canvasMemoryChanged(canvasIdentifier, memoryCost) 76 { 77 // Called from WebInspector.CanvasObserver. 78 79 let canvas = this._canvasIdentifierMap.get(canvasIdentifier); 80 console.assert(canvas); 81 if (!canvas) 82 return; 83 84 canvas.memoryCost = memoryCost; 85 } 86 75 87 // Private 76 88 -
trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js
r218618 r218908 26 26 WebInspector.Canvas = class Canvas extends WebInspector.Object 27 27 { 28 constructor(identifier, contextType, frame, {domNode, cssCanvasName, contextAttributes } = {})28 constructor(identifier, contextType, frame, {domNode, cssCanvasName, contextAttributes, memoryCost} = {}) 29 29 { 30 30 super(); … … 40 40 this._cssCanvasName = cssCanvasName || ""; 41 41 this._contextAttributes = contextAttributes || {}; 42 this._memoryCost = memoryCost || NaN; 42 43 } 43 44 … … 63 64 cssCanvasName: payload.cssCanvasName, 64 65 contextAttributes: payload.contextAttributes, 66 memoryCost: payload.memoryCost, 65 67 }); 66 68 } … … 90 92 get cssCanvasName() { return this._cssCanvasName; } 91 93 get contextAttributes() { return this._contextAttributes; } 94 95 get memoryCost() 96 { 97 return this._memoryCost; 98 } 99 100 set memoryCost(memoryCost) 101 { 102 if (memoryCost === this._memoryCost) 103 return; 104 105 this._memoryCost = memoryCost; 106 107 this.dispatchEventToListeners(WebInspector.Canvas.Event.MemoryChanged); 108 } 92 109 93 110 get displayName() … … 162 179 163 180 WebInspector.Canvas.ResourceSidebarType = "resource-type-canvas"; 181 182 WebInspector.Canvas.Event = { 183 MemoryChanged: "canvas-memory-changed", 184 }; -
trunk/Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js
r218440 r218908 37 37 WebInspector.canvasManager.canvasRemoved(canvasId); 38 38 } 39 40 canvasMemoryChanged(canvasId, memoryCost) 41 { 42 WebInspector.canvasManager.canvasMemoryChanged(canvasId, memoryCost); 43 } 39 44 }; -
trunk/Source/WebInspectorUI/UserInterface/Views/CanvasDetailsSidebarPanel.js
r218618 r218908 58 58 return; 59 59 60 this._canvas = canvas || null;61 62 60 if (this._node) { 63 61 this._node.removeEventListener(WebInspector.DOMNode.Event.AttributeModified, this._refreshSourceSection, this); … … 67 65 } 68 66 67 if (this._canvas) 68 this._canvas.removeEventListener(WebInspector.Canvas.Event.MemoryChanged, this._canvasMemoryChanged, this); 69 70 this._canvas = canvas || null; 71 72 if (this._canvas) 73 this._canvas.addEventListener(WebInspector.Canvas.Event.MemoryChanged, this._canvasMemoryChanged, this); 74 69 75 this.needsLayout(); 70 76 } … … 78 84 this._nameRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Name")); 79 85 this._typeRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Type")); 86 this._memoryRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Memory")); 80 87 81 88 let identitySection = new WebInspector.DetailsSection("canvas-details", WebInspector.UIString("Identity")); 82 identitySection.groups = [new WebInspector.DetailsSectionGroup([this._nameRow, this._typeRow ])];89 identitySection.groups = [new WebInspector.DetailsSectionGroup([this._nameRow, this._typeRow, this._memoryRow])]; 83 90 this.contentView.element.appendChild(identitySection.element); 84 91 … … 129 136 this._nameRow.value = this._canvas.displayName; 130 137 this._typeRow.value = WebInspector.Canvas.displayNameForContextType(this._canvas.contextType); 138 this._formatMemoryRow(); 131 139 } 132 140 … … 231 239 dataGrid.updateLayoutIfNeeded(); 232 240 } 241 242 _formatMemoryRow() 243 { 244 if (!this._canvas.memoryCost || isNaN(this._canvas.memoryCost)) { 245 this._memoryRow.value = emDash; 246 return; 247 } 248 249 let canvasMemory = Number.bytesToString(this._canvas.memoryCost); 250 this._memoryRow.value = canvasMemory; 251 this._memoryRow.tooltip = WebInspector.UIString("Memory usage of this canvas"); 252 } 253 254 _canvasMemoryChanged(event) 255 { 256 this._formatMemoryRow(); 257 } 233 258 };
Note: See TracChangeset
for help on using the changeset viewer.