Skip to content

fix: survive oversized notification extras parcels - #44

Merged
Dvorinka merged 2 commits into
mainfrom
fix/notification-extras-oom
Nov 5, 2026
Merged

Dvorinka merged 2 commits into
mainfrom
fix/notification-extras-oom

Conversation

@Dvorinka

@Dvorinka Dvorinka commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • OutOfMemoryError on 0.19.18 (moto g23, Android 14): first read of Notification.extras unparcels the entire bundle, and a notification carrying an oversized parcelled payload (chat history, embedded images) exhausted the 256MB heap inside AutomationNotificationListener.onNotificationPosted.
  • Title/text/sender are now read behind runCatching and degrade to empty strings — pkg, category, group state and timestamps still dispatch the trigger, and the notification log/ shade refresh still run.
  • refreshActiveNotifications is serialized behind a Mutex: each refresh unparcels every active notification's extras, and concurrent runs multiplied the same heap spike during notification bursts.

The two ForegroundServiceDidNotStartInTimeException reports in the same batch are from 0.19.12 and were already fixed by #43 (shipped in 0.19.17) — no action needed beyond users updating.

Test plan

  • ./gradlew :app:assemblePlayDebug — builds
  • ./gradlew :automation-android:lintDebug — clean
  • :automation-android:testDebugUnitTest — no test sources in module
  • Device: post a notification with large extras (e.g. busy MessagingStyle thread) and confirm no crash; notification triggers still fire on pkg/category

Generated with Devin

First read of Notification.extras unparcels the entire bundle. A
notification carrying a huge parcelled payload (chat history, embedded
images) materialized enough objects to exhaust the 256MB heap inside
AutomationNotificationListener.onNotificationPosted — OutOfMemoryError
on 0.19.18, moto g23 Android 14.

Title/text/sender are now read behind runCatching and degrade to empty
strings, so pkg, category, group state and timestamps still dispatch the
trigger and the shade refresh still runs. Shade refreshes are also
serialized behind a Mutex: each unparcels every active notification's
extras, and concurrent runs multiplied the same heap spike.

Authored By: TDvorak <info@tdvorak.dev>
@vercel

vercel Bot commented Nov 5, 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 5, 2026 7:57am UTC

@mira-tdvorak

mira-tdvorak Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Mira PR Walkthrough

This PR fixes an OutOfMemoryError caused by unparcelling oversized notification extras (e.g., chat history with embedded images) in AutomationNotificationListener. Title/text/sender reads are now wrapped in runCatching to degrade gracefully to empty strings, while pkg/category/group state and timestamps still dispatch triggers. A Mutex serializes refreshActiveNotifications to prevent concurrent heap spikes during notification bursts.

Confidence: 4/5   ◉◉◉◉○   Safe with minor fixes
  • Minimal, targeted fix using standard patterns (runCatching, Mutex) for a specific crash; only 4 lines of logic changed in one file plus changelog.

2 files reviewed


Comment @mira-tdvorak help to get the list of available commands and usage tips.

@mira-tdvorak mira-tdvorak Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mira Review Summary

In automation-android/src/main/kotlin/com/tdvorak/nothingmodes/automation/lifecycle/AutomationNotificationListener.kt:128, the generation check runs after the expensive notification fetch and unparcel work, and this check is stale. Moving the check earlier would avoid unnecessary processing.

Key Issues

Issue Location
🔴 Stale generation check runs after expensive notification fetch/unparcel work automation-android/src/main/kotlin/com/tdvorak/nothingmodes/automation/lifecycle/AutomationNotificationListener.kt:128

Review follow-up: the generation check ran after fetching and
unparcelling every active notification, so a stale refresh still paid
the full cost before discarding. Check before the fetch too; the
post-fetch check stays so a refresh overtaken mid-flight cannot
overwrite fresher snapshots. Adds the missing changelog entry.

Authored By: TDvorak <info@tdvorak.dev>
@Dvorinka
Dvorinka merged commit 4cf3bf1 into main Nov 5, 2026
3 checks passed

This branch was successfully deployed

1 active deployment
Preview — 98bd6df8 Deployed Nov 5, 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