Skip to content

fix(android): avoid duplicate Gateway history and pause OOM restore - #720

Merged
Codename-11 merged 4 commits into
devfrom
fix/android-gateway-memory-700
Oct 15, 2026
Merged

Codename-11 merged 4 commits into
devfrom
fix/android-gateway-memory-700

Conversation

@Codename-11

@Codename-11 Codename-11 commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Sending into or recovering a stored conversation requested a second display transcript over Gateway before the prompt could be submitted, even though Android reads visible history over HTTP. Request upstream history omission on those binding paths and pause automatic conversation reopening after a recorded out-of-memory crash so users can choose a conversation without racing another restart. Refs #700.

The exact Play 1.18.1 mapping identifies the Gateway JSON decoder. The reporter's frame and total heap state are unavailable, so this addresses a verified allocation gap and recovery problem without claiming the exact reported crash is reproduced.

Changes

  • Request omit_messages for cold send, checkpoint resume/activation and mid-turn activation. Keep live output, queued work and open requests; preserve child-watch history and existing HTTP history behavior.
  • Keep automatic restoration paused after dismissing an OOM report for that launch. Preserve saved selection, drafts and checkpoints until explicit action; keep Sessions and socket readiness available.
  • Add real WebSocket payload tests, a bounded-heap JSON reproduction, startup-state tests and an API 36 instrumentation test. Extend the existing history fixture and update conformance for upstream's extracted resume helpers.

Verification

  • Three new transport tests failed before the binding fix with the missing omission option.
  • During implementation, scripts/android-lane.ps1 gradle :app:testSideloadDebugUnitTest --tests '*GatewayChatClientTest' --tests '*GatewayPayloadMemoryTest' --tests '*ChatMemoryRecoveryTest' --tests '*ReliabilityReportTest' passed 221 tests. This includes 209 Gateway tests, one isolated heap test, seven reliability tests and four recovery-state tests.
  • The isolated 128 MiB JVM exhausted memory while decoding a synthetic 32 Mi-character escaped history frame with 16 MiB retained state. Repeated metadata-only decoding passed. Real transport tests kept binding responses below 2 KiB with about 4 MiB of stored synthetic history.
  • python -W error::ResourceWarning -m unittest discover -s test-fixtures/vanilla-gateway/tests -q: 39 passed. python -m unittest discover -s scripts/tests -p check_gateway_scenario_conformance_test.py -q: 16 passed. python -m unittest scripts.tests.android_prepush_test -q: four passed.
  • initial_history_bind resume/activation source conformance passed against clean upstream f9bdaa303e1614245cf1104db52ed0efd90b6f13. This is source conformance, not live upstream execution.
  • Android locale validation (12 catalogs), collection API compatibility, version tracks and localized-doc validation passed. Diff whitespace check passed.
  • Final head 2a02abce9cf42ff11da8ac9237da2cb73fcb27c1: required CI passed, including lint, build, Android tests and the upstream route contract. The expanded sideload and Google Play shards also passed.
  • On that head, scripts/android-lane.ps1 gradle :app:testGooglePlayDebugUnitTest --tests '*GatewayChatClientTest' --tests '*GatewayPayloadMemoryTest' --tests '*ChatMemoryRecoveryTest' --tests '*ReliabilityReportTest' --tests '*NativeDashboardAuthTest' passed 255 tests locally.
  • The complete Google Play shard using every FOCUSED_TESTS filter from scripts/android-prepush.py also passed locally on the final head: 883 tests across 63 classes, zero failures/errors/skips.
  • scripts/android-lane.ps1 gradle :app:standardPhoneApi36SideloadDebugAndroidTest --rerun -Pandroid.testInstrumentationRunnerArguments.class=com.hermesandroid.relay.viewmodel.ChatMemoryRecoveryInstrumentedTest: one passed, zero failures/skips on the final head. Verified report dismissal, lifecycle return and explicit history loading. A prior emulator startup failure was not counted as a test pass. No physical-device test or installation was performed.
  • Release smoke, full lint and both debug assemblies passed on the earlier 08ba9077 candidate. That run's broad Play step hit its 20-minute limit; the successful final-head run above supersedes it.
  • Product server/plugin and Desktop checks: N/A. Documentation changes are internal Markdown; relative link targets were checked. New translations retain their existing AI-translated review status.

Screenshots

Standard Phone API 36 (Pixel 6 profile, x86_64), default dark app theme. Production recovery dialog in the instrumentation harness; text and controls are readable without clipping.

OOM recovery dialog

Compatibility / risk

The omission parameter is supported by current vanilla upstream. Older Gateways may ignore it and still return large payloads. This does not cap or delete HTTP history, and PR #709's compacted-history expansion is not included. In-flight output and arbitrary incoming frames can still be large. Startup recovery requires a readable local crash report and does not certify the reporter's Pixel 8 Pro / Android 17 behavior. #465 and #531 remain separate reports. No versions, dependencies, credentials or server state change.

Lineage / contributor credit

Checklist

  • Target branch is dev, unless this is a dev → main release PR or a focused production-tag hotfix PR to main
  • Scope is focused and related issues/PRs are linked
  • Android changes: lint and focused tests ran, or rationale is listed above
  • Translation changes: locale validation/review ran, or N/A is listed above
  • Server/plugin changes: focused tests ran, or N/A/rationale is listed above
  • Desktop changes: build/tests ran, or N/A/rationale is listed above
  • Docs/site changes: build or link/route checks ran, or N/A/rationale is listed above
  • UI changes were tested on a relevant device/emulator/desktop surface, or the missing proof is stated above
  • Commit messages follow Conventional Commits
  • CHANGELOG.md is updated for user-visible changes, or N/A is listed above
  • Public writing hygiene checked: no secrets, private infrastructure, personal names, or AI/process narration
  • Salvaged/replacement work links source PRs and preserves contributor authorship, or N/A is listed above

@Codename-11
Codename-11 marked this pull request as ready for review October 15, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant