A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
test(native): fix what the first real matrix showed was wrong with the instrument
esengine99cea4d5311b
diff --git a/.github/workflows/android-compat.yml b/.github/workflows/android-compat.ymlindex 970793ebd..aff24cdf8 100644--- a/.github/workflows/android-compat.yml+++ b/.github/workflows/android-compat.yml@@ -276,7 +276,11 @@ jobs:name: Android API ${{ matrix.api }}needs: [versions, apk]runs-on: ubuntu-latest- timeout-minutes: 45+ # A version that works finishes in about three minutes and one that crashes in+ # seven. API 29 once failed to boot at all and sat here for the full 45, so the+ # cap is set near what a real run costs: a stuck emulator should be reported as+ # "no data" quickly, not held open in case it recovers.+ timeout-minutes: 20strategy:# A compatibility matrix whose whole output is "which versions work" must# run every version even after one fails. fail-fast here would report the@@ -404,6 +408,7 @@ jobs:node tools/android-compat-report.mjs \--dir build/compat \--template-source '${{ needs.apk.outputs.template-from }}' \+ --expect '${{ needs.versions.outputs.matrix }}' \${{ steps.shots.outputs.base && format('--shots-base {0}', steps.shots.outputs.base) || '' }} \--out compat-comment.mdcat compat-comment.md >> "$GITHUB_STEP_SUMMARY"diff --git a/tools/android-compat-report.mjs b/tools/android-compat-report.mjsindex 107750ace..3b93409f3 100644--- a/tools/android-compat-report.mjs+++ b/tools/android-compat-report.mjs@@ -70,6 +70,22 @@ if (!runs.length) {process.exit(0);}+// A version whose job never filed anything must still get a row. The first real+// run lost API 29 to a job timeout and the table simply said "7 versions" — an+// absent row reads as "that version does not exist", which is the one conclusion+// a compatibility matrix must never imply by accident.+if (opts.expect) {+ const seen = new Set(runs.map((r) => r.api));+ const wanted = String(opts.expect).replace(/[[\]\s]/g, '').split(',').map(Number).filter(Boolean);+ for (const api of wanted) {+ if (seen.has(api)) continue;+ runs.push({+ api, release: null, label: `api${api}`, ok: false, missing: true,+ why: '没测到 — 这个 job 没跑完(模拟器没启动起来,或 job 超时)',+ });+ }+}+// API level ascending, so the table reads oldest-first — the direction a// compatibility floor is read in.runs.sort((a, b) => (a.api ?? 0) - (b.api ?? 0) || String(a.label).localeCompare(String(b.label)));@@ -82,13 +98,20 @@ const frames = (f) => (!f ? '—' : `${f.medianMs} / ${f.p95Ms} ms`);// The label is `api<NN>-<example>`; the app column only appears when more than// one was run, because a column with one repeated value is noise.const appOf = (r) => String(r.label ?? '').replace(/^api\d+-?/, '') || '—';-const apps = [...new Set(runs.map(appOf))];+// Placeholders for versions that filed nothing carry no app name, and counting+// their '—' as one would flip a single-app run into per-app mode.+const apps = [...new Set(runs.filter((r) => !r.missing).map(appOf))];const perApp = apps.length > 1;+// `am start -W`'s TotalTime and logcat's "Displayed" are the SAME measurement —+// launch to the activity being fully drawn — and the first run proved it, agreeing+// to the millisecond on all six versions that produced data. Both are still+// collected into the JSON as a cross-check, but showing them as two columns+// claimed two independent clocks where there is one.const rows = runs.map((r) => {const s = r.startup ?? {};return `| ${r.release ?? '?'} | ${r.api ?? '?'} ${perApp ? `| ${appOf(r)} ` : ''}`- + `| ${ms(s.readyMs)} | ${ms(s.displayedMs)} | ${ms(s.totalMs)} `+ + `| ${ms(s.readyMs)} | ${ms(s.totalMs)} `+ `| ${mb(r.memory?.totalPssKb)} | ${mb(r.memory?.graphicsKb)} | ${pct(r.cpu)} | ${frames(r.frames)} `+ `| ${r.ok ? '✓' : `✗ ${r.why || 'failed'}`} |`;});@@ -111,16 +134,20 @@ if (opts.templateSource === 'release') {out.push('运行时模板**从这个分支构建** —— 测的是这里改的代码,不是已发布的版本。');}out.push('');-out.push(`| Android | API ${perApp ? '| app ' : ''}| ready | 首帧上屏 | am start | PSS | Graphics | CPU | 帧间隔 中位/p95 | 结果 |`);-out.push(`|---|---|${perApp ? '---|' : ''}---|---|---|---|---|---|---|---|`);+out.push(`| Android | API ${perApp ? '| app ' : ''}| ready | 启动到首帧 | PSS | Graphics | CPU | 帧间隔 中位/p95 | 结果 |`);+out.push(`|---|---|${perApp ? '---|' : ''}---|---|---|---|---|---|---|`);out.push(...rows);out.push('');-const broken = runs.filter((r) => !r.ok);+// "ran and broke" and "never ran" are different findings and must not share a+// count. The first is a result about Android; the second is a result about this+// pipeline, and reporting them together lets an untested version pass for a+// tested one.+const broken = runs.filter((r) => !r.ok && !r.missing);+const untested = runs.filter((r) => r.missing);+if (broken.length) {- const brokenVersions = new Set(broken.map((r) => r.api));- out.push(`**${brokenVersions.size}/${versions.size} 个 Android 版本没跑起来**`- + `(${broken.length}/${runs.length} 次运行失败)。`);+ out.push(`**${new Set(broken.map((r) => r.api)).size}/${versions.size} 个 Android 版本装上了但没跑起来。**`);out.push('');for (const r of broken) {out.push(`- **Android ${r.release ?? '?'} (API ${r.api ?? '?'})**`@@ -130,6 +157,14 @@ if (broken.length) {out.push('');}+if (untested.length) {+ out.push(`**${untested.length} 个版本没有数据 —— 这是关于这条流水线的结论,不是关于 Android 的。**`);+ out.push('这些版本既没被证明可用,也没被证明有问题。');+ out.push('');+ for (const r of untested) out.push(`- **API ${r.api}** — ${r.why}`);+ out.push('');+}+out.push('### 截图 — 需要人工看');out.push('');out.push('这里没有任何像素判据。上面的表只回答了「装上了、起来了、没报错」;');diff --git a/tools/verify-native-boot.mjs b/tools/verify-native-boot.mjsindex 3fad52a58..23706ed6f 100644--- a/tools/verify-native-boot.mjs+++ b/tools/verify-native-boot.mjs@@ -233,6 +233,16 @@ function androidDriver(opts) {*/async metrics(launchOutput) {const notes = [];+ // The DEVICE first, before anything that depends on the app being+ // alive. Read after the early return below, the one row that matters+ // most — the version that crashed — came out labelled "Android ? (API+ // ?)", which is the row a reader needs the version on.+ const device = {+ api: Number(trySh(adb, ['shell', 'getprop', 'ro.build.version.sdk']).stdout.trim()) || null,+ release: trySh(adb, ['shell', 'getprop', 'ro.build.version.release']).stdout.trim() || null,+ renderer: /GLES:\s*(.+)/.exec(+ trySh(adb, ['shell', 'dumpsys', 'SurfaceFlinger']).stdout ?? '')?.[1]?.trim() ?? null,+ };const pid = trySh(adb, ['shell', 'pidof', APP_ID]).stdout.trim().split(/\s+/)[0] || null;const startup = {@@ -250,11 +260,16 @@ function androidDriver(opts) {if (!pid) {notes.push('the process was gone before anything could be sampled');- return { startup, memory: null, cpu: null, frames: null, notes };+ return { ...device, startup, memory: null, cpu: null, frames: null, notes };}const meminfo = trySh(adb, ['shell', 'dumpsys', 'meminfo', APP_ID]).stdout ?? '';- const memRow = (label) => firstNumber(new RegExp(`^\\s*${label}\\s+(\\d+)`, 'm'), meminfo);+ // The colon is optional because the same figure is labelled both ways in+ // one dumpsys: the per-process table writes "Native Heap 1234" and+ // the App Summary below it writes "Native Heap: 1234". Requiring+ // whitespace after the label found neither Graphics nor Native Heap, so+ // Dawn's Vulkan allocations read as "—" on every version.+ const memRow = (label) => firstNumber(new RegExp(`^\\s*${label}:?\\s+(\\d+)`, 'm'), meminfo);const memory = {// "TOTAL PSS:" is the App Summary line on API 29+; older releases// label the same figure "TOTAL" in the table above it.@@ -316,19 +331,7 @@ function androidDriver(opts) {if (!frames) notes.push('SurfaceFlinger had too few presented frames to time');}- // Recorded rather than judged. On a runner this is SwiftShader — a CPU- // rasteriser — so the frame times above are a software renderer's, and- // GPU utilisation and power do not exist to be read at all. Comparing- // them across Android versions is still meaningful; reading them as- // device performance is not.- const renderer = /GLES:\s*(.+)/.exec(- trySh(adb, ['shell', 'dumpsys', 'SurfaceFlinger']).stdout ?? '')?.[1]?.trim() ?? null;-- return {- api: Number(trySh(adb, ['shell', 'getprop', 'ro.build.version.sdk']).stdout.trim()) || null,- release: trySh(adb, ['shell', 'getprop', 'ro.build.version.release']).stdout.trim() || null,- startup, memory, cpu, frames, renderer, notes,- };+ return { ...device, startup, memory, cpu, frames, notes };},diagnostics() {return [