@playcanvas/inspector 0.2.0 → 0.4.0
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.
- package/README.md +147 -5
- package/package.json +1 -1
- package/src/asset-view.js +24 -17
- package/src/camera-view.js +5 -3
- package/src/context-menu.js +231 -0
- package/src/copy-json.js +692 -0
- package/src/describe.js +20 -1
- package/src/entity-inspector-script.js +10 -0
- package/src/frame-graph-view.js +41 -9
- package/src/hierarchy-view.js +29 -3
- package/src/inspector.js +958 -80
- package/src/list-view.js +118 -12
- package/src/material-view.js +7 -6
- package/src/memory-view.js +224 -66
- package/src/mesh-view.js +6 -5
- package/src/model.js +24 -2
- package/src/node-model.js +81 -11
- package/src/perf-capture.js +2034 -0
- package/src/perf-chart.js +3989 -0
- package/src/perf-copy.js +367 -0
- package/src/perf-view.js +1224 -0
- package/src/property-view.js +162 -5
- package/src/render-target-view.js +3 -3
- package/src/script-view.js +21 -12
- package/src/styles.js +374 -2
- package/src/texture-view.js +4 -4
- package/src/transform-tool.js +185 -0
- package/types/asset-view.d.ts +3 -1
- package/types/camera-view.d.ts +4 -0
- package/types/context-menu.d.ts +90 -0
- package/types/copy-json.d.ts +69 -0
- package/types/describe.d.ts +1 -1
- package/types/entity-inspector-script.d.ts +8 -0
- package/types/frame-graph-view.d.ts +7 -0
- package/types/hierarchy-view.d.ts +13 -0
- package/types/inspector.d.ts +339 -25
- package/types/list-view.d.ts +44 -3
- package/types/material-view.d.ts +3 -1
- package/types/memory-view.d.ts +24 -25
- package/types/mesh-view.d.ts +3 -1
- package/types/model.d.ts +16 -1
- package/types/node-model.d.ts +17 -1
- package/types/perf-capture.d.ts +871 -0
- package/types/perf-chart.d.ts +1407 -0
- package/types/perf-copy.d.ts +61 -0
- package/types/perf-view.d.ts +231 -0
- package/types/property-view.d.ts +41 -0
- package/types/script-view.d.ts +3 -1
- package/types/transform-tool.d.ts +92 -0
|
@@ -0,0 +1,871 @@
|
|
|
1
|
+
export type PerfEvent = object;
|
|
2
|
+
export type PerfBake = object;
|
|
3
|
+
export type PerfScript = object;
|
|
4
|
+
export type PerfLoad = object;
|
|
5
|
+
export type PerfPass = object;
|
|
6
|
+
export type PerfGpuPass = object;
|
|
7
|
+
/** @import { AppBase, Asset, GraphicsDevice } from 'playcanvas' */
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {object} PerfEvent
|
|
10
|
+
* @ignore
|
|
11
|
+
* @property {'long'|'marker'|'bake'} kind - What happened: the browser reported a long animation
|
|
12
|
+
* frame, the app measured a span with `performance.measure`, or the lightmapper baked lightmaps.
|
|
13
|
+
* @property {string} name - What it was: the script that ran longest, the measure, or the bake.
|
|
14
|
+
* @property {number} start - When it started, as a `performance.now()` time.
|
|
15
|
+
* @property {number} duration - How long it took in milliseconds, zero for an instant.
|
|
16
|
+
* @property {string} [detail] - More about it, such as the blocking time of a long frame.
|
|
17
|
+
* @property {PerfBake} [bake] - The figures of a bake of lightmaps.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {object} PerfBake
|
|
21
|
+
* @ignore
|
|
22
|
+
* @property {number} lightmaps - How many lightmaps it baked.
|
|
23
|
+
* @property {number} passes - How many render passes it took.
|
|
24
|
+
* @property {number} targets - The time creating render targets, in milliseconds.
|
|
25
|
+
* @property {number} shaders - How many shaders it linked.
|
|
26
|
+
* @property {number} compile - The time compiling and linking them.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {object} PerfScript
|
|
30
|
+
* @ignore
|
|
31
|
+
* @property {number} id - Its index into {@link PerfCapture#scriptNames}.
|
|
32
|
+
* @property {string} name - The name the script type is registered under.
|
|
33
|
+
* @property {number} update - Its own time in its update, in milliseconds.
|
|
34
|
+
* @property {number} post - Its own time in its post-update.
|
|
35
|
+
* @property {number} init - Its own time initializing and post-initializing, as new instances do,
|
|
36
|
+
* and swapping in when hot-reloaded.
|
|
37
|
+
* @property {number} calls - How many of its methods were called.
|
|
38
|
+
* @property {number} updateCalls - How many times its update was called, once an instance.
|
|
39
|
+
* @property {number} postCalls - How many times its post-update was called.
|
|
40
|
+
* @property {number} initCalls - How many times it was initialized, post-initialized or swapped.
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {object} PerfLoad
|
|
44
|
+
* @ignore
|
|
45
|
+
* @property {'asset'|'request'|'milestone'} kind - What it is: an asset loading, a request the
|
|
46
|
+
* page made, or a moment of the app or the page, such as its first paint.
|
|
47
|
+
* @property {string} name - The asset, the file requested, or the moment.
|
|
48
|
+
* @property {number} start - When it began, as a `performance.now()` time; NaN for an asset that
|
|
49
|
+
* began loading before recording did.
|
|
50
|
+
* @property {number} end - When it ended; the same as its start for a moment.
|
|
51
|
+
* @property {string} [type] - The type of an asset.
|
|
52
|
+
* @property {number} [id] - The id of an asset.
|
|
53
|
+
* @property {boolean} [failed] - Whether an asset failed to load.
|
|
54
|
+
* @property {number} [netStart] - When the request of an asset or a request began on the network.
|
|
55
|
+
* @property {number} [netEnd] - When its last byte arrived.
|
|
56
|
+
* @property {number} [firstByte] - When its first byte arrived.
|
|
57
|
+
* @property {number} [bytes] - Its size over the network, the size of the file where it came
|
|
58
|
+
* from the cache.
|
|
59
|
+
* @property {boolean} [cached] - Whether it came from the cache.
|
|
60
|
+
* @property {string} [url] - The file requested.
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* @typedef {object} PerfPass
|
|
64
|
+
* @ignore
|
|
65
|
+
* @property {string} name - The profiler name of the pass. Passes sharing a name are summed.
|
|
66
|
+
* @property {number} time - Its GPU time in milliseconds.
|
|
67
|
+
*/
|
|
68
|
+
/**
|
|
69
|
+
* @typedef {object} PerfGpuPass
|
|
70
|
+
* @ignore
|
|
71
|
+
* @property {string} name - The profiler name of the pass.
|
|
72
|
+
* @property {number} time - Its GPU time in milliseconds.
|
|
73
|
+
* @property {string|null} owner - The profiler name of the effect running it, the pass of the
|
|
74
|
+
* frame graph it is a before or after pass of, or null for a pass of its own.
|
|
75
|
+
* @property {number} occurrence - Which of the passes of the frame graph with its name it is, 0
|
|
76
|
+
* for the first, or -1 where it was not matched to one.
|
|
77
|
+
* @property {number} ownerOccurrence - Which of the passes with its owner's name its owner is,
|
|
78
|
+
* or -1.
|
|
79
|
+
*/
|
|
80
|
+
/**
|
|
81
|
+
* How many frames a capture keeps, about 17 seconds at 60 Hz: few enough that the charts show
|
|
82
|
+
* them without squeezing many frames into each pixel. The oldest frames make way once it is full.
|
|
83
|
+
*/
|
|
84
|
+
export const CAPTURE_FRAMES: 1000;
|
|
85
|
+
/**
|
|
86
|
+
* The figures recorded for every frame, each in a ring of its own. Durations are in milliseconds,
|
|
87
|
+
* timestamps are `performance.now()` times, memory is in bytes and a figure the engine did not
|
|
88
|
+
* provide is NaN.
|
|
89
|
+
*
|
|
90
|
+
* @type {string[]}
|
|
91
|
+
*/
|
|
92
|
+
export const CHANNELS: string[];
|
|
93
|
+
export const ENTRY_STARTUP: 1;
|
|
94
|
+
/**
|
|
95
|
+
* Records the performance of an app frame by frame, while asked to, into rings holding the last
|
|
96
|
+
* {@link CAPTURE_FRAMES} frames. A frame is recorded in two steps: its CPU timings when its work
|
|
97
|
+
* ends, and its frame interval and the counters of the work it submitted as the next frame begins,
|
|
98
|
+
* when the engine publishes them. GPU timings resolve a few frames later still and are matched to
|
|
99
|
+
* their frame by the render version they describe. Frames are numbered by sequence from the last
|
|
100
|
+
* clear, so a number stays put while older frames make way.
|
|
101
|
+
*
|
|
102
|
+
* Nothing is hooked into the app while not recording.
|
|
103
|
+
*
|
|
104
|
+
* @ignore
|
|
105
|
+
*/
|
|
106
|
+
export class PerfCapture {
|
|
107
|
+
/**
|
|
108
|
+
* @param {PerfLoad} asset - An asset load.
|
|
109
|
+
* @param {PerfLoad} request - The request of its file.
|
|
110
|
+
* @private
|
|
111
|
+
*/
|
|
112
|
+
private static _linkRequest;
|
|
113
|
+
/**
|
|
114
|
+
* @param {AppBase} app - The app to record.
|
|
115
|
+
* @param {number} [capacity] - How many frames to keep. Defaults to {@link CAPTURE_FRAMES}.
|
|
116
|
+
*/
|
|
117
|
+
constructor(app: AppBase, capacity?: number);
|
|
118
|
+
/**
|
|
119
|
+
* The rings, one per channel of {@link CHANNELS}, indexed by {@link slot}.
|
|
120
|
+
*
|
|
121
|
+
* @type {Record<string, Float64Array>}
|
|
122
|
+
*/
|
|
123
|
+
data: Record<string, Float64Array>;
|
|
124
|
+
/**
|
|
125
|
+
* How many frames are kept.
|
|
126
|
+
*
|
|
127
|
+
* @type {number}
|
|
128
|
+
*/
|
|
129
|
+
capacity: number;
|
|
130
|
+
/**
|
|
131
|
+
* Whether the engine publishes the render phase timings and the breakdown of the draw calls:
|
|
132
|
+
* the profiler and debug engines do.
|
|
133
|
+
*
|
|
134
|
+
* @type {boolean}
|
|
135
|
+
*/
|
|
136
|
+
detailed: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Bumped whenever the recorded data changes, so a view can tell when to redraw.
|
|
139
|
+
*
|
|
140
|
+
* @type {number}
|
|
141
|
+
*/
|
|
142
|
+
version: number;
|
|
143
|
+
/**
|
|
144
|
+
* The names of the GPU passes seen, indexed by the ids the frames keep.
|
|
145
|
+
*
|
|
146
|
+
* @type {string[]}
|
|
147
|
+
*/
|
|
148
|
+
names: string[];
|
|
149
|
+
/**
|
|
150
|
+
* Whether the GPU timings come with the frame they describe, so each lands on its own frame.
|
|
151
|
+
* Older engines leave it to the newest frame when the timings change, a few frames late.
|
|
152
|
+
*
|
|
153
|
+
* @type {boolean}
|
|
154
|
+
*/
|
|
155
|
+
gpuExact: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* What the browser, the device and the app report: long animation frames, the spans measured by
|
|
158
|
+
* the app, the size of the JavaScript heap, the pipelines created, which only WebGPU has, the
|
|
159
|
+
* calls of scripts, which an app without a script system has none of, the counters of
|
|
160
|
+
* `app.stats.user`, which engines before 2.24 have none of, and the bakes of the lightmapper,
|
|
161
|
+
* which an app without one has none of.
|
|
162
|
+
*
|
|
163
|
+
* @type {{ longFrames: boolean, measures: boolean, heap: boolean, pipelines: boolean, scripts: boolean, counters: boolean, lightmapper: boolean }}
|
|
164
|
+
*/
|
|
165
|
+
supports: {
|
|
166
|
+
longFrames: boolean;
|
|
167
|
+
measures: boolean;
|
|
168
|
+
heap: boolean;
|
|
169
|
+
pipelines: boolean;
|
|
170
|
+
scripts: boolean;
|
|
171
|
+
counters: boolean;
|
|
172
|
+
lightmapper: boolean;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* The names of the script types timed, indexed by the ids the frames keep.
|
|
176
|
+
*
|
|
177
|
+
* @type {string[]}
|
|
178
|
+
*/
|
|
179
|
+
scriptNames: string[];
|
|
180
|
+
/**
|
|
181
|
+
* The names of the counters the app keeps in `app.stats.user`, indexed by the ids of
|
|
182
|
+
* {@link PerfCapture#counterRings}, in the order the app first set them.
|
|
183
|
+
*
|
|
184
|
+
* @type {string[]}
|
|
185
|
+
*/
|
|
186
|
+
counterNames: string[];
|
|
187
|
+
/**
|
|
188
|
+
* The value of each counter as each frame ended, a ring of {@link PerfCapture#slots} each,
|
|
189
|
+
* NaN in a frame the app did not set it in.
|
|
190
|
+
*
|
|
191
|
+
* @type {Float64Array[]}
|
|
192
|
+
*/
|
|
193
|
+
counterRings: Float64Array[];
|
|
194
|
+
/**
|
|
195
|
+
* @type {Map<string, number>}
|
|
196
|
+
* @private
|
|
197
|
+
*/
|
|
198
|
+
private _counterIds;
|
|
199
|
+
/**
|
|
200
|
+
* The slot the counters are being taken into.
|
|
201
|
+
*
|
|
202
|
+
* @type {number}
|
|
203
|
+
* @private
|
|
204
|
+
*/
|
|
205
|
+
private _counterSlot;
|
|
206
|
+
/**
|
|
207
|
+
* The batcher's time creating batches as the last frame ended, so a frame takes what it
|
|
208
|
+
* created.
|
|
209
|
+
*
|
|
210
|
+
* @type {number}
|
|
211
|
+
* @private
|
|
212
|
+
*/
|
|
213
|
+
private _batchCreated;
|
|
214
|
+
/**
|
|
215
|
+
* When the lightmapper began the bake in progress, NaN while none is.
|
|
216
|
+
*
|
|
217
|
+
* @type {number}
|
|
218
|
+
* @private
|
|
219
|
+
*/
|
|
220
|
+
private _bakeStart;
|
|
221
|
+
/**
|
|
222
|
+
* The class of each script type timed, by the same ids: the one it last ran as, as a
|
|
223
|
+
* hot-reloaded script swaps in a new class under the same name.
|
|
224
|
+
*
|
|
225
|
+
* @type {Function[]}
|
|
226
|
+
*/
|
|
227
|
+
scriptClasses: Function[];
|
|
228
|
+
/**
|
|
229
|
+
* The estimated cost of timing a script call in milliseconds, NaN until scripts are first
|
|
230
|
+
* timed.
|
|
231
|
+
*
|
|
232
|
+
* @type {number}
|
|
233
|
+
*/
|
|
234
|
+
callCost: number;
|
|
235
|
+
/**
|
|
236
|
+
* The smallest step the clock moves by in milliseconds, which the times of single calls are
|
|
237
|
+
* made of, NaN until scripts are first timed.
|
|
238
|
+
*
|
|
239
|
+
* @type {number}
|
|
240
|
+
*/
|
|
241
|
+
clockStep: number;
|
|
242
|
+
/**
|
|
243
|
+
* @type {AppBase}
|
|
244
|
+
* @private
|
|
245
|
+
*/
|
|
246
|
+
private _app;
|
|
247
|
+
/**
|
|
248
|
+
* One slot more than {@link capacity}, for the frame being recorded.
|
|
249
|
+
*
|
|
250
|
+
* @private
|
|
251
|
+
*/
|
|
252
|
+
private _slots;
|
|
253
|
+
/**
|
|
254
|
+
* The sequence number the frame being recorded gets once complete.
|
|
255
|
+
*
|
|
256
|
+
* @private
|
|
257
|
+
*/
|
|
258
|
+
private _end;
|
|
259
|
+
/** @private */
|
|
260
|
+
private _recording;
|
|
261
|
+
/**
|
|
262
|
+
* Whether the frame in the next slot has begun, and whether its work has ended.
|
|
263
|
+
*
|
|
264
|
+
* @private
|
|
265
|
+
*/
|
|
266
|
+
private _begun;
|
|
267
|
+
/** @private */
|
|
268
|
+
private _ended;
|
|
269
|
+
/**
|
|
270
|
+
* The render version of the last frame recorded, to tell a frame that rendered nothing.
|
|
271
|
+
*
|
|
272
|
+
* @private
|
|
273
|
+
*/
|
|
274
|
+
private _lastVersion;
|
|
275
|
+
/**
|
|
276
|
+
* The render version of the last GPU timings taken, or their frame time on older engines.
|
|
277
|
+
*
|
|
278
|
+
* @private
|
|
279
|
+
*/
|
|
280
|
+
private _gpuSeen;
|
|
281
|
+
/**
|
|
282
|
+
* @type {Map<string, number>}
|
|
283
|
+
* @private
|
|
284
|
+
*/
|
|
285
|
+
private _nameIds;
|
|
286
|
+
/**
|
|
287
|
+
* The GPU passes of each slot in the order they ran, {@link PASS_STRIDE} figures each, written
|
|
288
|
+
* in place as the ring turns over, so recording makes no garbage; {@link _passCounts} says how
|
|
289
|
+
* many of them the slot has.
|
|
290
|
+
*
|
|
291
|
+
* @type {number[][]}
|
|
292
|
+
* @private
|
|
293
|
+
*/
|
|
294
|
+
private _passFigures;
|
|
295
|
+
/**
|
|
296
|
+
* @type {number[]}
|
|
297
|
+
* @private
|
|
298
|
+
*/
|
|
299
|
+
private _passCounts;
|
|
300
|
+
/**
|
|
301
|
+
* The owners last matched to the timed passes, by the names of the passes of the frame graph
|
|
302
|
+
* and of the timed passes they were matched for. The frame graph rarely changes, though some
|
|
303
|
+
* of its passes are made anew every frame, so most frames reuse them.
|
|
304
|
+
*
|
|
305
|
+
* @private
|
|
306
|
+
*/
|
|
307
|
+
private _match;
|
|
308
|
+
/**
|
|
309
|
+
* The events of each slot, null for the many frames without any.
|
|
310
|
+
*
|
|
311
|
+
* @type {(PerfEvent[]|null)[]}
|
|
312
|
+
* @private
|
|
313
|
+
*/
|
|
314
|
+
private _events;
|
|
315
|
+
/**
|
|
316
|
+
* The loads of each slot, those that ended in its entry, null for the many without any.
|
|
317
|
+
*
|
|
318
|
+
* @type {(PerfLoad[]|null)[]}
|
|
319
|
+
* @private
|
|
320
|
+
*/
|
|
321
|
+
private _loads;
|
|
322
|
+
/**
|
|
323
|
+
* The assets loading, by id, from when they began: they go to the entry they end in.
|
|
324
|
+
*
|
|
325
|
+
* @type {Map<number, PerfLoad>}
|
|
326
|
+
* @private
|
|
327
|
+
*/
|
|
328
|
+
private _pending;
|
|
329
|
+
/**
|
|
330
|
+
* Whether the entry being recorded is the start of the app: the inspector began recording
|
|
331
|
+
* before the app ran its first frame.
|
|
332
|
+
*
|
|
333
|
+
* @private
|
|
334
|
+
*/
|
|
335
|
+
private _startup;
|
|
336
|
+
/**
|
|
337
|
+
* The latest request of each file, by URL, and the assets that ended loading before the
|
|
338
|
+
* browser reported the request of their file, which it does a little later: each is linked
|
|
339
|
+
* to the other as the second of them comes.
|
|
340
|
+
*
|
|
341
|
+
* @private
|
|
342
|
+
*/
|
|
343
|
+
private _requests;
|
|
344
|
+
/** @private */
|
|
345
|
+
private _awaitingRequest;
|
|
346
|
+
/**
|
|
347
|
+
* Whether the capture began with the start of the app, so its frames count from the one after.
|
|
348
|
+
*
|
|
349
|
+
* @type {boolean}
|
|
350
|
+
*/
|
|
351
|
+
startedAtStartup: boolean;
|
|
352
|
+
/**
|
|
353
|
+
* The slot the GPU timings being taken go to.
|
|
354
|
+
*
|
|
355
|
+
* @private
|
|
356
|
+
*/
|
|
357
|
+
private _gpuSlot;
|
|
358
|
+
/**
|
|
359
|
+
* Whether to time scripts while recording.
|
|
360
|
+
*
|
|
361
|
+
* @private
|
|
362
|
+
*/
|
|
363
|
+
private _timeScripts;
|
|
364
|
+
/**
|
|
365
|
+
* Puts back the engine's own way of calling script methods, while scripts are timed.
|
|
366
|
+
*
|
|
367
|
+
* @type {(() => void)|null}
|
|
368
|
+
* @private
|
|
369
|
+
*/
|
|
370
|
+
private _unhook;
|
|
371
|
+
/**
|
|
372
|
+
* @type {Map<string, number>}
|
|
373
|
+
* @private
|
|
374
|
+
*/
|
|
375
|
+
private _scriptIds;
|
|
376
|
+
/**
|
|
377
|
+
* The figures of each script type of each slot, {@link SCRIPT_STRIDE} per type by id, reused
|
|
378
|
+
* as the ring turns over and grown as new types appear. Single precision, which times to well
|
|
379
|
+
* under a microsecond, as an app can have hundreds of types.
|
|
380
|
+
*
|
|
381
|
+
* @type {Float32Array[]}
|
|
382
|
+
* @private
|
|
383
|
+
*/
|
|
384
|
+
private _scriptTimes;
|
|
385
|
+
/**
|
|
386
|
+
* How many script types have had their first update, and their first post-update, in the frame
|
|
387
|
+
* being recorded.
|
|
388
|
+
*
|
|
389
|
+
* @private
|
|
390
|
+
*/
|
|
391
|
+
private _scriptOrder;
|
|
392
|
+
/**
|
|
393
|
+
* How deep the script call under way is nested in others, as a script creating an entity
|
|
394
|
+
* initializes its scripts within its own call; the time of the calls nested in it so far; and
|
|
395
|
+
* the phase the outermost call is in: 0 the update, 1 the post-update, 2 anywhere else.
|
|
396
|
+
*
|
|
397
|
+
* @private
|
|
398
|
+
*/
|
|
399
|
+
private _depth;
|
|
400
|
+
/** @private */
|
|
401
|
+
private _nested;
|
|
402
|
+
/** @private */
|
|
403
|
+
private _phase;
|
|
404
|
+
/**
|
|
405
|
+
* The script calls of the frame being recorded in each phase, for the cost of timing them.
|
|
406
|
+
*
|
|
407
|
+
* @private
|
|
408
|
+
*/
|
|
409
|
+
private _phaseCalls;
|
|
410
|
+
/**
|
|
411
|
+
* Whether calls are being timed to measure their cost, rather than for the frame.
|
|
412
|
+
*
|
|
413
|
+
* @private
|
|
414
|
+
*/
|
|
415
|
+
private _probing;
|
|
416
|
+
/** @private */
|
|
417
|
+
private _compileStart;
|
|
418
|
+
/** @private */
|
|
419
|
+
private _linkStart;
|
|
420
|
+
/**
|
|
421
|
+
* @type {PerformanceObserver[]}
|
|
422
|
+
* @private
|
|
423
|
+
*/
|
|
424
|
+
private _observers;
|
|
425
|
+
/**
|
|
426
|
+
* Stops recording and lets go of the app.
|
|
427
|
+
*/
|
|
428
|
+
destroy(): void;
|
|
429
|
+
/**
|
|
430
|
+
* Whether frames are being recorded.
|
|
431
|
+
*
|
|
432
|
+
* @type {boolean}
|
|
433
|
+
*/
|
|
434
|
+
get recording(): boolean;
|
|
435
|
+
/**
|
|
436
|
+
* Whether to time each script type while recording: every method of a script the engine calls
|
|
437
|
+
* is timed, which costs the app about half a microsecond a call, counted as the inspector's
|
|
438
|
+
* time. A frame recorded while it is off has no script times.
|
|
439
|
+
*
|
|
440
|
+
* @type {boolean}
|
|
441
|
+
*/
|
|
442
|
+
set timeScripts(on: boolean);
|
|
443
|
+
get timeScripts(): boolean;
|
|
444
|
+
/**
|
|
445
|
+
* The length of the rings of {@link data}: {@link slot} is a frame's sequence number modulo
|
|
446
|
+
* this.
|
|
447
|
+
*
|
|
448
|
+
* @type {number}
|
|
449
|
+
*/
|
|
450
|
+
get slots(): number;
|
|
451
|
+
/**
|
|
452
|
+
* The sequence number of the oldest frame kept.
|
|
453
|
+
*
|
|
454
|
+
* @type {number}
|
|
455
|
+
*/
|
|
456
|
+
get first(): number;
|
|
457
|
+
/**
|
|
458
|
+
* One past the sequence number of the newest complete frame.
|
|
459
|
+
*
|
|
460
|
+
* @type {number}
|
|
461
|
+
*/
|
|
462
|
+
get end(): number;
|
|
463
|
+
/**
|
|
464
|
+
* How many complete frames are kept.
|
|
465
|
+
*
|
|
466
|
+
* @type {number}
|
|
467
|
+
*/
|
|
468
|
+
get count(): number;
|
|
469
|
+
/**
|
|
470
|
+
* Starts recording, adding to the frames kept. The frame in progress is left out, as its start
|
|
471
|
+
* was missed.
|
|
472
|
+
*/
|
|
473
|
+
start(): void;
|
|
474
|
+
/**
|
|
475
|
+
* Stops recording, keeping the frames recorded. The frame in progress is dropped.
|
|
476
|
+
*/
|
|
477
|
+
stop(): void;
|
|
478
|
+
/**
|
|
479
|
+
* Forgets every frame, and numbers the next one zero.
|
|
480
|
+
*/
|
|
481
|
+
clear(): void;
|
|
482
|
+
/**
|
|
483
|
+
* @param {number} seq - The sequence number of a frame.
|
|
484
|
+
* @returns {boolean} Whether that frame is kept.
|
|
485
|
+
*/
|
|
486
|
+
has(seq: number): boolean;
|
|
487
|
+
/**
|
|
488
|
+
* @param {number} seq - The sequence number of a kept frame.
|
|
489
|
+
* @returns {number} Its index into the rings of {@link data}.
|
|
490
|
+
*/
|
|
491
|
+
slot(seq: number): number;
|
|
492
|
+
/**
|
|
493
|
+
* @param {string} key - A channel of {@link CHANNELS}.
|
|
494
|
+
* @param {number} seq - The sequence number of a kept frame.
|
|
495
|
+
* @returns {number} Its figure.
|
|
496
|
+
*/
|
|
497
|
+
get(key: string, seq: number): number;
|
|
498
|
+
/**
|
|
499
|
+
* @param {number} seq - The sequence number of a kept frame.
|
|
500
|
+
* @returns {PerfPass[]} The GPU passes of the frame, longest first, empty until its timings
|
|
501
|
+
* resolve.
|
|
502
|
+
*/
|
|
503
|
+
passes(seq: number): PerfPass[];
|
|
504
|
+
/**
|
|
505
|
+
* @param {number} seq - The sequence number of a kept frame.
|
|
506
|
+
* @returns {PerfGpuPass[]} The GPU passes of the frame in the order they ran, each apart, with
|
|
507
|
+
* the effect running it where the frame graph says. An engine whose profiler sums the passes
|
|
508
|
+
* sharing a name gives one for each name.
|
|
509
|
+
*/
|
|
510
|
+
passesInOrder(seq: number): PerfGpuPass[];
|
|
511
|
+
/**
|
|
512
|
+
* @param {number} seq - The sequence number of a kept frame.
|
|
513
|
+
* @returns {PerfScript[]} The script types whose methods were called in the frame, with their
|
|
514
|
+
* own times, the longest first; empty for a frame scripts were not timed in.
|
|
515
|
+
*/
|
|
516
|
+
scripts(seq: number): PerfScript[];
|
|
517
|
+
/**
|
|
518
|
+
* @param {number} seq - The sequence number of a kept frame.
|
|
519
|
+
* @returns {Float32Array|null} The figures of each script type in the frame,
|
|
520
|
+
* {@link SCRIPT_STRIDE} a type by its index into {@link scriptNames}: its own update,
|
|
521
|
+
* post-update and initialize time, how many times each was called, and the order of its first
|
|
522
|
+
* update and post-update among the types'. A type past the end of it had none. Null for a
|
|
523
|
+
* frame scripts were not timed in. Read only.
|
|
524
|
+
*/
|
|
525
|
+
scriptFigures(seq: number): Float32Array | null;
|
|
526
|
+
/**
|
|
527
|
+
* @param {number} seq - The sequence number of a kept frame.
|
|
528
|
+
* @param {number} id - A script type, by its index into {@link scriptNames}.
|
|
529
|
+
* @returns {number} The type's own time in the frame, zero when none of its methods were
|
|
530
|
+
* called, NaN when scripts were not timed in it.
|
|
531
|
+
*/
|
|
532
|
+
scriptTime(seq: number, id: number): number;
|
|
533
|
+
/**
|
|
534
|
+
* @param {number} seq - The sequence number of a kept frame.
|
|
535
|
+
* @returns {readonly PerfEvent[]} What happened during the frame.
|
|
536
|
+
*/
|
|
537
|
+
events(seq: number): readonly PerfEvent[];
|
|
538
|
+
/**
|
|
539
|
+
* @param {number} seq - The sequence number of a kept entry.
|
|
540
|
+
* @returns {readonly PerfLoad[]} What finished loading in the entry, and the moments in it.
|
|
541
|
+
*/
|
|
542
|
+
loads(seq: number): readonly PerfLoad[];
|
|
543
|
+
/**
|
|
544
|
+
* @returns {PerfLoad[]} The assets loading now, which have not ended yet.
|
|
545
|
+
*/
|
|
546
|
+
pendingLoads(): PerfLoad[];
|
|
547
|
+
/**
|
|
548
|
+
* @param {number} seq - The sequence number of an entry.
|
|
549
|
+
* @returns {number} The number of the frame it is, counting from 1: from the frame after the
|
|
550
|
+
* start of the app, where the capture began with it. It stays as frames make way.
|
|
551
|
+
*/
|
|
552
|
+
frameNumber(seq: number): number;
|
|
553
|
+
/**
|
|
554
|
+
* @param {number} seq - The sequence number of a kept entry.
|
|
555
|
+
* @returns {string} What it is called: Startup, or Frame and its number.
|
|
556
|
+
*/
|
|
557
|
+
label(seq: number): string;
|
|
558
|
+
/**
|
|
559
|
+
* @param {number} from - The first kept entry.
|
|
560
|
+
* @param {number} to - The last, inclusive.
|
|
561
|
+
* @returns {string} What they are called together, as Frames 3–40, or Startup to frame 40.
|
|
562
|
+
*/
|
|
563
|
+
rangeLabel(from: number, to: number): string;
|
|
564
|
+
/**
|
|
565
|
+
* @param {number} seq - The sequence number of a kept entry.
|
|
566
|
+
* @returns {boolean} Whether it is the start of the app rather than a frame.
|
|
567
|
+
*/
|
|
568
|
+
isStartup(seq: number): boolean;
|
|
569
|
+
/**
|
|
570
|
+
* Where the kept entries begin on the time axis, in milliseconds.
|
|
571
|
+
*
|
|
572
|
+
* @type {number}
|
|
573
|
+
*/
|
|
574
|
+
get startPos(): number;
|
|
575
|
+
/**
|
|
576
|
+
* Where the kept entries end on the time axis, in milliseconds.
|
|
577
|
+
*
|
|
578
|
+
* @type {number}
|
|
579
|
+
*/
|
|
580
|
+
get endPos(): number;
|
|
581
|
+
/**
|
|
582
|
+
* @param {number} pos - A place on the time axis.
|
|
583
|
+
* @returns {number} The kept entry there or before it, the first one before them all, or -1
|
|
584
|
+
* while none is kept.
|
|
585
|
+
*/
|
|
586
|
+
seqAtPos(pos: number): number;
|
|
587
|
+
/**
|
|
588
|
+
* @param {number} time - A `performance.now()` time.
|
|
589
|
+
* @returns {number} Where it is on the time axis: within the entry it falls in, in proportion
|
|
590
|
+
* across a folded gap, and before the first kept entry at its start.
|
|
591
|
+
*/
|
|
592
|
+
posAt(time: number): number;
|
|
593
|
+
/**
|
|
594
|
+
* Counts time the inspector spent inside the frame being recorded, so it can be told apart from
|
|
595
|
+
* the app's own.
|
|
596
|
+
*
|
|
597
|
+
* @param {number} start - When the inspector's work began, as a `performance.now()` time.
|
|
598
|
+
* @param {number} duration - How long it took in milliseconds.
|
|
599
|
+
*/
|
|
600
|
+
addOverhead(start: number, duration: number): void;
|
|
601
|
+
/**
|
|
602
|
+
* @param {string} type - A performance entry type.
|
|
603
|
+
* @param {(list: PerformanceObserverEntryList) => void} callback - Takes the entries.
|
|
604
|
+
* @param {boolean} [buffered] - Whether to take the entries the browser kept from before too.
|
|
605
|
+
* @private
|
|
606
|
+
*/
|
|
607
|
+
private _observe;
|
|
608
|
+
/**
|
|
609
|
+
* The next frame begins: the previous one is complete now that the engine has published the
|
|
610
|
+
* counters of the work it submitted.
|
|
611
|
+
*
|
|
612
|
+
* @private
|
|
613
|
+
*/
|
|
614
|
+
private _onFrameUpdate;
|
|
615
|
+
/**
|
|
616
|
+
* Begins the entry of the start of the app, from when the page opened. Takes what the browser
|
|
617
|
+
* kept from before recording began: the requests of the page and its milestones.
|
|
618
|
+
*
|
|
619
|
+
* @private
|
|
620
|
+
*/
|
|
621
|
+
private _beginStartup;
|
|
622
|
+
/**
|
|
623
|
+
* Ends the entry of the start of the app, as its first frame begins.
|
|
624
|
+
*
|
|
625
|
+
* @param {number} now - When the first frame began.
|
|
626
|
+
* @private
|
|
627
|
+
*/
|
|
628
|
+
private _endStartup;
|
|
629
|
+
/**
|
|
630
|
+
* @param {number} now - When the frame began.
|
|
631
|
+
* @private
|
|
632
|
+
*/
|
|
633
|
+
private _begin;
|
|
634
|
+
/**
|
|
635
|
+
* The work of the frame has ended: takes its CPU timings, and memory and resources as it left
|
|
636
|
+
* them.
|
|
637
|
+
*
|
|
638
|
+
* @private
|
|
639
|
+
*/
|
|
640
|
+
private _onFrameEnd;
|
|
641
|
+
/**
|
|
642
|
+
* Completes the frame being recorded with its interval, which ends now, and the counters the
|
|
643
|
+
* engine has just published for it.
|
|
644
|
+
*
|
|
645
|
+
* @param {number} now - When the next frame began.
|
|
646
|
+
* @private
|
|
647
|
+
*/
|
|
648
|
+
private _complete;
|
|
649
|
+
/**
|
|
650
|
+
* Times every method of a script the engine calls from now on, by wrapping the one method of
|
|
651
|
+
* the script components that calls them. Measures what timing a call costs the first time.
|
|
652
|
+
*
|
|
653
|
+
* @private
|
|
654
|
+
*/
|
|
655
|
+
private _hookScripts;
|
|
656
|
+
/**
|
|
657
|
+
* Stops timing scripts. The frame under way was timed only in part, so it has no script times.
|
|
658
|
+
*
|
|
659
|
+
* @private
|
|
660
|
+
*/
|
|
661
|
+
private _unhookScripts;
|
|
662
|
+
/**
|
|
663
|
+
* @param {Function} timed - The wrapper timing script calls.
|
|
664
|
+
* @param {Function} original - The engine's own method it wraps.
|
|
665
|
+
* @returns {number} What timing a call costs, in milliseconds: an empty call made through the
|
|
666
|
+
* wrapper less one made directly, the best of a few rounds.
|
|
667
|
+
* @private
|
|
668
|
+
*/
|
|
669
|
+
private _measureCallCost;
|
|
670
|
+
/**
|
|
671
|
+
* Adds a timed script call to the frame being recorded.
|
|
672
|
+
*
|
|
673
|
+
* @param {any} script - The script instance.
|
|
674
|
+
* @param {string} method - The method called.
|
|
675
|
+
* @param {number} start - When the call began.
|
|
676
|
+
* @param {number} self - Its own time, without the calls nested in it.
|
|
677
|
+
* @param {boolean} outermost - Whether it was not nested in another.
|
|
678
|
+
* @private
|
|
679
|
+
*/
|
|
680
|
+
private _addScript;
|
|
681
|
+
/**
|
|
682
|
+
* Takes GPU timings that have resolved since the last frame, and stores them with the frame
|
|
683
|
+
* they describe.
|
|
684
|
+
*
|
|
685
|
+
* @private
|
|
686
|
+
*/
|
|
687
|
+
private _resolveGpu;
|
|
688
|
+
/**
|
|
689
|
+
* Finds the effect running each timed pass of a slot in the frame graph: the pass it is a
|
|
690
|
+
* before or after pass of, where that pass runs only passes of its own. A pass running effects
|
|
691
|
+
* that run passes, as a camera frame does, is a frame rather than an effect, so what it runs
|
|
692
|
+
* directly counts as passes of their own. The passes are matched by name in the order they
|
|
693
|
+
* ran, against the frame graph as it is now, as the timings arrive a few frames late; where
|
|
694
|
+
* too few match, as when the frame graph has changed, no pass gets an owner.
|
|
695
|
+
*
|
|
696
|
+
* @param {number} slot - The slot.
|
|
697
|
+
* @private
|
|
698
|
+
*/
|
|
699
|
+
private _matchOwners;
|
|
700
|
+
/**
|
|
701
|
+
* @param {any[]} passes - The passes of the frame graph.
|
|
702
|
+
* @param {number[]} figures - The figures of the timed passes.
|
|
703
|
+
* @param {number} count - How many passes were timed.
|
|
704
|
+
* @returns {number[]} For each timed pass, the id of its owner's name, which of the passes of
|
|
705
|
+
* the frame graph with its name it is, and which with its owner's name its owner is; -1 for
|
|
706
|
+
* each where unknown.
|
|
707
|
+
* @private
|
|
708
|
+
*/
|
|
709
|
+
private _findOwners;
|
|
710
|
+
/**
|
|
711
|
+
* @param {string} name - The name of a GPU pass or an effect.
|
|
712
|
+
* @returns {number} Its index into {@link names}, added there when new.
|
|
713
|
+
* @private
|
|
714
|
+
*/
|
|
715
|
+
private _nameId;
|
|
716
|
+
/**
|
|
717
|
+
* Adds a GPU pass to the frame its timings were resolved for. A callback made once, as an
|
|
718
|
+
* iterator over the map of pass timings would make garbage on every frame.
|
|
719
|
+
*
|
|
720
|
+
* @param {number} time - The GPU time of the pass.
|
|
721
|
+
* @param {string} name - Its name.
|
|
722
|
+
* @private
|
|
723
|
+
*/
|
|
724
|
+
private _addPass;
|
|
725
|
+
/**
|
|
726
|
+
* @param {PerfEvent} event - An event of the frame being recorded.
|
|
727
|
+
* @private
|
|
728
|
+
*/
|
|
729
|
+
private _addEvent;
|
|
730
|
+
/**
|
|
731
|
+
* @param {number} slot - The slot of a frame.
|
|
732
|
+
* @param {PerfEvent} event - An event of the frame.
|
|
733
|
+
* @private
|
|
734
|
+
*/
|
|
735
|
+
private _addEventTo;
|
|
736
|
+
/**
|
|
737
|
+
* Finds the frame, complete or being recorded, that began at or before a time and was still
|
|
738
|
+
* going on at it.
|
|
739
|
+
*
|
|
740
|
+
* @param {number} time - A `performance.now()` time.
|
|
741
|
+
* @returns {number} The slot of the frame, or -1 when no frame kept covers the time.
|
|
742
|
+
* @private
|
|
743
|
+
*/
|
|
744
|
+
private _slotAt;
|
|
745
|
+
/**
|
|
746
|
+
* @param {Asset} asset - An asset that began loading.
|
|
747
|
+
* @private
|
|
748
|
+
*/
|
|
749
|
+
private _onAssetLoadStart;
|
|
750
|
+
/**
|
|
751
|
+
* @param {Asset} asset - An asset that finished loading.
|
|
752
|
+
* @private
|
|
753
|
+
*/
|
|
754
|
+
private _onAssetLoad;
|
|
755
|
+
/**
|
|
756
|
+
* @param {*} err - The error.
|
|
757
|
+
* @param {Asset} asset - An asset that failed to load.
|
|
758
|
+
* @private
|
|
759
|
+
*/
|
|
760
|
+
private _onAssetError;
|
|
761
|
+
/**
|
|
762
|
+
* Adds an asset that ended loading to the entry it ended in, with the request of its file
|
|
763
|
+
* where the browser kept it: how long the network took, and so how long the asset took after.
|
|
764
|
+
*
|
|
765
|
+
* @param {Asset} asset - The asset.
|
|
766
|
+
* @param {number} end - When it ended.
|
|
767
|
+
* @param {boolean} failed - Whether it failed.
|
|
768
|
+
* @private
|
|
769
|
+
*/
|
|
770
|
+
private _endAsset;
|
|
771
|
+
/**
|
|
772
|
+
* @param {string} name - A moment of the app or the page.
|
|
773
|
+
* @param {number} time - When it was.
|
|
774
|
+
* @private
|
|
775
|
+
*/
|
|
776
|
+
private _addMilestone;
|
|
777
|
+
/**
|
|
778
|
+
* Adds a load to the entry it ended in, where it is kept.
|
|
779
|
+
*
|
|
780
|
+
* @param {PerfLoad} load - The load.
|
|
781
|
+
* @private
|
|
782
|
+
*/
|
|
783
|
+
private _addLoad;
|
|
784
|
+
/**
|
|
785
|
+
* @param {any} entry - A request the browser timed.
|
|
786
|
+
* @private
|
|
787
|
+
*/
|
|
788
|
+
private _addRequest;
|
|
789
|
+
/**
|
|
790
|
+
* @param {PerformanceObserverEntryList} list - The requests the browser timed.
|
|
791
|
+
* @private
|
|
792
|
+
*/
|
|
793
|
+
private _onResources;
|
|
794
|
+
/**
|
|
795
|
+
* @param {PerformanceObserverEntryList} list - The paints the browser timed: its first paint and
|
|
796
|
+
* its first paint of content.
|
|
797
|
+
* @private
|
|
798
|
+
*/
|
|
799
|
+
private _onPaints;
|
|
800
|
+
/** @private */
|
|
801
|
+
private _onPreloadStart;
|
|
802
|
+
/** @private */
|
|
803
|
+
private _onPreloadEnd;
|
|
804
|
+
/** @private */
|
|
805
|
+
private _onAppStart;
|
|
806
|
+
/**
|
|
807
|
+
* Takes a counter of `app.stats.user` into the frame ending, keeping a ring for it the first
|
|
808
|
+
* time the app sets it.
|
|
809
|
+
*
|
|
810
|
+
* @param {*} value - Its value.
|
|
811
|
+
* @param {string} name - Its name.
|
|
812
|
+
* @private
|
|
813
|
+
*/
|
|
814
|
+
private _takeCounter;
|
|
815
|
+
/**
|
|
816
|
+
* @param {{ timestamp: number }} e - The event.
|
|
817
|
+
* @private
|
|
818
|
+
*/
|
|
819
|
+
private _onBakeStart;
|
|
820
|
+
/**
|
|
821
|
+
* Adds a bake of lightmaps to the frame it ran in, with the figures the lightmapper kept of it.
|
|
822
|
+
*
|
|
823
|
+
* @param {{ timestamp: number, target: { stats: object } }} e - The event.
|
|
824
|
+
* @private
|
|
825
|
+
*/
|
|
826
|
+
private _onBakeEnd;
|
|
827
|
+
/**
|
|
828
|
+
* @param {{ timestamp: number }} e - The event.
|
|
829
|
+
* @private
|
|
830
|
+
*/
|
|
831
|
+
private _onCompileStart;
|
|
832
|
+
/**
|
|
833
|
+
* @param {{ timestamp: number }} e - The event.
|
|
834
|
+
* @private
|
|
835
|
+
*/
|
|
836
|
+
private _onCompileEnd;
|
|
837
|
+
/**
|
|
838
|
+
* @param {{ timestamp: number }} e - The event.
|
|
839
|
+
* @private
|
|
840
|
+
*/
|
|
841
|
+
private _onLinkStart;
|
|
842
|
+
/**
|
|
843
|
+
* @param {{ timestamp: number }} e - The event.
|
|
844
|
+
* @private
|
|
845
|
+
*/
|
|
846
|
+
private _onLinkEnd;
|
|
847
|
+
/**
|
|
848
|
+
* @param {number} duration - How long a shader compile or link took.
|
|
849
|
+
* @private
|
|
850
|
+
*/
|
|
851
|
+
private _countCompile;
|
|
852
|
+
/**
|
|
853
|
+
* Gives each long animation frame the browser reports to the app frame that ran in it, naming
|
|
854
|
+
* the script that ran longest.
|
|
855
|
+
*
|
|
856
|
+
* @param {PerformanceObserverEntryList} list - The entries.
|
|
857
|
+
* @private
|
|
858
|
+
*/
|
|
859
|
+
private _onLongFrames;
|
|
860
|
+
/**
|
|
861
|
+
* Gives each span the app measured with `performance.measure` to the frame it started in.
|
|
862
|
+
*
|
|
863
|
+
* @param {PerformanceObserverEntryList} list - The entries.
|
|
864
|
+
* @private
|
|
865
|
+
*/
|
|
866
|
+
private _onMeasures;
|
|
867
|
+
}
|
|
868
|
+
export const SCRIPT_CALLS: 3;
|
|
869
|
+
export const SCRIPT_ORDER: 6;
|
|
870
|
+
export const SCRIPT_STRIDE: 8;
|
|
871
|
+
import type { AppBase } from 'playcanvas';
|