Skip to content

fix: bound heap spikes behind OutOfMemoryError on low-RAM devices - #46

Merged
Dvorinka merged 1 commit into
mainfrom
fix/oom-low-memory-devices
Nov 9, 2026
Merged

Dvorinka merged 1 commit into
mainfrom
fix/oom-low-memory-devices

Conversation

@Dvorinka

@Dvorinka Dvorinka commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Summary

Two OutOfMemoryError reports on 0.19.19 (44) — Samsung SM-A305F, Android 11, 192MB heap — even though the notification-extras fix from #44 shipped in this version. The binder-thread stack (ThreadLocalWorkSource.setUid inside Binder.execTransact) is only the victim allocation: the heap was already full and fragmented, so whichever thread allocated next died.

This PR caps the remaining unbounded heap paths found in the codebase:

  • Full-resolution bitmap decodes — WallpaperActionEditor and GlyphEditorScreen (image/GIF import + clipboard paste) called BitmapFactory.decodeStream / ImageDecoder.decodeBitmap at native resolution before scaling. A 12–50MP photo is 48–200MB — instantly fatal on a 192MB heap, and the wallpaper thumbnail loads automatically when the action editor opens. New decodeSampledBitmap helper bounds the decode to ~1–2K px via inSampleSize.
  • WebView leak — IntegratedBrowserScreen never destroyed its WebView; every visit kept the renderer and page state alive. Now onRelease calls destroy(). fetchText (JSON download import) is also capped at 1M chars instead of readText().
  • HttpRequest action — drained the entire response body with readBytes(); now capped at 256KB (disconnect() follows anyway, so connection reuse was never real).
  • Notification shade refresh — every post/remove re-fetched getActiveNotifications() and un-parceled every active notification's extras. Bursts now debounce 500ms; the existing generation/mutex logic still guarantees only the freshest snapshot wins.
  • android:largeHeap="true" — raises the ceiling (~512MB) on 3–4GB devices. Headroom, not a root-cause fix — the caps above are the actual fixes.

Type of change

  • Bug fix (non-breaking)

Affected modules

  • automation-android
  • capabilities
  • ui
  • app

Testing

  • Unit tests pass (./gradlew test)
  • Lint passes (./gradlew :app:lintPlayDebug — 0 errors)
  • Debug build succeeds (./gradlew :app:assemblePlayDebug)
  • Tested on device / emulator — not run; changes are defensive caps, behavior unchanged on healthy devices

Device compatibility

No Glyph/device-specific behavior changed. Most relevant on low-RAM devices (the reporting device is a 3GB Samsung A30).

Checklist

  • Code follows existing style and conventions
  • No secrets / API keys committed
  • CHANGELOG.md updated (if user-facing)

Generated with Devin

0.19.19 still OOMed on a Samsung A30 (Android 11, 192MB heap). The
notification-extras guard stopped the fatal read, but the binder-thread
stack is only the victim allocation — several unbounded paths could
fill the heap first:

- Wallpaper and glyph-editor image imports decoded full-resolution
  bitmaps (a modern photo is tens to hundreds of MB) before scaling.
- The in-app browser never destroyed its WebView, leaking a renderer
  and page state on every visit.
- HttpRequest actions drained the entire response body into memory.
- Every notification post/remove re-unparceled every active
  notification's extras; bursts stacked the parcel churn.

Decodes now go through a sampled-decode helper (~1-2k px ceiling),
the browser WebView is destroyed on release, the response drain caps
at 256KB, and shade refreshes debounce 500ms so bursts collapse into
one unparcel pass. largeHeap is enabled for headroom on 3-4GB devices.

Authored By: TDvorak <info@tdvorak.dev>

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@vercel

vercel Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nothing-modes Ready Ready Preview Nov 9, 2026 2:42pm UTC

@mira-tdvorak

mira-tdvorak Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Mira PR Walkthrough


❌ Review failed — click for details

The code review failed to complete due to an unexpected error.

Stage: Code review
Error type: LLMError
Message: LLM tool-call failed

@Dvorinka
Dvorinka merged commit c4bfac9 into main Nov 9, 2026
2 of 5 checks passed

This branch was successfully deployed

1 active deployment
Preview — 720519e4 Deployed Nov 9, 2026 by vercel[bot]
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