{"record":{"id":"10838b8c4a261a9a","repo":"stablyai/orca","slug":"emulator-error-10838b","errorCode":"emulator_error","errorMessage":"Could not read screen size for ${serial}.","messagePattern":"Could not read screen size for (.+?)\\.","errorType":"exception","errorClass":"EmulatorError","httpStatus":null,"severity":"error","filePath":"src/main/emulator/backends/android-emulator-backend.ts","lineNumber":323,"sourceCode":"  // Boots an AVD (by name) when not running and waits for boot; returns the serial.\n  async ensureBooted(deviceOrName: string): Promise<string> {\n    return bootAndroidDevice(this.runner, this.requireSdk(), deviceOrName, {\n      bootTimeoutMs: this.bootTimeoutMs,\n      pollIntervalMs: this.pollIntervalMs,\n      sleep: this.sleep\n    })\n  }\n\n  private async getScreenSize(serial: string): Promise<DeviceScreenSize> {\n    const cached = this.screenSizes.get(serial)\n    if (cached) {\n      return cached\n    }\n    const sdk = this.requireSdk()\n    const result = await this.runner(sdk.adb, wmSizeArgs(serial))\n    const size = parseWmSize(result.stdout)\n    if (!size) {\n      throw new EmulatorError('emulator_error', `Could not read screen size for ${serial}.`)\n    }\n    this.screenSizes.set(serial, size)\n    return size\n  }\n\n  private requireSdk(): AndroidSdkPaths {\n    return this.sdkState.require()\n  }\n}\n\nfunction defaultSleep(ms: number): Promise<void> {\n  return new Promise((resolve) => setTimeout(resolve, ms))\n}\n","sourceCodeStart":305,"sourceCodeEnd":337,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/emulator/backends/android-emulator-backend.ts#L305-L337","documentation":"Thrown by AndroidEmulatorBackend.getScreenSize when `adb shell wm size` succeeds (no adb error) but parseWmSize cannot extract a usable size from the output. The size is cached per serial after a successful parse, so this only fires on the first attempt for a given device. It indicates the wm size output format was unparseable.","triggerScenarios":"getScreenSize(serial) on a serial with no cached entry; runner(sdk.adb, wmSizeArgs(serial)) returns code 0 but parseWmSize(result.stdout) yields null. Subsequent calls hit the cache and do not re-throw.","commonSituations":"An API level where `wm size` output differs from the expected 'Physical size: WxH' format; a device whose display service is not ready yet (wm returns empty/garbled); a headless emulator with no display configured; a resolution parsing edge case (unusual density/override lines).","solutions":["Run `adb -s <serial> shell wm size` manually and compare its output to what parseWmSize expects.","Retry after a short delay if the display service may not be ready (common right after boot).","Ensure the emulator/AVD has a display configured (headless AVDs without a skin can return no size).","If the format legitimately differs on your API level, extend parseWmSize to handle it."],"exampleFix":"// before: calling getScreenSize immediately after boot\nconst size = await backend.getScreenSize(serial)\n// after: let the display settle, then read\nawait sleep(2000)\nconst size = await backend.getScreenSize(serial)","handlingStrategy":"retry","validationCode":"// Sanity-check wm size output before relying on it.\nfunction wmSizeLooksValid(stdout: string): boolean {\n  return /Physical size:\\s*\\d+x\\d+/i.test(stdout)\n}","typeGuard":"import { EmulatorError } from '../emulator-errors'\nfunction isScreenSizeError(e: unknown): e is EmulatorError {\n  return e instanceof EmulatorError && /read screen size/i.test(e.message)\n}","tryCatchPattern":"for (let i = 0; i < 3; i++) {\n  try { return await backend.getScreenSize(serial) }\n  catch (e) {\n    if (isScreenSizeError(e) && i < 2) { await sleep(1000); continue }\n    throw e\n  }\n}","preventionTips":["Let the display settle after boot before reading wm size.","Ensure the AVD has a display/skin configured.","Extend parseWmSize if your API level emits a different wm size format."],"tags":["android","display","wm-size","emulator","parsing"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}