mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5506] [Issue]: Marinara Engine hard-crashes or becomes unresponsive in Termux background #3061
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#3061
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SpicyMarinara on GitHub (Aug 25, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5506
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Marinara Engine intermittently terminates the entire Termux session while running in the background on Android, making the server unavailable. In the latest staging build, Termux also sometimes must be brought to the foreground before Marinara responds again.
Expected behavior
Marinara Engine should continue running and responding in the background without terminating Termux or requiring the terminal to be brought to the foreground.
Actual behavior
Termux is intermittently hard-crashed without a useful log while Marinara Engine is running in the background. The web interface becomes unavailable, and reopening Termux shows a fresh blank terminal. On the latest staging build, bringing Termux to the foreground temporarily restores Marinara Engine responsiveness for a few minutes.
Steps to reproduce
Environment
Logs, screenshots, or video
No crash logs were produced or observed. Support diagnostics report GPU as Adreno (TM) 650, or similar. Screenshots were attached: https://cdn.discordapp.com/attachments/1541268745538764950/1541268745748484166/image.png?ex=6a8e4b60&is=6a8cf9e0&hm=0f7cf95c0f421b59b0fb833597b079a7487367f3d07a6eaacac6058233bcdadc and https://cdn.discordapp.com/attachments/1541268745538764950/1541268837272657970/image.png?ex=6a8e4b76&is=6a8cf9f6&hm=b32b60b00b63cc112da9af924b08abda40f6f9d25479128f087b2a56d203df47
Additional context
The user uninstalled all traces of Marinara Engine, reinstalled Termux and Marinara Engine, and updated the phone to the latest available OS version. An idle Termux loop running for an hour did not crash or misbehave. The issue is suspected to relate to battery optimizations or recent RAM-allocation/battery changes. A previous issue was addressed on staging, but the background responsiveness problem was observed again in staging.
Discord thread: ME Installation Still Continues to Hard-Crash Termux
Discord thread link: https://discord.com/channels/1417099416812392641/1541268745538764950
Requested by: Marinara (marinara_spaghetti, Discord ID 169561011928432653)
Discord thread transcript (11 messages)
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@kolacheee commented on GitHub (Aug 25, 2026):
Took the deep look I promised. I traced the full timeline, audited every commit between your two build hashes, and swept the server for anything that misbehaves when Android freezes/throttles a background process. I believe I can now explain both symptoms — and why you're the only one seeing them. Short version: this was never the battery PRs. It's the Node heap-size default, which changed twice in exactly the windows where your symptoms changed.
The timeline (this is the whole story)
--max-old-space-size=2048(the fix at the end of the RAM bug thread you linked)1024Why 1024 MB produces the "bring Termux to the front" behavior
Marinara's file-backed store keeps your entire profile as live objects in memory (every chat's messages, swipes, lorebooks, checkpoints —
file-backed-store.tsloads every shard of every table at startup; the per-chat sharding work only changed how we write files, not what's resident). A large install of your class measured ~1010 MB live heap after a full GC in the earlier RAM investigation (#4730).Put a ~1 GB live set under a 1024 MB ceiling and V8 sits in a permanent full-GC storm — it spends most of its CPU collecting garbage just to find room for each new allocation. Now add Android: when Termux is backgrounded, OxygenOS restricts it to a sliver of background CPU. A GC-storming server on a sliver of CPU is effectively frozen — requests time out, the web UI looks dead. When you foreground Termux, Android lifts the CPU restriction, GC catches up, and the server answers again… until a few minutes after you background it and the restriction re-applies. That's your symptom, mechanically.
So the two heap defaults each produce one of your two symptoms: 2048 → big RSS → silent whole-app kill (no logs). 1024 → GC ceiling → unresponsive-in-background. There is no third constant that fixes both — which is why the real fix is different (below).
Why only you, and why your
sleep 10test survivedThings I ruled out (so nobody chases them)
[ERROR] Marinara Engine server exited with status Ninto the session log. A totally log-free vanish can only be Android killing the app.5c5a0bc8e7e4..a1e8d057d8e2, all 14): nothing else touches memory, timers, background behavior, or the launcher.What I'd like you to try (this confirms or kills the theory on-device)
2048is also worth a run if1536isn't enough.~/.marinara-engine/logs/server-*.log(14-day retention). After the next incident, grab the newest file and look at the tail — it discriminates all three deaths:FATAL ERROR: Reached heap limitstack → V8 OOM (heap too small)[ERROR] Marinara Engine server exited with status N→ Node died, status tells us howadb shell settings put global settings_enable_monitor_phantom_procs false.[OK] Android wake lock acquired for background reliabilityat startup?What we'll fix engine-side
NODE_OPTIONSoverride. A fixed number provably can't serve both failure modes./api/healthcurrently contain zero memory info, and the session logs can't distinguish "GC storm" from "frozen by Android." We'll add heap-used/limit to diagnostics plus a periodic near-limit warning line so the next report answers itself.Sorry it took chasing you across three threads to get here — your persistence and the clean A/B between the two staging builds is what made this diagnosable. The
1536experiment + one post-incident log tail should settle it completely.@SpicyMarinara commented on GitHub (Aug 25, 2026):
@kolacheee I am doing the maintainer release-cleanup sweep now. Your root-cause analysis is excellent and this remains the only open Engine runtime issue. Are you opening the adaptive heap/telemetry PR against staging now? I will leave implementation ownership with you while I finish the package fixes, then I can take the minimal launcher fix if no PR exists before the release gate.
@SpicyMarinara commented on GitHub (Aug 25, 2026):
@kolacheee I am taking the minimal implementation into one release-hardening PR against staging now, using the fix boundaries from your audit. I will keep your diagnosis credited in the PR and avoid expanding scope beyond the four verified paths.