@gnsx/three 0.185.16 → 0.185.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,7 +8,14 @@ import { Parameters } from './tabs/Parameters.js';
|
|
|
8
8
|
import { Settings } from './tabs/Settings.js';
|
|
9
9
|
import { Viewer } from './tabs/Viewer.js';
|
|
10
10
|
import { Timeline } from './tabs/Timeline.js';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
setText,
|
|
13
|
+
// WITH_GENESYS
|
|
14
|
+
getJSHeapBytes,
|
|
15
|
+
startJSHeapSampling,
|
|
16
|
+
stopJSHeapSampling
|
|
17
|
+
// !WITH_GENESYS
|
|
18
|
+
} from './ui/utils.js';
|
|
12
19
|
|
|
13
20
|
import { setConsoleFunction, REVISION } from '@gnsx/three/webgpu';
|
|
14
21
|
|
|
@@ -18,6 +25,10 @@ class Inspector extends RendererInspector {
|
|
|
18
25
|
|
|
19
26
|
super();
|
|
20
27
|
|
|
28
|
+
// WITH_GENESYS
|
|
29
|
+
startJSHeapSampling();
|
|
30
|
+
// !WITH_GENESYS
|
|
31
|
+
|
|
21
32
|
// init profiler
|
|
22
33
|
|
|
23
34
|
const profiler = new Profiler( this );
|
|
@@ -493,6 +504,50 @@ class Inspector extends RendererInspector {
|
|
|
493
504
|
|
|
494
505
|
setText( this.profiler.toggleButton.querySelector( '.fps-counter' ), this.fps.toFixed() );
|
|
495
506
|
|
|
507
|
+
// WITH_GENESYS
|
|
508
|
+
const toggle = this.profiler.toggleButton;
|
|
509
|
+
const gpuCounter = toggle.querySelector( '.gpu-counter' );
|
|
510
|
+
const gpuLabel = toggle.querySelector( '.gpu-label' );
|
|
511
|
+
const heapCounter = toggle.querySelector( '.heap-counter' );
|
|
512
|
+
const heapLabel = toggle.querySelector( '.heap-label' );
|
|
513
|
+
const gpuBytes = this.getRenderer()?.info?.memory?.total;
|
|
514
|
+
const heap = getJSHeapBytes();
|
|
515
|
+
|
|
516
|
+
if ( gpuCounter ) {
|
|
517
|
+
|
|
518
|
+
if ( typeof gpuBytes === 'number' ) {
|
|
519
|
+
|
|
520
|
+
setText( gpuCounter, ( gpuBytes / ( 1024 * 1024 ) ).toFixed( 0 ) );
|
|
521
|
+
gpuCounter.style.display = '';
|
|
522
|
+
if ( gpuLabel ) gpuLabel.style.display = '';
|
|
523
|
+
|
|
524
|
+
} else {
|
|
525
|
+
|
|
526
|
+
gpuCounter.style.display = 'none';
|
|
527
|
+
if ( gpuLabel ) gpuLabel.style.display = 'none';
|
|
528
|
+
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
if ( heapCounter ) {
|
|
534
|
+
|
|
535
|
+
if ( heap ) {
|
|
536
|
+
|
|
537
|
+
setText( heapCounter, ( heap.used / ( 1024 * 1024 ) ).toFixed( 0 ) );
|
|
538
|
+
heapCounter.style.display = '';
|
|
539
|
+
if ( heapLabel ) heapLabel.style.display = '';
|
|
540
|
+
|
|
541
|
+
} else {
|
|
542
|
+
|
|
543
|
+
heapCounter.style.display = 'none';
|
|
544
|
+
if ( heapLabel ) heapLabel.style.display = 'none';
|
|
545
|
+
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
}
|
|
549
|
+
// !WITH_GENESYS
|
|
550
|
+
|
|
496
551
|
this.performance.updateText( this, frame );
|
|
497
552
|
this.memory.updateText( this );
|
|
498
553
|
|
|
@@ -535,6 +590,14 @@ class Inspector extends RendererInspector {
|
|
|
535
590
|
|
|
536
591
|
}
|
|
537
592
|
|
|
593
|
+
dispose() {
|
|
594
|
+
|
|
595
|
+
// WITH_GENESYS
|
|
596
|
+
stopJSHeapSampling();
|
|
597
|
+
// !WITH_GENESYS
|
|
598
|
+
|
|
599
|
+
}
|
|
600
|
+
|
|
538
601
|
}
|
|
539
602
|
|
|
540
603
|
function getItem( id ) {
|
|
@@ -2,7 +2,15 @@ import { Tab } from '../ui/Tab.js';
|
|
|
2
2
|
import { List } from '../ui/List.js';
|
|
3
3
|
import { Graph } from '../ui/Graph.js';
|
|
4
4
|
import { Item } from '../ui/Item.js';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
createValueSpan,
|
|
7
|
+
setText,
|
|
8
|
+
formatBytes,
|
|
9
|
+
info,
|
|
10
|
+
// WITH_GENESYS
|
|
11
|
+
getJSHeapBytes
|
|
12
|
+
// !WITH_GENESYS
|
|
13
|
+
} from '../ui/utils.js';
|
|
6
14
|
|
|
7
15
|
class Memory extends Tab {
|
|
8
16
|
|
|
@@ -26,6 +34,9 @@ class Memory extends Tab {
|
|
|
26
34
|
|
|
27
35
|
const graph = new Graph();
|
|
28
36
|
graph.addLine( 'total', 'var( --color-yellow )' );
|
|
37
|
+
// WITH_GENESYS
|
|
38
|
+
graph.addLine( 'jsHeap', 'var( --color-accent )' );
|
|
39
|
+
// !WITH_GENESYS
|
|
29
40
|
graphContainer.append( graph.domElement );
|
|
30
41
|
|
|
31
42
|
// stats
|
|
@@ -37,6 +48,13 @@ class Memory extends Tab {
|
|
|
37
48
|
graphItem.itemRow.childNodes[ 0 ].style.gridColumn = '1 / -1';
|
|
38
49
|
graphStats.add( graphItem );
|
|
39
50
|
|
|
51
|
+
// WITH_GENESYS
|
|
52
|
+
const legend = document.createElement( 'div' );
|
|
53
|
+
legend.className = 'graph-caption graph-legend';
|
|
54
|
+
legend.innerHTML = '<span class="graph-legend-item graph-legend-gpu">GPU</span><span class="graph-legend-item graph-legend-heap">JS Heap</span>';
|
|
55
|
+
graphContainer.prepend( legend );
|
|
56
|
+
// !WITH_GENESYS
|
|
57
|
+
|
|
40
58
|
// info
|
|
41
59
|
|
|
42
60
|
this.memoryStats = new Item( 'Renderer Info', '', createValueSpan() );
|
|
@@ -73,6 +91,19 @@ class Memory extends Tab {
|
|
|
73
91
|
this.uniformBuffers = new Item( 'Uniform Buffers', createValueSpan(), createValueSpan() );
|
|
74
92
|
this.memoryStats.add( this.uniformBuffers );
|
|
75
93
|
|
|
94
|
+
// WITH_GENESYS
|
|
95
|
+
this.jsHeapStats = new Item( 'JS Heap', '', createValueSpan() );
|
|
96
|
+
this.jsHeapStats.domElement.firstChild.classList.add( 'no-hover' );
|
|
97
|
+
memoryList.add( this.jsHeapStats );
|
|
98
|
+
info( this.jsHeapStats.domElement.querySelector( '.list-item-cell' ), 'Chromium reports V8 heap via performance.memory (used / allocated / limit). Other browsers only report a page-memory estimate if performance.measureUserAgentSpecificMemory is available in a cross-origin isolated document. Safari and Firefox do not expose JS heap size to web pages.' );
|
|
99
|
+
|
|
100
|
+
this.jsHeapAllocated = new Item( 'Allocated', '', createValueSpan() );
|
|
101
|
+
this.jsHeapStats.add( this.jsHeapAllocated );
|
|
102
|
+
|
|
103
|
+
this.jsHeapLimit = new Item( 'Limit', '', createValueSpan() );
|
|
104
|
+
this.jsHeapStats.add( this.jsHeapLimit );
|
|
105
|
+
// !WITH_GENESYS
|
|
106
|
+
|
|
76
107
|
this.graph = graph;
|
|
77
108
|
|
|
78
109
|
}
|
|
@@ -86,6 +117,16 @@ class Memory extends Tab {
|
|
|
86
117
|
|
|
87
118
|
this.graph.addPoint( 'total', memory.total );
|
|
88
119
|
|
|
120
|
+
// WITH_GENESYS
|
|
121
|
+
const heap = getJSHeapBytes();
|
|
122
|
+
|
|
123
|
+
if ( heap ) {
|
|
124
|
+
|
|
125
|
+
this.graph.addPoint( 'jsHeap', heap.used );
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
// !WITH_GENESYS
|
|
129
|
+
|
|
89
130
|
if ( this.graph.limit === 0 ) this.graph.limit = 1;
|
|
90
131
|
|
|
91
132
|
this.graph.update();
|
|
@@ -129,6 +170,24 @@ class Memory extends Tab {
|
|
|
129
170
|
setText( this.uniformBuffers.data[ 1 ], memory.uniformBuffers.toString() );
|
|
130
171
|
setText( this.uniformBuffers.data[ 2 ], formatBytes( memory.uniformBuffersSize ) );
|
|
131
172
|
|
|
173
|
+
// WITH_GENESYS
|
|
174
|
+
const heap = getJSHeapBytes();
|
|
175
|
+
|
|
176
|
+
if ( heap ) {
|
|
177
|
+
|
|
178
|
+
setText( this.jsHeapStats.data[ 2 ], formatBytes( heap.used ) );
|
|
179
|
+
setText( this.jsHeapAllocated.data[ 2 ], heap.total !== undefined ? formatBytes( heap.total ) : 'N/A' );
|
|
180
|
+
setText( this.jsHeapLimit.data[ 2 ], heap.limit !== undefined ? formatBytes( heap.limit ) : 'N/A' );
|
|
181
|
+
|
|
182
|
+
} else {
|
|
183
|
+
|
|
184
|
+
setText( this.jsHeapStats.data[ 2 ], 'Unsupported' );
|
|
185
|
+
setText( this.jsHeapAllocated.data[ 2 ], 'N/A' );
|
|
186
|
+
setText( this.jsHeapLimit.data[ 2 ], 'N/A' );
|
|
187
|
+
|
|
188
|
+
}
|
|
189
|
+
// !WITH_GENESYS
|
|
190
|
+
|
|
132
191
|
}
|
|
133
192
|
|
|
134
193
|
}
|
|
@@ -261,6 +261,12 @@ export class Profiler extends EventDispatcher {
|
|
|
261
261
|
<span class="toggle-text">
|
|
262
262
|
<span class="fps-counter">-</span>
|
|
263
263
|
<span class="fps-label">FPS</span>
|
|
264
|
+
<!-- WITH_GENESYS -->
|
|
265
|
+
<span class="gpu-counter" title="GPU memory (MB)">-</span>
|
|
266
|
+
<span class="gpu-label">GPU</span>
|
|
267
|
+
<span class="heap-counter" title="JS heap used (MB)">-</span>
|
|
268
|
+
<span class="heap-label">JS</span>
|
|
269
|
+
<!-- !WITH_GENESYS -->
|
|
264
270
|
</span>
|
|
265
271
|
<span class="toggle-icon">
|
|
266
272
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-device-ipad-horizontal-search"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M11.5 20h-6.5a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v5.5" /><path d="M9 17h2" /><path d="M18 18m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0" /><path d="M20.2 20.2l1.8 1.8" /></svg>
|
|
@@ -165,7 +165,10 @@ export class Style {
|
|
|
165
165
|
display: flex;
|
|
166
166
|
align-items: baseline;
|
|
167
167
|
padding: 8px 14px;
|
|
168
|
-
|
|
168
|
+
/* WITH_GENESYS */
|
|
169
|
+
min-width: 196px;
|
|
170
|
+
/* !WITH_GENESYS */
|
|
171
|
+
/* min-width: 80px; */
|
|
169
172
|
justify-content: right;
|
|
170
173
|
}
|
|
171
174
|
|
|
@@ -175,6 +178,20 @@ export class Style {
|
|
|
175
178
|
color: #999;
|
|
176
179
|
}
|
|
177
180
|
|
|
181
|
+
/* WITH_GENESYS */
|
|
182
|
+
.toggle-text .gpu-counter,
|
|
183
|
+
.toggle-text .heap-counter {
|
|
184
|
+
margin-left: 12px;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.toggle-text .gpu-label,
|
|
188
|
+
.toggle-text .heap-label {
|
|
189
|
+
font-size: 0.7em;
|
|
190
|
+
margin-left: 6px;
|
|
191
|
+
color: #999;
|
|
192
|
+
}
|
|
193
|
+
/* !WITH_GENESYS */
|
|
194
|
+
|
|
178
195
|
.builtin-tabs-container {
|
|
179
196
|
position: relative;
|
|
180
197
|
z-index: 1;
|
|
@@ -1237,6 +1254,41 @@ export class Style {
|
|
|
1237
1254
|
position: relative;
|
|
1238
1255
|
}
|
|
1239
1256
|
|
|
1257
|
+
/* WITH_GENESYS */
|
|
1258
|
+
.graph-caption {
|
|
1259
|
+
font-size: 11px;
|
|
1260
|
+
color: var(--text-secondary);
|
|
1261
|
+
margin-bottom: 4px;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
.graph-legend {
|
|
1265
|
+
display: flex;
|
|
1266
|
+
gap: 12px;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
.graph-legend-item {
|
|
1270
|
+
display: inline-flex;
|
|
1271
|
+
align-items: center;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
.graph-legend-item::before {
|
|
1275
|
+
content: '';
|
|
1276
|
+
display: inline-block;
|
|
1277
|
+
width: 8px;
|
|
1278
|
+
height: 8px;
|
|
1279
|
+
border-radius: 2px;
|
|
1280
|
+
margin-right: 6px;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
.graph-legend-gpu::before {
|
|
1284
|
+
background: var(--color-yellow);
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
.graph-legend-heap::before {
|
|
1288
|
+
background: var(--color-accent);
|
|
1289
|
+
}
|
|
1290
|
+
/* !WITH_GENESYS */
|
|
1291
|
+
|
|
1240
1292
|
.graph-svg, .graph-canvas {
|
|
1241
1293
|
width: 0;
|
|
1242
1294
|
min-width: 100%;
|
|
@@ -62,6 +62,127 @@ export function formatBytes( bytes, decimals = 2 ) {
|
|
|
62
62
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
// WITH_GENESYS
|
|
66
|
+
/**
|
|
67
|
+
* Best-effort JS / page memory sample for the inspector.
|
|
68
|
+
*
|
|
69
|
+
* Chromium exposes a sync V8 heap via `performance.memory`. The spec method
|
|
70
|
+
* `performance.measureUserAgentSpecificMemory()` is async, may include more
|
|
71
|
+
* than JS heap, and requires a cross-origin isolated document. Firefox and
|
|
72
|
+
* Safari do not expose JS heap size to web content as of 2026.
|
|
73
|
+
*
|
|
74
|
+
* @returns {{ used: number, total?: number, limit?: number } | null}
|
|
75
|
+
*/
|
|
76
|
+
let _specMemoryBytes = null;
|
|
77
|
+
let _specMemoryTimer = 0;
|
|
78
|
+
let _specMemorySampling = false;
|
|
79
|
+
|
|
80
|
+
function readPerformanceMemory() {
|
|
81
|
+
|
|
82
|
+
const memory = performance.memory;
|
|
83
|
+
|
|
84
|
+
if ( memory === undefined || typeof memory.usedJSHeapSize !== 'number' ) {
|
|
85
|
+
|
|
86
|
+
return null;
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
used: memory.usedJSHeapSize,
|
|
92
|
+
total: memory.totalJSHeapSize,
|
|
93
|
+
limit: memory.jsHeapSizeLimit
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function sampleSpecMemory() {
|
|
99
|
+
|
|
100
|
+
const measure = performance.measureUserAgentSpecificMemory;
|
|
101
|
+
|
|
102
|
+
if ( typeof measure !== 'function' ) {
|
|
103
|
+
|
|
104
|
+
return;
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
|
|
110
|
+
const result = await measure.call( performance );
|
|
111
|
+
|
|
112
|
+
if ( result && typeof result.bytes === 'number' ) {
|
|
113
|
+
|
|
114
|
+
_specMemoryBytes = result.bytes;
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
} catch {
|
|
119
|
+
|
|
120
|
+
// SecurityError when the document is not cross-origin isolated.
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function scheduleSpecMemorySample() {
|
|
127
|
+
|
|
128
|
+
if ( _specMemorySampling === false ) {
|
|
129
|
+
|
|
130
|
+
return;
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Spec guidance: poll on a randomized interval; the call may wait on GC.
|
|
135
|
+
_specMemoryTimer = setTimeout( () => {
|
|
136
|
+
|
|
137
|
+
sampleSpecMemory().finally( scheduleSpecMemorySample );
|
|
138
|
+
|
|
139
|
+
}, 8000 + Math.random() * 7000 );
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function startJSHeapSampling() {
|
|
144
|
+
|
|
145
|
+
if ( _specMemorySampling ) {
|
|
146
|
+
|
|
147
|
+
return;
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
_specMemorySampling = true;
|
|
152
|
+
sampleSpecMemory();
|
|
153
|
+
scheduleSpecMemorySample();
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function stopJSHeapSampling() {
|
|
158
|
+
|
|
159
|
+
_specMemorySampling = false;
|
|
160
|
+
clearTimeout( _specMemoryTimer );
|
|
161
|
+
_specMemoryTimer = 0;
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function getJSHeapBytes() {
|
|
166
|
+
|
|
167
|
+
const chromeHeap = readPerformanceMemory();
|
|
168
|
+
|
|
169
|
+
if ( chromeHeap ) {
|
|
170
|
+
|
|
171
|
+
return chromeHeap;
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if ( typeof _specMemoryBytes === 'number' ) {
|
|
176
|
+
|
|
177
|
+
return { used: _specMemoryBytes };
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return null;
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
// !WITH_GENESYS
|
|
185
|
+
|
|
65
186
|
export function info( parentNode, text ) {
|
|
66
187
|
|
|
67
188
|
let infoIcon = parentNode.querySelector( '.info-icon' );
|