-
Notifications
You must be signed in to change notification settings - Fork 567
Background persistence #505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
callebtc
wants to merge
28
commits into
main
Choose a base branch
from
background-persistence
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Here’s a focused code/diff review of the background-persistence work, centered on long‑running foreground service behavior, mesh reliability, notifications, and UI state retention.
Scope Reviewed
AppStateStore, related UI handlers.
Overall Assessment
AppStateStore helps mitigate Activity recreation.
thoughtfully split.
Strengths
Potential Issues Impacting Long-Run Reliability
service starts can be restricted or killed if not foregrounded. Risk: service runs without FGS or gets killed before promotion, especially on OEMs with aggressive policies.
returns false and you call startService() from a background context. Risk: background start blocked/killed; also locked boot may run before user unlock and storage/keys might be
unavailable.
mitigates this by only using startForegroundService() when both BL and notification perms are granted. That’s good, but edge conditions remain:
path), you may hit the 5s crash.
afterwards (no re-instantiation), subsequent startServices() will try to use a cancelled scope. Risk: periodic tasks, syncs, and internal coroutines won’t restart, causing silent
malfunction after a stop→start cycle (including process recreation if MeshServiceHolder still references the old instance).
hand out a “dead” instance with cancelled scope.
and risking OOM. Also, UI state won’t persist across process death since this store is in‑memory only.
event‑based updates.
storage (e.g., Noise keys). No guard is present to defer starting until after user unlock if needed.
adjusting.
safe.
promotion, with no explicit backoff or stopSelf strategy until user grants perms.
repopulates. If “preserve latest UI state” means last seen chats/messages across process death, consider persistence.
Protocol-Specific Observations
above could silently prevent these tasks from resuming after a stop.
by the NotificationManager path).
Recommended Next Steps
scope was cancelled.
starts and permissions are granted.
unlock.
only run a slow heartbeat as fallback.
extended period.
work.
If you’d like, I can patch: