[GH-ISSUE #5506] [Issue]: Marinara Engine hard-crashes or becomes unresponsive in Termux background #3061

Closed
opened 2026-10-21 05:59:17 +07:00 by bsakaguchi · 3 comments
Owner

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

  1. Run Marinara Engine in Termux on the affected Android phone.
  2. Leave Marinara Engine running in the background while using the phone normally.
  3. After an unspecified period, check the Marinara Engine web interface and reopen Termux.
  4. Observe that the server may be unavailable and Termux may have restarted to a fresh terminal without indicating the cause.
  5. On the latest staging build, leave Marinara Engine in the background and observe that bringing Termux to the foreground may temporarily restore responsiveness.

Environment

  • Marinara Engine version: 2.4.4; staging build 2.4.4+a1e8d057d8e2
  • Install type: termux
  • OS + version: Server: Android / Termux 5.10.209-android12-9-o-g63fb7a145195 (arm64); client: Android 15; device: OnePlus 10 Pro
  • Browser or app shell: Mozilla/5.0 (Android 15; Mobile; rv:154.0) Gecko/154.0 Firefox/154.0

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)
[2026-08-24T02:11:44.325Z] DSBwizzard: Marinara Engine diagnostics
Version: 2.4.4
Build: 2.4.4+5c5a0bc8e7e4
Commit: 5c5a0bc8e7e4
Server OS: Android / Termux 5.10.209-android12-9-o-g63fb7a145195 (arm64)
Client OS: Android 15
Browser / app shell: Mozilla/5.0 (Android 15; Mobile; rv:154.0) Gecko/154.0 Firefox/154.0
GPU: Adreno (TM) 650, or similar

From termux, I ran these commands for more general information:
~ $ getprop ro.build.date
Mon Jan  6 23:54:54 CST 2025
~ $ getprop ro.build.version.ota
NE2215_11.H.82_3820_202501070153

I continue to see Marinara Engine (specifically) crash my termux hard and without logging why when running ME on my phone. I have done some additional investigation to try and verify if my phone or OS are to blame and I do not believe they are at this point. Why others, including Umi who has a One Plus 10 Pro like me (albeit at a higher OS version than mine can receive) do not see this issue is beyond me.

Steps I have taken since observing this issue originally:
- Troubleshooting undertaken within the following bugs:
[1]https://discord.com/channels/1417099416812392641/1538613675261427863
[2]https://discord.com/channels/1417099416812392641/1539838979052933221

Since submitting those bugs and performing the troubleshooting within them, I have:

- Uninstalled all traces of ME from my device, and reinstalled Termux+Marinara Engine
- Updated my phone to the latest OS that is available to me
- Ran `while true; do date; sleep 10; done` for an hour on my termux and left phone alone as normal, did not see termux crash or misbehave at all like I see when running ME

ME appears to crash and kill my Termux without logging why, when my ME is running in the background. I have not seen any rhyme or reason why or when it happens, I just start my ME instance, go about my day, check my web browser and see my ME instance is unavailable, open termux on my phone, and see a blank, fresh Terminal waiting for me without any hint it was just running ME previously.

[attached image 1: https://cdn.discordapp.com/attachments/1541268745538764950/1541268745748484166/image.png?ex=6a8e4b60&is=6a8cf9e0&hm=0f7cf95c0f421b59b0fb833597b079a7487367f3d07a6eaacac6058233bcdadc&]
[Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541268745538764950]

[2026-08-24T02:11:45.155Z] Professor Mari [bot]: Howdy!

Thank you for submitting a new bug report/feature request, your support means a lot. A member of the team will look into it as soon as possible, and if they find it valid, they will open a GitHub Issue out of it. You can check whether it was addressed on the staging build of Marinara Engine. **Do not ping any of the developers, this will not speed up the process.**

**Please include a Support Diagnostic in the post if you haven't done it yet.** Otherwise, ignore this step. To grab it, go to the Marinara Engine tab:

`Settings -> Advanced -> Support Diagnostics -> Copy Support Diagnostics.`

If your report is about any of the **Agents**, please provide **the Agent's version** which you can grab from here:

`Agents -> Download Agents -> Installed Agents -> Selected Agent -> Installed Version`

Thank you, this will help tremendously.

This is an automated message, but if you reply to it, I will do my best to assist you using my LLM-powered brain. That said, it's best for a human to handle this case.

Cheers!
[Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541268749020045342]

[2026-08-24T02:12:06.342Z] DSBwizzard: I'm disappointed this keeps happening and hesitate to post this issue again, because nobody else reports this, but I still have a hunch it has something to do with the optimizations to battery or something along those lines as i recall the issue began to occur roughly near the end of this bug's life: https://discord.com/channels/1417099416812392641/1534559002787315844

Thank you. I appreciate the time. Unfortunately I am no longer able to continue using ME on my phone, and do not see other avenues to pursue myself other than hosting ME elsewhere than my Termux which I would prefer not to do, for my own preference and so I can continue to provide bugtesting and issue reproduction for other users who also host ME on termux.

[attached image 1: https://cdn.discordapp.com/attachments/1541268745538764950/1541268837272657970/image.png?ex=6a8e4b76&is=6a8cf9f6&hm=b32b60b00b63cc112da9af924b08abda40f6f9d25479128f087b2a56d203df47&]
[Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541268837884887161]

[2026-08-24T05:10:05.817Z] Marinara: @Professor Mari GitHub Issue
[Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541313630849732719]

[2026-08-24T05:10:19.332Z] Professor Mari [bot]: Skill issue. Made a GitHub issue here: https://github.com/Pasta-Devs/Marinara-Engine/issues/5470
[Issue]: Marinara Engine hard-crashes Termux while running in backg...
Summary Marinara Engine intermittently terminates the entire Termux session while running in the background on Android. The server becomes unavailable and Termux opens to a fresh terminal without a...
[Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541313687535620206]

[2026-08-24T06:57:39.983Z] kolache: if it still keeps crashing after that issue/PR just dm me because it must have been one of the prs i did previously yeah
[Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541340701584003133]

[2026-08-24T07:45:58.676Z] Marinara: Staging
[Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541352859583520790]

[2026-08-24T11:47:00.286Z] Professor Mari [bot]: The GitHub Issue #5470 was addressed and closed! It has now landed on staging (you can change the branch to staging in Marinara Engine's **Settings -> Advanced -> Updates -> Release Channel -> Staging/UAT**), so please test it out and let us know if everything works!
[Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541413515972313118]

[2026-08-24T15:20:32.040Z] DSBwizzard: Thanks Mari. I am testing this change to reduce the RAM allocation now. If it acts up Ill discuss further with Kolache as they requested.
[Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541467252363362384]

[2026-08-25T03:06:40.777Z] DSBwizzard: I think I'll use this thread. It's all related at some level I believe.

Marinara Engine diagnostics
Version: 2.4.4
Build: 2.4.4+a1e8d057d8e2
Commit: a1e8d057d8e2
Server OS: Android / Termux 5.10.209-android12-9-o-g63fb7a145195 (arm64)
Client OS: Android 15
Browser / app shell: Mozilla/5.0 (Android 15; Mobile; rv:154.0) Gecko/154.0 Firefox/154.0
GPU: Adreno (TM) 650, or similar

In latest staging, I am once again seeing the requirement to actively bring Termux to the front of my phone and look at it to cause Marinara Engine to respond again for a few minutes.

This is a regression/ re-expression of some of the issues we've seen regarding the battery improvements applied in the bugs mentioned earlier in this chat.

@kolache ping as requested, we can DM if preferred
[Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541644959726309416]

[2026-08-25T07:43:13.595Z] kolache: will take a look after i finish a couple other things
[Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541714555049353308]

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
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 1. Run Marinara Engine in Termux on the affected Android phone. 2. Leave Marinara Engine running in the background while using the phone normally. 3. After an unspecified period, check the Marinara Engine web interface and reopen Termux. 4. Observe that the server may be unavailable and Termux may have restarted to a fresh terminal without indicating the cause. 5. On the latest staging build, leave Marinara Engine in the background and observe that bringing Termux to the foreground may temporarily restore responsiveness. ## Environment - Marinara Engine version: 2.4.4; staging build 2.4.4+a1e8d057d8e2 - Install type: termux - OS + version: Server: Android / Termux 5.10.209-android12-9-o-g63fb7a145195 (arm64); client: Android 15; device: OnePlus 10 Pro - Browser or app shell: Mozilla/5.0 (Android 15; Mobile; rv:154.0) Gecko/154.0 Firefox/154.0 ## 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) <details> <summary>Discord thread transcript (11 messages)</summary> ```text [2026-08-24T02:11:44.325Z] DSBwizzard: Marinara Engine diagnostics Version: 2.4.4 Build: 2.4.4+5c5a0bc8e7e4 Commit: 5c5a0bc8e7e4 Server OS: Android / Termux 5.10.209-android12-9-o-g63fb7a145195 (arm64) Client OS: Android 15 Browser / app shell: Mozilla/5.0 (Android 15; Mobile; rv:154.0) Gecko/154.0 Firefox/154.0 GPU: Adreno (TM) 650, or similar From termux, I ran these commands for more general information: ~ $ getprop ro.build.date Mon Jan 6 23:54:54 CST 2025 ~ $ getprop ro.build.version.ota NE2215_11.H.82_3820_202501070153 I continue to see Marinara Engine (specifically) crash my termux hard and without logging why when running ME on my phone. I have done some additional investigation to try and verify if my phone or OS are to blame and I do not believe they are at this point. Why others, including Umi who has a One Plus 10 Pro like me (albeit at a higher OS version than mine can receive) do not see this issue is beyond me. Steps I have taken since observing this issue originally: - Troubleshooting undertaken within the following bugs: [1]https://discord.com/channels/1417099416812392641/1538613675261427863 [2]https://discord.com/channels/1417099416812392641/1539838979052933221 Since submitting those bugs and performing the troubleshooting within them, I have: - Uninstalled all traces of ME from my device, and reinstalled Termux+Marinara Engine - Updated my phone to the latest OS that is available to me - Ran `while true; do date; sleep 10; done` for an hour on my termux and left phone alone as normal, did not see termux crash or misbehave at all like I see when running ME ME appears to crash and kill my Termux without logging why, when my ME is running in the background. I have not seen any rhyme or reason why or when it happens, I just start my ME instance, go about my day, check my web browser and see my ME instance is unavailable, open termux on my phone, and see a blank, fresh Terminal waiting for me without any hint it was just running ME previously. [attached image 1: https://cdn.discordapp.com/attachments/1541268745538764950/1541268745748484166/image.png?ex=6a8e4b60&is=6a8cf9e0&hm=0f7cf95c0f421b59b0fb833597b079a7487367f3d07a6eaacac6058233bcdadc&] [Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541268745538764950] [2026-08-24T02:11:45.155Z] Professor Mari [bot]: Howdy! Thank you for submitting a new bug report/feature request, your support means a lot. A member of the team will look into it as soon as possible, and if they find it valid, they will open a GitHub Issue out of it. You can check whether it was addressed on the staging build of Marinara Engine. **Do not ping any of the developers, this will not speed up the process.** **Please include a Support Diagnostic in the post if you haven't done it yet.** Otherwise, ignore this step. To grab it, go to the Marinara Engine tab: `Settings -> Advanced -> Support Diagnostics -> Copy Support Diagnostics.` If your report is about any of the **Agents**, please provide **the Agent's version** which you can grab from here: `Agents -> Download Agents -> Installed Agents -> Selected Agent -> Installed Version` Thank you, this will help tremendously. This is an automated message, but if you reply to it, I will do my best to assist you using my LLM-powered brain. That said, it's best for a human to handle this case. Cheers! [Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541268749020045342] [2026-08-24T02:12:06.342Z] DSBwizzard: I'm disappointed this keeps happening and hesitate to post this issue again, because nobody else reports this, but I still have a hunch it has something to do with the optimizations to battery or something along those lines as i recall the issue began to occur roughly near the end of this bug's life: https://discord.com/channels/1417099416812392641/1534559002787315844 Thank you. I appreciate the time. Unfortunately I am no longer able to continue using ME on my phone, and do not see other avenues to pursue myself other than hosting ME elsewhere than my Termux which I would prefer not to do, for my own preference and so I can continue to provide bugtesting and issue reproduction for other users who also host ME on termux. [attached image 1: https://cdn.discordapp.com/attachments/1541268745538764950/1541268837272657970/image.png?ex=6a8e4b76&is=6a8cf9f6&hm=b32b60b00b63cc112da9af924b08abda40f6f9d25479128f087b2a56d203df47&] [Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541268837884887161] [2026-08-24T05:10:05.817Z] Marinara: @Professor Mari GitHub Issue [Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541313630849732719] [2026-08-24T05:10:19.332Z] Professor Mari [bot]: Skill issue. Made a GitHub issue here: https://github.com/Pasta-Devs/Marinara-Engine/issues/5470 [Issue]: Marinara Engine hard-crashes Termux while running in backg... Summary Marinara Engine intermittently terminates the entire Termux session while running in the background on Android. The server becomes unavailable and Termux opens to a fresh terminal without a... [Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541313687535620206] [2026-08-24T06:57:39.983Z] kolache: if it still keeps crashing after that issue/PR just dm me because it must have been one of the prs i did previously yeah [Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541340701584003133] [2026-08-24T07:45:58.676Z] Marinara: Staging [Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541352859583520790] [2026-08-24T11:47:00.286Z] Professor Mari [bot]: The GitHub Issue #5470 was addressed and closed! It has now landed on staging (you can change the branch to staging in Marinara Engine's **Settings -> Advanced -> Updates -> Release Channel -> Staging/UAT**), so please test it out and let us know if everything works! [Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541413515972313118] [2026-08-24T15:20:32.040Z] DSBwizzard: Thanks Mari. I am testing this change to reduce the RAM allocation now. If it acts up Ill discuss further with Kolache as they requested. [Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541467252363362384] [2026-08-25T03:06:40.777Z] DSBwizzard: I think I'll use this thread. It's all related at some level I believe. Marinara Engine diagnostics Version: 2.4.4 Build: 2.4.4+a1e8d057d8e2 Commit: a1e8d057d8e2 Server OS: Android / Termux 5.10.209-android12-9-o-g63fb7a145195 (arm64) Client OS: Android 15 Browser / app shell: Mozilla/5.0 (Android 15; Mobile; rv:154.0) Gecko/154.0 Firefox/154.0 GPU: Adreno (TM) 650, or similar In latest staging, I am once again seeing the requirement to actively bring Termux to the front of my phone and look at it to cause Marinara Engine to respond again for a few minutes. This is a regression/ re-expression of some of the issues we've seen regarding the battery improvements applied in the bugs mentioned earlier in this chat. @kolache ping as requested, we can DM if preferred [Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541644959726309416] [2026-08-25T07:43:13.595Z] kolache: will take a look after i finish a couple other things [Discord message: https://discord.com/channels/1417099416812392641/1541268745538764950/1541714555049353308] ``` </details> ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:59:17 +07:00
Author
Owner

@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)

Date Change What you saw
Aug 8 Launcher starts setting --max-old-space-size=2048 (the fix at the end of the RAM bug thread you linked) Hard crashes begin. With a 2 GB ceiling, Node's process can balloon well past 1.5 GB on your phone. A background app that big is a prime target for Android's low-memory killer and OxygenOS's battery management — which kill the entire Termux app with a straight SIGKILL: no error, no log, fresh terminal. This is also why it felt like it started "near the end of that bug's life" — that's literally when this default landed, right alongside the battery PRs.
Aug 12 Launcher acquires a Termux wakelock No help — a wakelock keeps the CPU awake but does not protect against LMKD/OxygenOS kills (your Aug 24 build had it and still crashed).
Aug 24 #5471 halves the default to 1024 The foreground-to-revive behavior appears on exactly the first build containing this. Explanation below.

Why 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.ts loads 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 10 test survived

  • You're running the largest known Termux profile on the single most aggressive OEM for background kills (OnePlus/OxygenOS). Other Termux users have small heaps; other OnePlus users have small profiles.
  • Your hour-long idle loop test is actually evidence for this diagnosis, not against your phone: a tiny shell loop has no memory footprint and no CPU burn, so neither LMKD nor OxygenOS has any reason to touch it. The kills are resource-triggered, and only Marinara has the resources.
  • People who don't leave Termux in the background would never see either symptom — matching kolache's suspicion that others may simply not notice.

Things I ruled out (so nobody chases them)

  • The battery PRs themselves (#4715/#4716/#4719/#4723/#4727): audited; they reduced idle work and none of them regress background responsiveness.
  • A server bug that exits silently: every timer/rejection path routes into catches; any Node-side death (including a V8 heap abort) would print [ERROR] Marinara Engine server exited with status N into the session log. A totally log-free vanish can only be Android killing the app.
  • Your browser being the frozen one: the client's heartbeat/version-check/stream-watchdog all fire fresh requests the instant Firefox becomes visible — a frozen tab self-heals on its own. And nothing client-side can benefit from Termux being foregrounded. Symptom B is server-side by elimination.
  • The extension sandbox: structurally can't even run on Termux (no bubblewrap), so it's not involved.
  • Every other commit in your window (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)

  1. The decisive experiment — start with an explicit heap between the two bad constants:
    NODE_OPTIONS="--max-old-space-size=1536" ./start-termux.sh
    
    The launcher honors an explicit limit and skips its default. Prediction: the foreground-to-revive behavior disappears (1536 clears your ~1 GB live set with real headroom) while keeping RSS ~500 MB smaller than the 2048 era to stay off the kill radar. If hard kills return anyway, that confirms the symptom-A half too. 2048 is also worth a run if 1536 isn't enough.
  2. Send us the logs that now exist. Since the Aug 17–18 builds, every session is recorded to ~/.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 limit stack → V8 OOM (heap too small)
    • [ERROR] Marinara Engine server exited with status N → Node died, status tells us how
    • log just stops mid-stream with no exit line → Android killed the whole Termux app (LMKD / phantom-process killer / OxygenOS)
  3. Measure where you actually sit, while the server runs:
    du -sh <your-marinara-folder>/packages/server/data
    ps -o pid,rss,args -p $(pgrep -f 'node dist/index.js')
    
    (RSS is in KB — I expect ~1.2–1.5 GB+ under the old 2048 default.)
  4. OxygenOS settings (for the silent kills): Settings → Battery → Termux → don't optimize / allow background activity; disable any "sleep standby optimization" for it; lock Termux in the recents screen. Optionally, the classic Android 12+ Termux mitigation — disable the phantom-process killer via adb: adb shell settings put global settings_enable_monitor_phantom_procs false.
  5. Three quick questions: (a) Do you have autonomous messages enabled on any chat, or automatic backup enabled? (Both fire real work immediately when the process un-freezes — they'd sharpen the "responsive a few minutes, then dies" shape.) (b) Which Termux build — F-Droid, GitHub, or Play Store? (c) Did the launcher print [OK] Android wake lock acquired for background reliability at startup?

What we'll fix engine-side

  1. Stop using a fixed heap constant. The launcher should scale the default from device RAM and/or the on-disk profile size (small profile → stay lean for Android; large profile → get the headroom it factually needs), keeping the explicit NODE_OPTIONS override. A fixed number provably can't serve both failure modes.
  2. Heap telemetry. Support Diagnostics and /api/health currently 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.
  3. Two smaller hardening items found during the sweep (a timer-path rejection that could theoretically hard-exit the server, and an unconditional per-prompt lorebook scan that adds GC pressure) — I'll file/fix those separately.

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 1536 experiment + one post-incident log tail should settle it completely.

<!-- gh-comment-id:5409420621 --> @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) | Date | Change | What you saw | |---|---|---| | Aug 8 | Launcher starts setting `--max-old-space-size=2048` (the fix at the end of the RAM bug thread you linked) | **Hard crashes begin.** With a 2 GB ceiling, Node's process can balloon well past 1.5 GB on your phone. A *background* app that big is a prime target for Android's low-memory killer and OxygenOS's battery management — which kill the **entire Termux app** with a straight SIGKILL: no error, no log, fresh terminal. This is also why it felt like it started "near the end of that bug's life" — that's literally when this default landed, right alongside the battery PRs. | | Aug 12 | Launcher acquires a Termux wakelock | No help — a wakelock keeps the CPU awake but does not protect against LMKD/OxygenOS kills (your Aug 24 build had it and still crashed). | | Aug 24 | #5471 halves the default to `1024` | **The foreground-to-revive behavior appears on exactly the first build containing this.** Explanation below. | ## Why 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.ts` loads 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 10` test survived - You're running the largest known Termux profile on the single most aggressive OEM for background kills (OnePlus/OxygenOS). Other Termux users have small heaps; other OnePlus users have small profiles. - Your hour-long idle loop test is actually *evidence for* this diagnosis, not against your phone: a tiny shell loop has no memory footprint and no CPU burn, so neither LMKD nor OxygenOS has any reason to touch it. The kills are resource-triggered, and only Marinara has the resources. - People who don't leave Termux in the background would never see either symptom — matching kolache's suspicion that others may simply not notice. ## Things I ruled out (so nobody chases them) - **The battery PRs themselves** (#4715/#4716/#4719/#4723/#4727): audited; they *reduced* idle work and none of them regress background responsiveness. - **A server bug that exits silently**: every timer/rejection path routes into catches; any Node-side death (including a V8 heap abort) would print `[ERROR] Marinara Engine server exited with status N` into the session log. A totally log-free vanish can only be Android killing the app. - **Your browser being the frozen one**: the client's heartbeat/version-check/stream-watchdog all fire fresh requests the instant Firefox becomes visible — a frozen tab self-heals on its own. And nothing client-side can benefit from *Termux* being foregrounded. Symptom B is server-side by elimination. - **The extension sandbox**: structurally can't even run on Termux (no bubblewrap), so it's not involved. - **Every other commit in your window** (`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) 1. **The decisive experiment** — start with an explicit heap between the two bad constants: ``` NODE_OPTIONS="--max-old-space-size=1536" ./start-termux.sh ``` The launcher honors an explicit limit and skips its default. Prediction: the foreground-to-revive behavior disappears (1536 clears your ~1 GB live set with real headroom) while keeping RSS ~500 MB smaller than the 2048 era to stay off the kill radar. If hard kills return anyway, that confirms the symptom-A half too. `2048` is also worth a run if `1536` isn't enough. 2. **Send us the logs that now exist.** Since the Aug 17–18 builds, every session is recorded to `~/.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 limit` stack → V8 OOM (heap too small) - `[ERROR] Marinara Engine server exited with status N` → Node died, status tells us how - log just **stops mid-stream** with no exit line → Android killed the whole Termux app (LMKD / phantom-process killer / OxygenOS) 3. **Measure where you actually sit**, while the server runs: ``` du -sh <your-marinara-folder>/packages/server/data ps -o pid,rss,args -p $(pgrep -f 'node dist/index.js') ``` (RSS is in KB — I expect ~1.2–1.5 GB+ under the old 2048 default.) 4. **OxygenOS settings** (for the silent kills): Settings → Battery → Termux → don't optimize / allow background activity; disable any "sleep standby optimization" for it; lock Termux in the recents screen. Optionally, the classic Android 12+ Termux mitigation — disable the phantom-process killer via adb: `adb shell settings put global settings_enable_monitor_phantom_procs false`. 5. **Three quick questions:** (a) Do you have **autonomous messages** enabled on any chat, or **automatic backup** enabled? (Both fire real work immediately when the process un-freezes — they'd sharpen the "responsive a few minutes, then dies" shape.) (b) Which Termux build — F-Droid, GitHub, or Play Store? (c) Did the launcher print `[OK] Android wake lock acquired for background reliability` at startup? ## What we'll fix engine-side 1. **Stop using a fixed heap constant.** The launcher should scale the default from device RAM and/or the on-disk profile size (small profile → stay lean for Android; large profile → get the headroom it factually needs), keeping the explicit `NODE_OPTIONS` override. A fixed number provably can't serve both failure modes. 2. **Heap telemetry.** Support Diagnostics and `/api/health` currently 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. 3. Two smaller hardening items found during the sweep (a timer-path rejection that could theoretically hard-exit the server, and an unconditional per-prompt lorebook scan that adds GC pressure) — I'll file/fix those separately. 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 `1536` experiment + one post-incident log tail should settle it completely.
Author
Owner

@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.

<!-- gh-comment-id:5409567877 --> @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.
Author
Owner

@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.

<!-- gh-comment-id:5409719671 --> @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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#3061
No description provided.