also looking at this
perf(android): ship libcraft.so without its DWARF, and keep the DWARF for symbols
#217
6 files
+235
-14
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | import type { LegOutcome, RunnerOptions } from './types' |
| 2 | import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs' | |
| 2 | import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs' | |
| 3 | 3 | import { join } from 'node:path' |
| 4 | 4 | import { init } from '../../packages/android/src/index' |
| 5 | import { androidDeclines, awaitedNeeds, DISMISS_SHARE_MENU, evaluateRun, hasTerminated, runtimePermissionGranted, shareMenuInFront } from './protocol' | |
| 5 | import { androidDeclines, awaitedNeeds, DISMISS_SHARE_MENU, elfSectionNames, evaluateRun, hasTerminated, runtimePermissionGranted, shareMenuInFront, strippedLibraryProblems } from './protocol' | |
| 6 | 6 | import { command, driverPage, waitForFile } from './support' |
| 7 | 7 | |
| 8 | 8 | /** |
| @@ -321,6 +321,20 @@ export async function runAndroid(options: RunnerOptions): Promise<LegOutcome[]> | ||
| 321 | 321 | ) |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | // What every generated app will ship, checked before any leg uses it. The | |
| 325 | // runtime leg asserts the library loads and answers; this asserts it is the | |
| 326 | // release shape #204 settled on, stripped with its DWARF kept beside it, | |
| 327 | // because a regression there costs every APK megabytes and fails no case. | |
| 328 | const symbolsPath = join(runtimeDir, '..', 'android-symbols', 'x86_64', 'libcraft.so.debug') | |
| 329 | const libraryProblems = strippedLibraryProblems( | |
| 330 | elfSectionNames(new Uint8Array(readFileSync(abi))), | |
| 331 | existsSync(symbolsPath) ? elfSectionNames(new Uint8Array(readFileSync(symbolsPath))) : null, | |
| 332 | ) | |
| 333 | if (libraryProblems.length) | |
| 334 | throw new Error(`${abi}: ${libraryProblems.join('; ')}`) | |
| 335 | const megabytes = (path: string) => `${(statSync(path).size / 1024 / 1024).toFixed(2)} MB` | |
| 336 | console.log(`x86_64/libcraft.so ships at ${megabytes(abi)}; its symbols are ${megabytes(symbolsPath)} beside it`) | |
| 337 | ||
| 324 | 338 | const outcomes: LegOutcome[] = [] |
| 325 | 339 | for (const leg of legs(runtimeDir)) { |
| 326 | 340 | try { |