also looking at this
feat(maps): add key-free native Android maps and shared map controls
#363
28 files
+1857
-481
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -12,6 +12,8 @@ export interface AndroidEmulatorOptions { | ||
| 12 | 12 | temporaryDirectory?: string |
| 13 | 13 | port?: number |
| 14 | 14 | acceptLicenses?: boolean |
| 15 | /** Readiness budget in milliseconds, from 1 second to 30 minutes; defaults to 10 minutes. */ | |
| 16 | bootTimeoutMs?: number | |
| 15 | 17 | env?: Record<string, string | undefined> |
| 16 | 18 | } |
| 17 | 19 | |
| @@ -33,6 +35,9 @@ export async function createAndroidEmulator(options: AndroidEmulatorOptions): Pr | ||
| 33 | 35 | throw new Error('The Android system image must match the host architecture') |
| 34 | 36 | if (options.acceleration === 'software' && process.arch !== 'x64') |
| 35 | 37 | throw new Error('Android software emulation requires an x86_64 host and system image') |
| 38 | const bootTimeoutMs = options.bootTimeoutMs ?? 600_000 | |
| 39 | if (!Number.isSafeInteger(bootTimeoutMs) || bootTimeoutMs < 1000 || bootTimeoutMs > 1_800_000) | |
| 40 | throw new Error('Android bootTimeoutMs must be between 1000 and 1800000 milliseconds') | |
| 36 | 41 | const port = options.port ?? 5558 |
| 37 | 42 | if (!Number.isInteger(port) || port < 5554 || port > 5682 || port % 2 !== 0) throw new Error('Android console ports must be even and between 5554 and 5682') |
| 38 | 43 | const sdk = resolve(options.sdkRoot) |
| @@ -103,9 +108,9 @@ export async function createAndroidEmulator(options: AndroidEmulatorOptions): Pr | ||
| 103 | 108 | created = true |
| 104 | 109 | log = openSync(join(artifacts, 'emulator.log'), 'w') |
| 105 | 110 | child = Bun.spawn([executable, '-avd', name, '-port', String(port), '-no-window', '-no-snapshot', '-no-audio', '-no-boot-anim', '-gpu', 'software', '-memory', '2048', '-cores', '2', '-accel', options.acceleration === 'software' ? 'off' : 'on'], { env, stdout: log, stderr: log }) |
| 106 | const identity = { image: options.image, acceleration: options.acceleration, accelerationProbeExitCode: acceleration.code, serial, avdDirectory: env.ANDROID_AVD_HOME, emulatorPid: child.pid } | |
| 111 | const identity = { image: options.image, acceleration: options.acceleration, bootTimeoutMs, accelerationProbeExitCode: acceleration.code, serial, avdDirectory: env.ANDROID_AVD_HOME, emulatorPid: child.pid } | |
| 107 | 112 | await Bun.write(join(artifacts, 'android-emulator.json'), JSON.stringify(identity, null, 2) + '\n') |
| 108 | const deadline = Date.now() + 600_000 | |
| 113 | const deadline = Date.now() + bootTimeoutMs | |
| 109 | 114 | while (Date.now() < deadline && child.exitCode === null) { |
| 110 | 115 | let booted = false |
| 111 | 116 | // Nonzero ADB exits are expected while services initialize. Filesystem, |
| @@ -128,7 +133,7 @@ export async function createAndroidEmulator(options: AndroidEmulatorOptions): Pr | ||
| 128 | 133 | } |
| 129 | 134 | await Bun.sleep(2000) |
| 130 | 135 | } |
| 131 | throw new Error(`The owned Android emulator did not boot; inspect ${artifacts}`) | |
| 136 | throw new Error(`The owned Android emulator did not boot within ${bootTimeoutMs}ms; inspect ${artifacts}`) | |
| 132 | 137 | } |
| 133 | 138 | catch (error) { |
| 134 | 139 | if (child) { |
| @@ -26,7 +26,10 @@ try { | ||
| 26 | 26 | session = await createAndroidEmulator({ |
| 27 | 27 | sdkRoot: join(owned, 'sdk'), sdkmanager, avdmanager, |
| 28 | 28 | image: 'system-images;android-35;google_apis_playstore;x86_64', |
| 29 | // The stock Play image performs real first-boot dex optimization under TCG. | |
| 30 | // Keep every readiness and package assertion; give this software run an explicit bound. | |
| 29 | 31 | acceleration: 'software', artifactsDirectory: artifacts, |
| 32 | bootTimeoutMs: 20 * 60_000, | |
| 30 | 33 | temporaryDirectory: owned, acceptLicenses: true, |
| 31 | 34 | env: { JAVA_HOME: javaHome }, |
| 32 | 35 | }) |