@threenative/runtime-native 0.2.0 → 0.3.1
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/NOTICE +2 -0
- package/README.md +63 -0
- package/android/README.md +2 -2
- package/android/app/build.gradle.kts +177 -30
- package/android/app/src/main/AndroidManifest.xml +8 -1
- package/android/app/src/main/java/com/mystral/engine/MystralActivity.java +190 -2
- package/android/app/src/main/java/com/mystral/engine/TnUiOverlay.java +261 -0
- package/android/app/src/main/res/values/branding.xml +12 -0
- package/android/app/src/main/res/values/themes.xml +2 -0
- package/android/gradle.properties +1 -1
- package/package.json +44 -8
- package/scripts/asset-preflight.mjs +442 -0
- package/scripts/bundle.mjs +178 -48
- package/scripts/check-source-list.mjs +90 -0
- package/scripts/device-preflight.mjs +456 -0
- package/scripts/install-prebuilt.mjs +326 -30
- package/scripts/package-android.mjs +414 -23
- package/scripts/package-desktop.mjs +132 -12
- package/scripts/package-ios.mjs +249 -25
- package/scripts/physical-device-evidence.mjs +644 -0
- package/scripts/production-evidence.mjs +101 -2
- package/scripts/profile-production.mjs +544 -115
- package/scripts/qualify-physical-mobile.mjs +1327 -0
- package/scripts/verify-starter-desktop.mjs +140 -16
- package/scripts/xvfb.sh +68 -0
|
@@ -6,6 +6,11 @@ import { join, relative, resolve } from 'node:path';
|
|
|
6
6
|
|
|
7
7
|
export const PRODUCTION_EVIDENCE_VERSION = 'productionEvidenceV1';
|
|
8
8
|
export const REQUIRED_LIFECYCLE_MARKERS = ['run-start', 'first-workload-frame', 'clean-end'];
|
|
9
|
+
export const REGRESSION_COLLECTION_PROFILE = Object.freeze({
|
|
10
|
+
coldStarts: 5,
|
|
11
|
+
durationSeconds: 30,
|
|
12
|
+
minFrameSamples: 1_000,
|
|
13
|
+
});
|
|
9
14
|
|
|
10
15
|
export class ProductionEvidenceError extends Error {
|
|
11
16
|
constructor(code, message, status = 'BLOCKED') {
|
|
@@ -48,6 +53,8 @@ export function evaluateFrameBudget(metrics, budget = {}) {
|
|
|
48
53
|
const mean = finiteMetric(metrics.meanFps) ? metrics.meanFps : meanFps(metrics.frameIntervalsMs);
|
|
49
54
|
const p95 = finiteMetric(metrics.p95FrameMs) ? metrics.p95FrameMs : nearestRank(metrics.frameIntervalsMs, 0.95);
|
|
50
55
|
const p99 = finiteMetric(metrics.p99FrameMs) ? metrics.p99FrameMs : nearestRank(metrics.frameIntervalsMs, 0.99);
|
|
56
|
+
const medianFrameMs = nearestRank(metrics.frameIntervalsMs, 0.5);
|
|
57
|
+
if (budget.minFps !== undefined && (!finiteMetric(medianFrameMs) || Math.round(100_000 / medianFrameMs) / 100 < budget.minFps)) failures.push('TN_PROD_PERFORMANCE_BUDGET');
|
|
51
58
|
const floors = metrics.oneSecondFps ?? oneSecondFrameFloors(metrics.intervals ?? []);
|
|
52
59
|
const drawCalls = maximumMetric(metrics, 'drawCalls');
|
|
53
60
|
const triangles = maximumMetric(metrics, 'triangles');
|
|
@@ -63,9 +70,74 @@ export function evaluateFrameBudget(metrics, budget = {}) {
|
|
|
63
70
|
return { drawCalls, failures: [...new Set(failures)], floors, mean, p95, p99, triangles };
|
|
64
71
|
}
|
|
65
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Regression runs are deliberately stricter than the long-standing production report. A number
|
|
75
|
+
* is useful only after the workload is ready, the warmup buffer was reset, and both the monotonic
|
|
76
|
+
* wall clock and presented-frame clock have supplied the requested window. These checks are kept
|
|
77
|
+
* here so browser, desktop, Android, and iOS collectors share one fail-closed contract.
|
|
78
|
+
*/
|
|
79
|
+
export function regressionCollectionCodes(input) {
|
|
80
|
+
if (input.execution?.profile !== 'regression') return [];
|
|
81
|
+
const codes = [];
|
|
82
|
+
const metrics = input.metrics ?? {};
|
|
83
|
+
const execution = input.execution ?? {};
|
|
84
|
+
const frameSamples = metrics.frameIntervalsMs;
|
|
85
|
+
const frameCount = Array.isArray(frameSamples) ? frameSamples.length : 0;
|
|
86
|
+
const windows = metrics.runWindows;
|
|
87
|
+
const completeWindows = Array.isArray(windows)
|
|
88
|
+
&& windows.length === 1
|
|
89
|
+
&& windows.every((window) => isRecord(window)
|
|
90
|
+
&& Number.isInteger(window.sampleCount)
|
|
91
|
+
&& window.sampleCount >= REGRESSION_COLLECTION_PROFILE.minFrameSamples
|
|
92
|
+
&& finiteMetric(window.durationSeconds)
|
|
93
|
+
&& window.durationSeconds >= REGRESSION_COLLECTION_PROFILE.durationSeconds);
|
|
94
|
+
const windowSampleCount = Array.isArray(windows)
|
|
95
|
+
? windows.reduce((total, window) => total + (isRecord(window) && Number.isInteger(window.sampleCount) ? window.sampleCount : 0), 0)
|
|
96
|
+
: 0;
|
|
97
|
+
const duration = metrics.durationSeconds;
|
|
98
|
+
if (frameCount < REGRESSION_COLLECTION_PROFILE.minFrameSamples
|
|
99
|
+
|| !completeWindows
|
|
100
|
+
|| windowSampleCount < REGRESSION_COLLECTION_PROFILE.minFrameSamples
|
|
101
|
+
|| !finiteMetric(duration)
|
|
102
|
+
|| duration < REGRESSION_COLLECTION_PROFILE.durationSeconds) {
|
|
103
|
+
codes.push('TN_PROD_REGRESSION_WINDOW');
|
|
104
|
+
}
|
|
105
|
+
if (execution.readiness?.ready !== true || execution.readiness?.sampleReset !== true) {
|
|
106
|
+
codes.push('TN_PROD_READINESS_MISSING');
|
|
107
|
+
}
|
|
108
|
+
if (execution.warmupReset !== true) codes.push('TN_PROD_STARTUP_CONTAMINATION');
|
|
109
|
+
if (metrics.clockSource !== 'monotonic-performance'
|
|
110
|
+
|| !strictlyIncreasing(metrics.clockSamplesMs)
|
|
111
|
+
|| metrics.fixedTick === true) {
|
|
112
|
+
codes.push('TN_PROD_CLOCK_INVALID');
|
|
113
|
+
}
|
|
114
|
+
if (metrics.presentationClockSource !== 'raf-presentation'
|
|
115
|
+
|| !strictlyIncreasing(metrics.presentationSamplesMs)) {
|
|
116
|
+
codes.push('TN_PROD_PRESENTATION_CLOCK_INVALID');
|
|
117
|
+
}
|
|
118
|
+
if (!Number.isInteger(execution.coldStarts)
|
|
119
|
+
|| execution.coldStarts < REGRESSION_COLLECTION_PROFILE.coldStarts
|
|
120
|
+
|| !Array.isArray(metrics.startupSamplesMs)
|
|
121
|
+
|| metrics.startupSamplesMs.length < REGRESSION_COLLECTION_PROFILE.coldStarts) {
|
|
122
|
+
codes.push('TN_PROD_STARTUP_SAMPLES_INCOMPLETE');
|
|
123
|
+
}
|
|
124
|
+
if (metrics.motion?.moved !== true || metrics.motion?.movingObjects <= 0) {
|
|
125
|
+
codes.push('TN_PROD_MOTION_MISSING');
|
|
126
|
+
}
|
|
127
|
+
if (metrics.pixels?.nonBlank !== true || metrics.pixels?.changed !== true) {
|
|
128
|
+
codes.push('TN_PROD_PIXEL_EVIDENCE_MISSING');
|
|
129
|
+
}
|
|
130
|
+
if (String(input.target ?? '').includes('physical')
|
|
131
|
+
&& (metrics.thermal?.complete !== true || metrics.thermal?.thermallyConfounded === true)) {
|
|
132
|
+
codes.push('TN_PROD_THERMAL_STATE_INVALID');
|
|
133
|
+
}
|
|
134
|
+
return [...new Set(codes)];
|
|
135
|
+
}
|
|
136
|
+
|
|
66
137
|
export function evaluateProductionEvidence(input, options = {}) {
|
|
67
138
|
validateProductionEvidence(input);
|
|
68
139
|
const codes = new Set(input.codes ?? []);
|
|
140
|
+
const advisoryCodes = new Set(input.advisoryCodes ?? []);
|
|
69
141
|
const markers = new Set(markerNames(input.markers));
|
|
70
142
|
const diagnosticCodes = new Set([
|
|
71
143
|
'TN_PROD_ANDROID_ANR',
|
|
@@ -87,14 +159,22 @@ export function evaluateProductionEvidence(input, options = {}) {
|
|
|
87
159
|
}
|
|
88
160
|
if (input.source.dirty === true && input.source.diffSha === undefined) codes.add('TN_PROD_SOURCE_DIFF_MISSING');
|
|
89
161
|
const frameBudget = evaluateFrameBudget(input.metrics ?? {}, input.budget ?? {});
|
|
90
|
-
|
|
162
|
+
const advisoryTiming = input.execution?.performanceEvaluation === 'advisory';
|
|
163
|
+
for (const code of frameBudget.failures) {
|
|
164
|
+
if (advisoryTiming) advisoryCodes.add(code);
|
|
165
|
+
else codes.add(code);
|
|
166
|
+
}
|
|
167
|
+
for (const code of regressionCollectionCodes(input)) codes.add(code);
|
|
91
168
|
if (input.metrics?.thermal?.complete === false || input.metrics?.battery?.complete === false) codes.add('TN_PROD_RESOURCE_SAMPLES_INCOMPLETE');
|
|
92
169
|
if (input.metrics?.thermal?.severeSeconds >= 60) codes.add('TN_PROD_THERMAL_BUDGET');
|
|
93
170
|
if (input.metrics?.durationSeconds !== undefined && input.budget?.minDurationSeconds !== undefined && input.metrics.durationSeconds < input.budget.minDurationSeconds) codes.add('TN_PROD_MARKER_MISSING');
|
|
94
171
|
const startupP95 = input.metrics?.startupP95Ms
|
|
95
172
|
?? nearestRank(input.metrics?.startupSamplesMs, 0.95)
|
|
96
173
|
?? input.metrics?.startupMs;
|
|
97
|
-
if (input.budget?.maxStartupMs !== undefined && (startupP95 === undefined || startupP95 > input.budget.maxStartupMs))
|
|
174
|
+
if (input.budget?.maxStartupMs !== undefined && (startupP95 === undefined || startupP95 > input.budget.maxStartupMs)) {
|
|
175
|
+
if (advisoryTiming) advisoryCodes.add('TN_PROD_STARTUP_BUDGET');
|
|
176
|
+
else codes.add('TN_PROD_STARTUP_BUDGET');
|
|
177
|
+
}
|
|
98
178
|
const memory = input.metrics?.memory;
|
|
99
179
|
if (memory !== undefined) {
|
|
100
180
|
const firstMedian = memory.first15MedianBytes;
|
|
@@ -125,6 +205,11 @@ export function evaluateProductionEvidence(input, options = {}) {
|
|
|
125
205
|
if (input.audioClaim === 'claimed' && typeof input.audioEvidenceSha256 !== 'string') codes.add('TN_PROD_AUDIO_EVIDENCE');
|
|
126
206
|
const blockedCodes = [...codes].filter((code) => [
|
|
127
207
|
'TN_PROD_MARKER_MISSING',
|
|
208
|
+
'TN_PROD_REGRESSION_WINDOW',
|
|
209
|
+
'TN_PROD_READINESS_MISSING',
|
|
210
|
+
'TN_PROD_STARTUP_CONTAMINATION',
|
|
211
|
+
'TN_PROD_CLOCK_INVALID',
|
|
212
|
+
'TN_PROD_PRESENTATION_CLOCK_INVALID',
|
|
128
213
|
'TN_PROD_SOURCE_SHA_MISMATCH',
|
|
129
214
|
'TN_PROD_SOURCE_DIFF_MISSING',
|
|
130
215
|
'TN_PROD_RESOURCE_SAMPLES_INCOMPLETE',
|
|
@@ -137,11 +222,15 @@ export function evaluateProductionEvidence(input, options = {}) {
|
|
|
137
222
|
'TN_PROD_PLAYTEST_FAILED',
|
|
138
223
|
'TN_PROD_RENDER_SAMPLES_INCOMPLETE',
|
|
139
224
|
'TN_PROD_STARTUP_SAMPLES_INCOMPLETE',
|
|
225
|
+
'TN_PROD_MOTION_MISSING',
|
|
226
|
+
'TN_PROD_PIXEL_EVIDENCE_MISSING',
|
|
227
|
+
'TN_PROD_THERMAL_STATE_INVALID',
|
|
140
228
|
].includes(code));
|
|
141
229
|
const failureCodes = [...codes].filter((code) => code.startsWith('TN_PROD_') && !blockedCodes.includes(code));
|
|
142
230
|
const status = blockedCodes.length > 0 ? 'BLOCKED' : failureCodes.length > 0 ? 'FAIL' : 'PASS';
|
|
143
231
|
return {
|
|
144
232
|
...input,
|
|
233
|
+
...(advisoryCodes.size === 0 ? {} : { advisoryCodes: [...advisoryCodes] }),
|
|
145
234
|
codes: [...codes],
|
|
146
235
|
metrics: {
|
|
147
236
|
...input.metrics,
|
|
@@ -203,6 +292,9 @@ export function validateProductionEvidence(value) {
|
|
|
203
292
|
if (value.diagnosticArtifacts !== undefined && !Array.isArray(value.diagnosticArtifacts)) {
|
|
204
293
|
throw new ProductionEvidenceError('TN_PROD_EVIDENCE_INVALID', 'Evidence diagnosticArtifacts must be an array when present.');
|
|
205
294
|
}
|
|
295
|
+
if (value.advisoryCodes !== undefined && (!Array.isArray(value.advisoryCodes) || value.advisoryCodes.some((code) => typeof code !== 'string' || code.length === 0))) {
|
|
296
|
+
throw new ProductionEvidenceError('TN_PROD_EVIDENCE_INVALID', 'Evidence advisoryCodes must be a string array when present.');
|
|
297
|
+
}
|
|
206
298
|
assertPrivacySafe(value);
|
|
207
299
|
}
|
|
208
300
|
|
|
@@ -231,6 +323,13 @@ function finiteMetric(value) {
|
|
|
231
323
|
return typeof value === 'number' && Number.isFinite(value);
|
|
232
324
|
}
|
|
233
325
|
|
|
326
|
+
function strictlyIncreasing(values) {
|
|
327
|
+
return Array.isArray(values)
|
|
328
|
+
&& values.length > 1
|
|
329
|
+
&& values.every((value, index) => finiteMetric(value)
|
|
330
|
+
&& (index === 0 || value > values[index - 1]));
|
|
331
|
+
}
|
|
332
|
+
|
|
234
333
|
function maximumMetric(metrics, key) {
|
|
235
334
|
if (Array.isArray(metrics.intervals) && metrics.intervals.length > 0) {
|
|
236
335
|
const values = metrics.intervals.map((sample) => sample?.[key]);
|