@gnsx/three 0.186.1 → 0.186.3
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, getConsoleFunction, REVISION } from '@gnsx/three/webgpu';
|
|
14
21
|
|
|
@@ -24,6 +31,10 @@ class Inspector extends RendererInspector {
|
|
|
24
31
|
|
|
25
32
|
this.nonce = nonce;
|
|
26
33
|
|
|
34
|
+
// WITH_GENESYS
|
|
35
|
+
startJSHeapSampling();
|
|
36
|
+
// !WITH_GENESYS
|
|
37
|
+
|
|
27
38
|
// init profiler
|
|
28
39
|
|
|
29
40
|
const profiler = new Profiler( this, options );
|
|
@@ -589,6 +600,50 @@ class Inspector extends RendererInspector {
|
|
|
589
600
|
|
|
590
601
|
setText( this.profiler.toggleButton.querySelector( '.fps-counter' ), this.fps.toFixed() );
|
|
591
602
|
|
|
603
|
+
// WITH_GENESYS
|
|
604
|
+
const toggle = this.profiler.toggleButton;
|
|
605
|
+
const gpuCounter = toggle.querySelector( '.gpu-counter' );
|
|
606
|
+
const gpuLabel = toggle.querySelector( '.gpu-label' );
|
|
607
|
+
const heapCounter = toggle.querySelector( '.heap-counter' );
|
|
608
|
+
const heapLabel = toggle.querySelector( '.heap-label' );
|
|
609
|
+
const gpuBytes = this.getRenderer()?.info?.memory?.total;
|
|
610
|
+
const heap = getJSHeapBytes();
|
|
611
|
+
|
|
612
|
+
if ( gpuCounter ) {
|
|
613
|
+
|
|
614
|
+
if ( typeof gpuBytes === 'number' ) {
|
|
615
|
+
|
|
616
|
+
setText( gpuCounter, ( gpuBytes / ( 1024 * 1024 ) ).toFixed( 0 ) );
|
|
617
|
+
gpuCounter.style.display = '';
|
|
618
|
+
if ( gpuLabel ) gpuLabel.style.display = '';
|
|
619
|
+
|
|
620
|
+
} else {
|
|
621
|
+
|
|
622
|
+
gpuCounter.style.display = 'none';
|
|
623
|
+
if ( gpuLabel ) gpuLabel.style.display = 'none';
|
|
624
|
+
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
if ( heapCounter ) {
|
|
630
|
+
|
|
631
|
+
if ( heap ) {
|
|
632
|
+
|
|
633
|
+
setText( heapCounter, ( heap.used / ( 1024 * 1024 ) ).toFixed( 0 ) );
|
|
634
|
+
heapCounter.style.display = '';
|
|
635
|
+
if ( heapLabel ) heapLabel.style.display = '';
|
|
636
|
+
|
|
637
|
+
} else {
|
|
638
|
+
|
|
639
|
+
heapCounter.style.display = 'none';
|
|
640
|
+
if ( heapLabel ) heapLabel.style.display = 'none';
|
|
641
|
+
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
}
|
|
645
|
+
// !WITH_GENESYS
|
|
646
|
+
|
|
592
647
|
this.performance.updateText( this, frame );
|
|
593
648
|
this.memory.updateText( this );
|
|
594
649
|
|
|
@@ -633,6 +688,10 @@ class Inspector extends RendererInspector {
|
|
|
633
688
|
|
|
634
689
|
dispose() {
|
|
635
690
|
|
|
691
|
+
// WITH_GENESYS
|
|
692
|
+
stopJSHeapSampling();
|
|
693
|
+
// !WITH_GENESYS
|
|
694
|
+
|
|
636
695
|
super.dispose();
|
|
637
696
|
|
|
638
697
|
this.setRenderer( null );
|
|
@@ -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
|
}
|
|
@@ -85,6 +116,16 @@ class Memory extends Tab {
|
|
|
85
116
|
|
|
86
117
|
this.graph.addPoint( 'total', memory.total );
|
|
87
118
|
|
|
119
|
+
// WITH_GENESYS
|
|
120
|
+
const heap = getJSHeapBytes();
|
|
121
|
+
|
|
122
|
+
if ( heap ) {
|
|
123
|
+
|
|
124
|
+
this.graph.addPoint( 'jsHeap', heap.used );
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
// !WITH_GENESYS
|
|
128
|
+
|
|
88
129
|
if ( this.graph.limit === 0 ) this.graph.limit = 1;
|
|
89
130
|
|
|
90
131
|
this.graph.update();
|
|
@@ -127,6 +168,24 @@ class Memory extends Tab {
|
|
|
127
168
|
setText( this.uniformBuffers.data[ 1 ], memory.uniformBuffers.toString() );
|
|
128
169
|
setText( this.uniformBuffers.data[ 2 ], formatBytes( memory.uniformBuffersSize ) );
|
|
129
170
|
|
|
171
|
+
// WITH_GENESYS
|
|
172
|
+
const heap = getJSHeapBytes();
|
|
173
|
+
|
|
174
|
+
if ( heap ) {
|
|
175
|
+
|
|
176
|
+
setText( this.jsHeapStats.data[ 2 ], formatBytes( heap.used ) );
|
|
177
|
+
setText( this.jsHeapAllocated.data[ 2 ], heap.total !== undefined ? formatBytes( heap.total ) : 'N/A' );
|
|
178
|
+
setText( this.jsHeapLimit.data[ 2 ], heap.limit !== undefined ? formatBytes( heap.limit ) : 'N/A' );
|
|
179
|
+
|
|
180
|
+
} else {
|
|
181
|
+
|
|
182
|
+
setText( this.jsHeapStats.data[ 2 ], 'Unsupported' );
|
|
183
|
+
setText( this.jsHeapAllocated.data[ 2 ], 'N/A' );
|
|
184
|
+
setText( this.jsHeapLimit.data[ 2 ], 'N/A' );
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
// !WITH_GENESYS
|
|
188
|
+
|
|
130
189
|
}
|
|
131
190
|
|
|
132
191
|
}
|
|
@@ -271,6 +271,12 @@ export class Profiler extends EventDispatcher {
|
|
|
271
271
|
<span class="toggle-text">
|
|
272
272
|
<span class="fps-counter">-</span>
|
|
273
273
|
<span class="fps-label">FPS</span>
|
|
274
|
+
<!-- WITH_GENESYS -->
|
|
275
|
+
<span class="gpu-counter" title="GPU memory (MB)">-</span>
|
|
276
|
+
<span class="gpu-label">GPU</span>
|
|
277
|
+
<span class="heap-counter" title="JS heap used (MB)">-</span>
|
|
278
|
+
<span class="heap-label">JS</span>
|
|
279
|
+
<!-- !WITH_GENESYS -->
|
|
274
280
|
</span>
|
|
275
281
|
<span class="toggle-icon">
|
|
276
282
|
<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>
|
|
@@ -179,7 +179,10 @@ export class Style {
|
|
|
179
179
|
display: flex;
|
|
180
180
|
align-items: baseline;
|
|
181
181
|
padding: 8px 14px;
|
|
182
|
-
|
|
182
|
+
/* WITH_GENESYS */
|
|
183
|
+
min-width: 196px;
|
|
184
|
+
/* !WITH_GENESYS */
|
|
185
|
+
/* min-width: 80px; */
|
|
183
186
|
justify-content: right;
|
|
184
187
|
}
|
|
185
188
|
|
|
@@ -189,6 +192,20 @@ export class Style {
|
|
|
189
192
|
color: #999;
|
|
190
193
|
}
|
|
191
194
|
|
|
195
|
+
/* WITH_GENESYS */
|
|
196
|
+
.toggle-text .gpu-counter,
|
|
197
|
+
.toggle-text .heap-counter {
|
|
198
|
+
margin-left: 12px;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.toggle-text .gpu-label,
|
|
202
|
+
.toggle-text .heap-label {
|
|
203
|
+
font-size: 0.7em;
|
|
204
|
+
margin-left: 6px;
|
|
205
|
+
color: #999;
|
|
206
|
+
}
|
|
207
|
+
/* !WITH_GENESYS */
|
|
208
|
+
|
|
192
209
|
.builtin-tabs-container {
|
|
193
210
|
position: relative;
|
|
194
211
|
z-index: 1;
|
|
@@ -1251,6 +1268,41 @@ export class Style {
|
|
|
1251
1268
|
position: relative;
|
|
1252
1269
|
}
|
|
1253
1270
|
|
|
1271
|
+
/* WITH_GENESYS */
|
|
1272
|
+
.graph-caption {
|
|
1273
|
+
font-size: 11px;
|
|
1274
|
+
color: var(--text-secondary);
|
|
1275
|
+
margin-bottom: 4px;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
.graph-legend {
|
|
1279
|
+
display: flex;
|
|
1280
|
+
gap: 12px;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
.graph-legend-item {
|
|
1284
|
+
display: inline-flex;
|
|
1285
|
+
align-items: center;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
.graph-legend-item::before {
|
|
1289
|
+
content: '';
|
|
1290
|
+
display: inline-block;
|
|
1291
|
+
width: 8px;
|
|
1292
|
+
height: 8px;
|
|
1293
|
+
border-radius: 2px;
|
|
1294
|
+
margin-right: 6px;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
.graph-legend-gpu::before {
|
|
1298
|
+
background: var(--color-yellow);
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
.graph-legend-heap::before {
|
|
1302
|
+
background: var(--color-accent);
|
|
1303
|
+
}
|
|
1304
|
+
/* !WITH_GENESYS */
|
|
1305
|
+
|
|
1254
1306
|
.graph-svg, .graph-canvas {
|
|
1255
1307
|
width: 0;
|
|
1256
1308
|
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' );
|