Skip to content

fix: enable service hibernation by default to reduce memory usage#2364

Open
phelix001 wants to merge 2 commits into
ferdium:developfrom
phelix001:fix/hibernate-enabled-by-default
Open

fix: enable service hibernation by default to reduce memory usage#2364
phelix001 wants to merge 2 commits into
ferdium:developfrom
phelix001:fix/hibernate-enabled-by-default

Conversation

@phelix001

Copy link
Copy Markdown
Contributor

Summary

  • Root cause fix: isHibernationEnabled defaulted to false per service, making the entire hibernation system non-functional — canHibernate always returned false, so services never hibernated even with hibernateOnStartup: true
  • Tune defaults: Reduce hibernation delay from 5min to 2min, disable auto wake-up (services stay asleep until user clicks)
  • Add backgroundThrottling to webview webPreferences to throttle inactive service tabs before hibernation kicks in

The bug chain

  1. DEFAULT_SERVICE_SETTINGS.isHibernationEnabled = false (src/config.ts:628)
  2. canHibernate = isHibernationEnabled && !isMediaPlaying → always false
  3. isHibernating = canHibernate && isHibernationRequested → always false
  4. _hibernate() early-returns on !service.canHibernate
  5. hibernateOnStartup: true sets isHibernationRequested but isHibernating still returns false

Result: Every service runs a permanent Chromium renderer process (~170MB each) regardless of activity. 8 services = ~2.3GB.

Changes

Setting Before After Why
isHibernationEnabled false true Services actually hibernate now
hibernationStrategy '300' (5 min) '120' (2 min) Faster memory reclaim
wakeUpStrategy '300' (5 min) '0' (disabled) No pointless hibernate/wake cycling
isWakeUpEnabled true false Consistent with wakeUpStrategy
webview backgroundThrottling not set 1 Throttle inactive tabs before hibernation

Expected impact

~1.2GB freed for typical 8-service setup (7 hibernated × ~170MB). Only affects NEW services and fresh installs — existing users' per-service settings are persisted in the database.

Test plan

  • pnpm typecheck passes
  • pnpm lint passes (via pre-commit hook)
  • pnpm test — 81 passed, 2 skipped
  • Manual: Add 5+ services, switch away, wait 2 min → services show 😴 and renderer process count drops
  • Manual: Click hibernated service → wakes up correctly

Fixes #2363
Related: #2197, #219, #647, #606

🤖 Generated with Claude Code

phelix001 and others added 2 commits March 28, 2026 03:29
isHibernationEnabled defaulted to false per service, which made the entire
hibernation system non-functional: canHibernate always returned false,
isHibernating was always false, and _hibernate() early-returned. Even
hibernateOnStartup (which defaults to true) had no effect since it only
sets isHibernationRequested, which is gated by canHibernate.

This caused all service renderer processes (~170MB each) to run permanently
regardless of user activity, leading to 2-3GB+ memory usage with 8+ services.

Changes:
- isHibernationEnabled: false → true (services now actually hibernate)
- hibernationStrategy: 300 → 120 (hibernate after 2 min, not 5)
- wakeUpStrategy: 300 → 0 (stay hibernated until user clicks)
- isWakeUpEnabled: true → false (consistent with wakeUpStrategy)
- Add backgroundThrottling=1 to webview webPreferences

Expected savings: ~1.2GB for a typical 8-service setup.

Fixes ferdium#2363
Related: ferdium#2197, ferdium#219, ferdium#647, ferdium#606

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…agent

Clean up Chromium session (cache + flush storage) when services are
hibernated, disabled, or deleted to release PartitionAlloc memory pools.
Replace useragent-generator dependency with inline Chrome UA string to
avoid compatibility issues. Add CLAUDE.md project instructions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@SpecialAro SpecialAro force-pushed the fix/hibernate-enabled-by-default branch from 79ab327 to fb45492 Compare March 28, 2026 03:29
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.

Bug: Hibernation disabled by default — isHibernationEnabled defaults to false, making hibernateOnStartup ineffective

1 participant