@rnperf/sdk 0.0.0-stage → 0.1.2
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 +203 -2
- package/RNPerfSDK.podspec +21 -0
- package/android/build.gradle +46 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/rnperf/sdk/RNPerfFrameMonitorModule.java +345 -0
- package/android/src/main/java/com/rnperf/sdk/RNPerfFrameMonitorPackage.java +36 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +318 -0
- package/dist/index.js.map +1 -0
- package/dist/native.d.ts +44 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +97 -0
- package/dist/native.js.map +1 -0
- package/dist/probes.d.ts +68 -0
- package/dist/probes.d.ts.map +1 -0
- package/dist/probes.js +205 -0
- package/dist/probes.js.map +1 -0
- package/dist/renders.d.ts +23 -0
- package/dist/renders.d.ts.map +1 -0
- package/dist/renders.js +157 -0
- package/dist/renders.js.map +1 -0
- package/dist/rn.d.ts +42 -0
- package/dist/rn.d.ts.map +1 -0
- package/dist/rn.js +88 -0
- package/dist/rn.js.map +1 -0
- package/dist/transport.d.ts +39 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +122 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +100 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/ios/RNPerfFrameMonitor.h +16 -0
- package/ios/RNPerfFrameMonitor.m +249 -0
- package/package.json +53 -4
- package/react-native.config.js +25 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { PerfMonitorOptions } from './types.js';
|
|
2
|
+
export type { PerfMonitorOptions, Sample, PerfEvent, ComponentRenderStat } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Start streaming performance data to the rnperf daemon.
|
|
5
|
+
*
|
|
6
|
+
* Call it once, as early as possible but **after** React has loaded, so the
|
|
7
|
+
* render tracker can attach to React's commit hook:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { startPerfMonitor } from '@rnperf/sdk';
|
|
11
|
+
* import App from './App';
|
|
12
|
+
*
|
|
13
|
+
* startPerfMonitor(); // host is derived from the Metro URL
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* In a release build it is a no-op unless `enableInRelease` is set, and there
|
|
17
|
+
* `host` must be given explicitly — an embedded bundle carries no Metro URL:
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* startPerfMonitor({ enableInRelease: true, host: '192.168.1.5' });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function startPerfMonitor(options?: PerfMonitorOptions): void;
|
|
24
|
+
export declare function stopPerfMonitor(): void;
|
|
25
|
+
/** Tell the monitor which screen is active, so findings can name it. */
|
|
26
|
+
export declare function setScreen(name: string): void;
|
|
27
|
+
export declare function mark(name: string, detail?: unknown): void;
|
|
28
|
+
/** Duration since `mark(startMark ?? name)`, also reported to the daemon. */
|
|
29
|
+
export declare function measure(name: string, startMark?: string, detail?: unknown): number | undefined;
|
|
30
|
+
export declare function reportTTI(screen?: string, durationMs?: number): void;
|
|
31
|
+
export declare function trackInteraction(name: string, durationMs: number): void;
|
|
32
|
+
export declare function perfLog(level: 'debug' | 'info' | 'warn' | 'error', message: string, tag?: string): void;
|
|
33
|
+
export declare function isPerfMonitorConnected(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Drop-in for React Navigation: pass to `<NavigationContainer onStateChange>`
|
|
36
|
+
* (or call from your own router) to segment metrics by screen.
|
|
37
|
+
*
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <NavigationContainer onStateChange={() => setScreen(navigationRef.getCurrentRoute()?.name ?? '')}>
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function createNavigationTracker(getCurrentRouteName: () => string | und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|
package/dist/index.js
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startPerfMonitor = startPerfMonitor;
|
|
4
|
+
exports.stopPerfMonitor = stopPerfMonitor;
|
|
5
|
+
exports.setScreen = setScreen;
|
|
6
|
+
exports.mark = mark;
|
|
7
|
+
exports.measure = measure;
|
|
8
|
+
exports.reportTTI = reportTTI;
|
|
9
|
+
exports.trackInteraction = trackInteraction;
|
|
10
|
+
exports.perfLog = perfLog;
|
|
11
|
+
exports.isPerfMonitorConnected = isPerfMonitorConnected;
|
|
12
|
+
exports.createNavigationTracker = createNavigationTracker;
|
|
13
|
+
const probes_js_1 = require("./probes.js");
|
|
14
|
+
const rn_js_1 = require("./rn.js");
|
|
15
|
+
const native_js_1 = require("./native.js");
|
|
16
|
+
const renders_js_1 = require("./renders.js");
|
|
17
|
+
const transport_js_1 = require("./transport.js");
|
|
18
|
+
const DEFAULT_PORT = 8139;
|
|
19
|
+
class PerfMonitor {
|
|
20
|
+
transport;
|
|
21
|
+
fps = new probes_js_1.FpsProbe();
|
|
22
|
+
stalls = new probes_js_1.StallProbe();
|
|
23
|
+
bridge = new probes_js_1.BridgeProbe();
|
|
24
|
+
renders = new renders_js_1.RenderTracker();
|
|
25
|
+
nativeFrames = new native_js_1.NativeFrameProbe();
|
|
26
|
+
timer = null;
|
|
27
|
+
reporting = false;
|
|
28
|
+
startedAt = 0;
|
|
29
|
+
currentScreen;
|
|
30
|
+
marks = new Map();
|
|
31
|
+
ttiReported = new Set();
|
|
32
|
+
running = false;
|
|
33
|
+
start(options = {}) {
|
|
34
|
+
if (this.running)
|
|
35
|
+
return;
|
|
36
|
+
const dev = Boolean(global.__DEV__);
|
|
37
|
+
if (!dev && !options.enableInRelease) {
|
|
38
|
+
// Profiling costs real CPU. Opting in to it in production must be explicit.
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const host = options.host === 'auto' || !options.host ? (0, rn_js_1.inferHost)() : options.host;
|
|
42
|
+
if (!host) {
|
|
43
|
+
// A release bundle is loaded from `assets://` or `file://`, so there is no
|
|
44
|
+
// Metro address to read. Forcing this one warning past the __DEV__ guard is
|
|
45
|
+
// the difference between a diagnosable mistake and a monitor that opted in
|
|
46
|
+
// to release and then said nothing at all.
|
|
47
|
+
warn(dev
|
|
48
|
+
? 'could not infer the daemon host from the Metro bundle URL — pass `host` explicitly.'
|
|
49
|
+
: "a release build has no Metro bundle URL to infer the daemon host from — pass it explicitly, e.g. startPerfMonitor({ enableInRelease: true, host: '192.168.1.5' }).", !dev);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.running = true;
|
|
53
|
+
this.startedAt = (0, probes_js_1.now)();
|
|
54
|
+
const platform = rn_js_1.Platform.OS === 'android' ? 'android' : 'ios';
|
|
55
|
+
this.transport = new transport_js_1.Transport(host, options.port ?? DEFAULT_PORT, {
|
|
56
|
+
app: {
|
|
57
|
+
bundleId: options.bundleId ?? (0, rn_js_1.inferBundleId)(),
|
|
58
|
+
name: options.appName,
|
|
59
|
+
version: options.appVersion,
|
|
60
|
+
},
|
|
61
|
+
platform,
|
|
62
|
+
deviceName: rn_js_1.Platform.constants?.Model ?? rn_js_1.Platform.constants?.Brand,
|
|
63
|
+
runtime: {
|
|
64
|
+
rnVersion: rn_js_1.Platform.constants?.reactNativeVersion
|
|
65
|
+
? formatVersion(rn_js_1.Platform.constants.reactNativeVersion)
|
|
66
|
+
: undefined,
|
|
67
|
+
hermes: (0, probes_js_1.isHermes)(),
|
|
68
|
+
dev,
|
|
69
|
+
},
|
|
70
|
+
}, options.onStatus);
|
|
71
|
+
this.transport.connect();
|
|
72
|
+
this.fps.start();
|
|
73
|
+
this.stalls.start();
|
|
74
|
+
if (options.trackBridge !== false)
|
|
75
|
+
this.bridge.start();
|
|
76
|
+
if (options.trackUiFrames !== false) {
|
|
77
|
+
if (this.nativeFrames.attach()) {
|
|
78
|
+
this.nativeFrames.start();
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
warn((0, native_js_1.explainMissingNativeModule)());
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (options.trackRenders !== false && !this.renders.install()) {
|
|
85
|
+
// In release the hook is simply not there, and React's production renderer
|
|
86
|
+
// records no timings either — a different cause needing a different answer.
|
|
87
|
+
warn(dev
|
|
88
|
+
? 'component render tracking is unavailable — React had not initialised when the monitor started. Call startPerfMonitor() after importing your root component.'
|
|
89
|
+
: 'component render tracking is unavailable in a release build — React ships its production renderer, which records no render timings. Every other metric still reports.', !dev);
|
|
90
|
+
}
|
|
91
|
+
const intervalMs = options.intervalMs ?? 1000;
|
|
92
|
+
this.timer = setInterval(() => void this.report(), intervalMs);
|
|
93
|
+
this.installErrorHook();
|
|
94
|
+
}
|
|
95
|
+
async report() {
|
|
96
|
+
if (!this.transport)
|
|
97
|
+
return;
|
|
98
|
+
// Reading the native window is a bridge round trip. If the JS thread is
|
|
99
|
+
// blocked it may still be outstanding when the next tick fires; skipping
|
|
100
|
+
// is correct, because the native side keeps accumulating either way and
|
|
101
|
+
// the following read simply covers a longer window.
|
|
102
|
+
if (this.reporting)
|
|
103
|
+
return;
|
|
104
|
+
this.reporting = true;
|
|
105
|
+
try {
|
|
106
|
+
await this.collectAndSend();
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
this.reporting = false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async collectAndSend() {
|
|
113
|
+
if (!this.transport)
|
|
114
|
+
return;
|
|
115
|
+
const t = Date.now();
|
|
116
|
+
const sample = { t, dt: Math.round((0, probes_js_1.now)() - this.startedAt) };
|
|
117
|
+
const fps = this.fps.read();
|
|
118
|
+
if (fps !== undefined)
|
|
119
|
+
sample.jsFps = Math.round(fps * 10) / 10;
|
|
120
|
+
const { jsStallMaxMs, jsStallCount } = this.stalls.read();
|
|
121
|
+
if (jsStallCount > 0) {
|
|
122
|
+
sample.jsStallMaxMs = Math.round(jsStallMaxMs);
|
|
123
|
+
sample.jsStallCount = jsStallCount;
|
|
124
|
+
}
|
|
125
|
+
Object.assign(sample, (0, probes_js_1.readJsHeap)());
|
|
126
|
+
const bridgeCalls = this.bridge.read();
|
|
127
|
+
if (bridgeCalls !== undefined)
|
|
128
|
+
sample.bridgeCalls = bridgeCalls;
|
|
129
|
+
const renders = this.renders.read();
|
|
130
|
+
if (renders)
|
|
131
|
+
sample.renders = renders;
|
|
132
|
+
if (this.currentScreen)
|
|
133
|
+
sample.screen = this.currentScreen;
|
|
134
|
+
if (this.nativeFrames.available) {
|
|
135
|
+
const frames = await this.nativeFrames.read();
|
|
136
|
+
if (frames.uiFps !== undefined)
|
|
137
|
+
sample.uiFps = round1(frames.uiFps);
|
|
138
|
+
if (frames.refreshHz !== undefined)
|
|
139
|
+
sample.uiRefreshHz = frames.refreshHz;
|
|
140
|
+
if (frames.frameP50Ms !== undefined)
|
|
141
|
+
sample.frameP50Ms = round2(frames.frameP50Ms);
|
|
142
|
+
if (frames.frameP95Ms !== undefined)
|
|
143
|
+
sample.frameP95Ms = round2(frames.frameP95Ms);
|
|
144
|
+
if (frames.frameP99Ms !== undefined)
|
|
145
|
+
sample.frameP99Ms = round2(frames.frameP99Ms);
|
|
146
|
+
if (frames.jankPercent !== undefined)
|
|
147
|
+
sample.jankPercent = round1(frames.jankPercent);
|
|
148
|
+
if (frames.framesRendered !== undefined)
|
|
149
|
+
sample.framesRendered = frames.framesRendered;
|
|
150
|
+
// Without a cable the daemon cannot read memory at all, so for a device
|
|
151
|
+
// on Wi-Fi these are the only memory figures available for the run.
|
|
152
|
+
if (frames.memoryMB !== undefined)
|
|
153
|
+
sample.rssMB = round1(frames.memoryMB);
|
|
154
|
+
if (frames.javaHeapMB !== undefined)
|
|
155
|
+
sample.javaHeapMB = round1(frames.javaHeapMB);
|
|
156
|
+
if (frames.nativeHeapMB !== undefined)
|
|
157
|
+
sample.nativeHeapMB = round1(frames.nativeHeapMB);
|
|
158
|
+
}
|
|
159
|
+
// The transport may have been torn down while awaiting the bridge.
|
|
160
|
+
this.transport?.sendSample(sample);
|
|
161
|
+
}
|
|
162
|
+
installErrorHook() {
|
|
163
|
+
try {
|
|
164
|
+
const handler = global.ErrorUtils?.getGlobalHandler?.();
|
|
165
|
+
global.ErrorUtils?.setGlobalHandler?.((error, isFatal) => {
|
|
166
|
+
this.transport?.sendEvent({
|
|
167
|
+
type: 'crash',
|
|
168
|
+
t: Date.now(),
|
|
169
|
+
message: `${isFatal ? 'Fatal: ' : ''}${error?.message ?? String(error)}`,
|
|
170
|
+
stack: error?.stack,
|
|
171
|
+
});
|
|
172
|
+
handler?.(error, isFatal);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
catch { /* leave the app's own handler alone */ }
|
|
176
|
+
}
|
|
177
|
+
/* ------------------------------------------------------------ public */
|
|
178
|
+
setScreen(name) {
|
|
179
|
+
if (this.currentScreen === name)
|
|
180
|
+
return;
|
|
181
|
+
this.currentScreen = name;
|
|
182
|
+
this.transport?.sendEvent({ type: 'screen', t: Date.now(), name });
|
|
183
|
+
}
|
|
184
|
+
mark(name, detail) {
|
|
185
|
+
this.marks.set(name, (0, probes_js_1.now)());
|
|
186
|
+
this.transport?.sendEvent({ type: 'mark', t: Date.now(), name, detail });
|
|
187
|
+
}
|
|
188
|
+
measure(name, startMark, detail) {
|
|
189
|
+
const start = this.marks.get(startMark ?? name);
|
|
190
|
+
if (start === undefined)
|
|
191
|
+
return undefined;
|
|
192
|
+
const durationMs = (0, probes_js_1.now)() - start;
|
|
193
|
+
this.transport?.sendEvent({
|
|
194
|
+
type: 'measure', t: Date.now(), name, durationMs: Math.round(durationMs * 100) / 100, detail,
|
|
195
|
+
});
|
|
196
|
+
return durationMs;
|
|
197
|
+
}
|
|
198
|
+
/** Report time-to-interactive for a screen. Ignored after the first call per screen. */
|
|
199
|
+
reportTTI(screen, durationMs) {
|
|
200
|
+
const key = screen ?? '__app__';
|
|
201
|
+
if (this.ttiReported.has(key))
|
|
202
|
+
return;
|
|
203
|
+
this.ttiReported.add(key);
|
|
204
|
+
this.transport?.sendEvent({
|
|
205
|
+
type: 'tti',
|
|
206
|
+
t: Date.now(),
|
|
207
|
+
durationMs: Math.round(durationMs ?? (0, probes_js_1.now)() - this.startedAt),
|
|
208
|
+
screen,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
trackInteraction(name, durationMs) {
|
|
212
|
+
this.transport?.sendEvent({ type: 'interaction', t: Date.now(), name, durationMs: Math.round(durationMs) });
|
|
213
|
+
}
|
|
214
|
+
log(level, message, tag) {
|
|
215
|
+
this.transport?.sendEvent({ type: 'log', t: Date.now(), level, message, tag });
|
|
216
|
+
}
|
|
217
|
+
stop() {
|
|
218
|
+
if (!this.running)
|
|
219
|
+
return;
|
|
220
|
+
this.running = false;
|
|
221
|
+
if (this.timer)
|
|
222
|
+
clearInterval(this.timer);
|
|
223
|
+
this.timer = null;
|
|
224
|
+
this.fps.stop();
|
|
225
|
+
this.stalls.stop();
|
|
226
|
+
this.bridge.stop();
|
|
227
|
+
this.nativeFrames.stop();
|
|
228
|
+
this.renders.uninstall();
|
|
229
|
+
this.transport?.close();
|
|
230
|
+
this.transport = undefined;
|
|
231
|
+
}
|
|
232
|
+
get isConnected() {
|
|
233
|
+
return Boolean(this.transport?.connected);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const monitor = new PerfMonitor();
|
|
237
|
+
/**
|
|
238
|
+
* Start streaming performance data to the rnperf daemon.
|
|
239
|
+
*
|
|
240
|
+
* Call it once, as early as possible but **after** React has loaded, so the
|
|
241
|
+
* render tracker can attach to React's commit hook:
|
|
242
|
+
*
|
|
243
|
+
* ```ts
|
|
244
|
+
* import { startPerfMonitor } from '@rnperf/sdk';
|
|
245
|
+
* import App from './App';
|
|
246
|
+
*
|
|
247
|
+
* startPerfMonitor(); // host is derived from the Metro URL
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* In a release build it is a no-op unless `enableInRelease` is set, and there
|
|
251
|
+
* `host` must be given explicitly — an embedded bundle carries no Metro URL:
|
|
252
|
+
*
|
|
253
|
+
* ```ts
|
|
254
|
+
* startPerfMonitor({ enableInRelease: true, host: '192.168.1.5' });
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
function startPerfMonitor(options) {
|
|
258
|
+
monitor.start(options);
|
|
259
|
+
}
|
|
260
|
+
function stopPerfMonitor() {
|
|
261
|
+
monitor.stop();
|
|
262
|
+
}
|
|
263
|
+
/** Tell the monitor which screen is active, so findings can name it. */
|
|
264
|
+
function setScreen(name) {
|
|
265
|
+
monitor.setScreen(name);
|
|
266
|
+
}
|
|
267
|
+
function mark(name, detail) {
|
|
268
|
+
monitor.mark(name, detail);
|
|
269
|
+
}
|
|
270
|
+
/** Duration since `mark(startMark ?? name)`, also reported to the daemon. */
|
|
271
|
+
function measure(name, startMark, detail) {
|
|
272
|
+
return monitor.measure(name, startMark, detail);
|
|
273
|
+
}
|
|
274
|
+
function reportTTI(screen, durationMs) {
|
|
275
|
+
monitor.reportTTI(screen, durationMs);
|
|
276
|
+
}
|
|
277
|
+
function trackInteraction(name, durationMs) {
|
|
278
|
+
monitor.trackInteraction(name, durationMs);
|
|
279
|
+
}
|
|
280
|
+
function perfLog(level, message, tag) {
|
|
281
|
+
monitor.log(level, message, tag);
|
|
282
|
+
}
|
|
283
|
+
function isPerfMonitorConnected() {
|
|
284
|
+
return monitor.isConnected;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Drop-in for React Navigation: pass to `<NavigationContainer onStateChange>`
|
|
288
|
+
* (or call from your own router) to segment metrics by screen.
|
|
289
|
+
*
|
|
290
|
+
* ```tsx
|
|
291
|
+
* <NavigationContainer onStateChange={() => setScreen(navigationRef.getCurrentRoute()?.name ?? '')}>
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
function createNavigationTracker(getCurrentRouteName) {
|
|
295
|
+
let previous;
|
|
296
|
+
let enteredAt = (0, probes_js_1.now)();
|
|
297
|
+
return () => {
|
|
298
|
+
const name = getCurrentRouteName();
|
|
299
|
+
if (!name || name === previous)
|
|
300
|
+
return;
|
|
301
|
+
if (previous)
|
|
302
|
+
monitor.trackInteraction(`navigate:${previous}→${name}`, (0, probes_js_1.now)() - enteredAt);
|
|
303
|
+
previous = name;
|
|
304
|
+
enteredAt = (0, probes_js_1.now)();
|
|
305
|
+
monitor.setScreen(name);
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/* --------------------------------------------------------------- helpers */
|
|
309
|
+
function formatVersion(v) {
|
|
310
|
+
return `${v.major ?? 0}.${v.minor ?? 0}.${v.patch ?? 0}`;
|
|
311
|
+
}
|
|
312
|
+
const round1 = (n) => Math.round(n * 10) / 10;
|
|
313
|
+
const round2 = (n) => Math.round(n * 100) / 100;
|
|
314
|
+
function warn(message, force = false) {
|
|
315
|
+
if (global.__DEV__ || force)
|
|
316
|
+
console.warn(`[rnperf] ${message}`);
|
|
317
|
+
}
|
|
318
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AA0QA,4CAEC;AAED,0CAEC;AAGD,8BAEC;AAED,oBAEC;AAGD,0BAEC;AAED,8BAEC;AAED,4CAEC;AAED,0BAEC;AAED,wDAEC;AAUD,0DAWC;AAnUD,2CAA2F;AAC3F,mCAA6D;AAC7D,2CAA2E;AAC3E,6CAA6C;AAC7C,iDAA2C;AAO3C,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B,MAAM,WAAW;IACP,SAAS,CAAa;IACb,GAAG,GAAG,IAAI,oBAAQ,EAAE,CAAC;IACrB,MAAM,GAAG,IAAI,sBAAU,EAAE,CAAC;IAC1B,MAAM,GAAG,IAAI,uBAAW,EAAE,CAAC;IAC3B,OAAO,GAAG,IAAI,0BAAa,EAAE,CAAC;IAC9B,YA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AAM,CAAC,OAAO,IAAI,KAAK;QAAE,OAAO,CAAC,IAAI,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC;AACnE,CAAC"}
|
package/dist/native.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** One window of UI-thread frame data, drained from the native module. */
|
|
2
|
+
export interface NativeFrameMetrics {
|
|
3
|
+
uiFps?: number;
|
|
4
|
+
frameP50Ms?: number;
|
|
5
|
+
frameP95Ms?: number;
|
|
6
|
+
frameP99Ms?: number;
|
|
7
|
+
jankPercent?: number;
|
|
8
|
+
framesRendered?: number;
|
|
9
|
+
/** The display's maximum refresh rate — 120 on ProMotion hardware. */
|
|
10
|
+
refreshHz?: number;
|
|
11
|
+
/** iOS: physical footprint in MB — what Xcode shows, and what jetsam judges. */
|
|
12
|
+
memoryMB?: number;
|
|
13
|
+
/** Android: Java heap in use. */
|
|
14
|
+
javaHeapMB?: number;
|
|
15
|
+
/** Android: native heap allocated. */
|
|
16
|
+
nativeHeapMB?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Bridge to the optional `RNPerfFrameMonitor` native module.
|
|
20
|
+
*
|
|
21
|
+
* Everything degrades to "no UI-thread data" rather than throwing: the module
|
|
22
|
+
* is absent in Expo Go, in a build where pods were not reinstalled, and on
|
|
23
|
+
* Android (where the daemon reads frame timings from `adb` instead).
|
|
24
|
+
*/
|
|
25
|
+
export declare class NativeFrameProbe {
|
|
26
|
+
private module?;
|
|
27
|
+
private started;
|
|
28
|
+
private inFlight;
|
|
29
|
+
private failures;
|
|
30
|
+
/** Attaches to the native module. Returns false when it is unavailable. */
|
|
31
|
+
attach(): boolean;
|
|
32
|
+
start(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Reads and resets the native window. Returns `{}` when a read is already
|
|
35
|
+
* outstanding, which happens when the JS thread is blocked — precisely when
|
|
36
|
+
* piling up more bridge calls would make things worse.
|
|
37
|
+
*/
|
|
38
|
+
read(): Promise<NativeFrameMetrics>;
|
|
39
|
+
stop(): void;
|
|
40
|
+
get available(): boolean;
|
|
41
|
+
}
|
|
42
|
+
/** Why UI-thread frame data is unavailable, phrased for a dev-time warning. */
|
|
43
|
+
export declare function explainMissingNativeModule(): string;
|
|
44
|
+
//# sourceMappingURL=native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAIA,0EAA0E;AAC1E,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAQD;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,CAAe;IAC9B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAK;IAErB,2EAA2E;IAC3E,MAAM,IAAI,OAAO;IAWjB,KAAK,IAAI,IAAI;IAUb;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAkBzC,IAAI,IAAI,IAAI;IAWZ,IAAI,SAAS,IAAI,OAAO,CAEvB;CACF;AAED,+EAA+E;AAC/E,wBAAgB,0BAA0B,IAAI,MAAM,CAUnD"}
|
package/dist/native.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NativeFrameProbe = void 0;
|
|
4
|
+
exports.explainMissingNativeModule = explainMissingNativeModule;
|
|
5
|
+
const rn_js_1 = require("./rn.js");
|
|
6
|
+
/**
|
|
7
|
+
* Bridge to the optional `RNPerfFrameMonitor` native module.
|
|
8
|
+
*
|
|
9
|
+
* Everything degrades to "no UI-thread data" rather than throwing: the module
|
|
10
|
+
* is absent in Expo Go, in a build where pods were not reinstalled, and on
|
|
11
|
+
* Android (where the daemon reads frame timings from `adb` instead).
|
|
12
|
+
*/
|
|
13
|
+
class NativeFrameProbe {
|
|
14
|
+
module;
|
|
15
|
+
started = false;
|
|
16
|
+
inFlight = false;
|
|
17
|
+
failures = 0;
|
|
18
|
+
/** Attaches to the native module. Returns false when it is unavailable. */
|
|
19
|
+
attach() {
|
|
20
|
+
try {
|
|
21
|
+
const candidate = rn_js_1.NativeModules.RNPerfFrameMonitor;
|
|
22
|
+
if (!candidate || typeof candidate.getMetrics !== 'function')
|
|
23
|
+
return false;
|
|
24
|
+
this.module = candidate;
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
start() {
|
|
32
|
+
if (!this.module || this.started)
|
|
33
|
+
return;
|
|
34
|
+
try {
|
|
35
|
+
this.module.start();
|
|
36
|
+
this.started = true;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
this.module = undefined;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Reads and resets the native window. Returns `{}` when a read is already
|
|
44
|
+
* outstanding, which happens when the JS thread is blocked — precisely when
|
|
45
|
+
* piling up more bridge calls would make things worse.
|
|
46
|
+
*/
|
|
47
|
+
async read() {
|
|
48
|
+
if (!this.module || !this.started || this.inFlight)
|
|
49
|
+
return {};
|
|
50
|
+
this.inFlight = true;
|
|
51
|
+
try {
|
|
52
|
+
const metrics = await this.module.getMetrics();
|
|
53
|
+
this.failures = 0;
|
|
54
|
+
return metrics ?? {};
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// Three consecutive failures means something is structurally wrong;
|
|
58
|
+
// stop paying for a bridge call every second to rediscover that.
|
|
59
|
+
this.failures += 1;
|
|
60
|
+
if (this.failures >= 3)
|
|
61
|
+
this.stop();
|
|
62
|
+
return {};
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
this.inFlight = false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
stop() {
|
|
69
|
+
if (!this.module)
|
|
70
|
+
return;
|
|
71
|
+
try {
|
|
72
|
+
if (this.started)
|
|
73
|
+
this.module.stop();
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// The module is going away regardless.
|
|
77
|
+
}
|
|
78
|
+
this.started = false;
|
|
79
|
+
this.module = undefined;
|
|
80
|
+
}
|
|
81
|
+
get available() {
|
|
82
|
+
return Boolean(this.module);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.NativeFrameProbe = NativeFrameProbe;
|
|
86
|
+
/** Why UI-thread frame data is unavailable, phrased for a dev-time warning. */
|
|
87
|
+
function explainMissingNativeModule() {
|
|
88
|
+
const platform = rn_js_1.Platform.OS;
|
|
89
|
+
if ((0, rn_js_1.isExpoRuntime)()) {
|
|
90
|
+
return 'UI-thread FPS needs the rnperf native module, which Expo Go cannot load. Run `npx expo prebuild` and use a development build.';
|
|
91
|
+
}
|
|
92
|
+
if (platform === 'android') {
|
|
93
|
+
return 'UI-thread FPS needs the rnperf native module. Rebuild the app (`npx react-native run-android`) so autolinking picks it up. Until then, connect the device over adb and the daemon will read frame timings itself.';
|
|
94
|
+
}
|
|
95
|
+
return 'UI-thread FPS needs the rnperf native module. Run `cd ios && pod install`, then rebuild the app.';
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=native.js.map
|
|
@@ -0,0 +1 @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AAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,oEAAoE;YACpE,iEAAiE;YACjE,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;YACnB,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC;gBAAE,IAAI,CAAC,IAAI,EAAE,CAAC;YACpC,OAAO,EAAE,CAAC;QACZ,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACxB,CAAC;IACH,CAAC;IAED,IAAI;QACF,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO;QACzB,IAAI,CAAC;YACH,IAAI,IAAI,CAAC,OAAO;gBAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACvC,CAAC;QAAC,MAAM,CAAC;YACP,uCAAuC;QACzC,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;CACF;AAjED,4CAiEC;AAED,+EAA+E;AAC/E,SAAgB,0BAA0B;IACxC,MAAM,QAAQ,GAAG,gBAAQ,CAAC,EAAE,CAAC;IAE7B,IAAI,IAAA,qBAAa,GAAE,EAAE,CAAC;QACpB,OAAO,+HAA+H,CAAC;IACzI,CAAC;IACD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,mNAAmN,CAAC;IAC7N,CAAC;IACD,OAAO,kGAAkG,CAAC;AAC5G,CAAC"}
|
package/dist/probes.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime probes. Every one of these degrades to "no data" rather than
|
|
3
|
+
* throwing: the SDK runs inside someone else's app and must never be the
|
|
4
|
+
* reason it crashes.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Counts animation frames the JS thread actually serviced. React Native drives
|
|
8
|
+
* `requestAnimationFrame` from the JS thread, so a shortfall here is a direct
|
|
9
|
+
* measure of JS thread saturation — the thing that makes touch handling feel
|
|
10
|
+
* sticky even when the UI thread is fine.
|
|
11
|
+
*/
|
|
12
|
+
export declare class FpsProbe {
|
|
13
|
+
private frames;
|
|
14
|
+
private windowStart;
|
|
15
|
+
private running;
|
|
16
|
+
private rafId;
|
|
17
|
+
start(): void;
|
|
18
|
+
/** Frames per second since the last read, then resets the window. */
|
|
19
|
+
read(): number | undefined;
|
|
20
|
+
stop(): void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Measures how late a fixed-period timer actually fires. Drift is time the JS
|
|
24
|
+
* thread spent inside one synchronous block, which is what users experience as
|
|
25
|
+
* a freeze. FPS alone cannot distinguish "steadily slow" from "fine, then a
|
|
26
|
+
* 400ms lockup" — this can.
|
|
27
|
+
*/
|
|
28
|
+
export declare class StallProbe {
|
|
29
|
+
private timer;
|
|
30
|
+
private expected;
|
|
31
|
+
private maxStall;
|
|
32
|
+
private stallCount;
|
|
33
|
+
private readonly periodMs;
|
|
34
|
+
private readonly thresholdMs;
|
|
35
|
+
constructor(periodMs?: number, thresholdMs?: number);
|
|
36
|
+
start(): void;
|
|
37
|
+
read(): {
|
|
38
|
+
jsStallMaxMs: number;
|
|
39
|
+
jsStallCount: number;
|
|
40
|
+
};
|
|
41
|
+
stop(): void;
|
|
42
|
+
}
|
|
43
|
+
/** Hermes exposes allocator stats; JSC and V8 expose `performance.memory`. */
|
|
44
|
+
export declare function readJsHeap(): {
|
|
45
|
+
jsHeapMB?: number;
|
|
46
|
+
jsHeapTotalMB?: number;
|
|
47
|
+
};
|
|
48
|
+
export declare function isHermes(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Counts calls crossing the legacy bridge by installing MessageQueue's spy
|
|
51
|
+
* hook on the live bridge instance. Under the new architecture most calls are
|
|
52
|
+
* synchronous JSI and never appear here, so a zero reading means "nothing on
|
|
53
|
+
* the bridge", not "nothing happening".
|
|
54
|
+
*/
|
|
55
|
+
export declare class BridgeProbe {
|
|
56
|
+
private calls;
|
|
57
|
+
private installed;
|
|
58
|
+
start(): boolean;
|
|
59
|
+
read(): number | undefined;
|
|
60
|
+
stop(): void;
|
|
61
|
+
}
|
|
62
|
+
export declare function now(): number;
|
|
63
|
+
/**
|
|
64
|
+
* Metro resolves `require` at build time, so these deep imports have to go
|
|
65
|
+
* through an indirect lookup to stay optional — the SDK must not hard-fail in
|
|
66
|
+
* an app that has tree-shaken or renamed an internal module.
|
|
67
|
+
*/
|
|
68
|
+
//# sourceMappingURL=probes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probes.d.ts","sourceRoot":"","sources":["../src/probes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;;;;GAKG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAuB;IAEpC,KAAK,IAAI,IAAI;IAab,qEAAqE;IACrE,IAAI,IAAI,MAAM,GAAG,SAAS;IAW1B,IAAI,IAAI,IAAI;CAOb;AAID;;;;;GAKG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAA+C;IAC5D,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;gBAEzB,QAAQ,SAAK,EAAE,WAAW,SAAM;IAK5C,KAAK,IAAI,IAAI;IAcb,IAAI,IAAI;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE;IAOtD,IAAI,IAAI,IAAI;CAIb;AAID,8EAA8E;AAC9E,wBAA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