Repository navigation
Notify messages stored before the notification handlers subscribe - #2268
Merged
mpretty-cyro merged 1 commit intoNov 17, 2026
Merged
mpretty-cyro merged 1 commit into
mpretty-cyro merged 1 commit into
Conversation
A push or background poll that cold-starts the process stores its message before NotificationProcessor subscribes to the database change flows, which keep no replay, so the message never notified. Since the notification refactor in 1.33.0 this has hit every message that wakes a killed process. Mark each message a handler deals with in the existing, unused notified column, and have each subscription start by replaying the unread incoming messages still unmarked as Added events. Messages a handler already saw aren't replayed, so a dismissed unread message doesn't notify again on each cold start. The mark is per row because sms ids are reused after its newest rows are deleted.
mpretty-cyro
force-pushed
the
fix/notify-on-push-cold-start
branch
from
November 17, 2026 22:48
8ebb4ce to
012f0c9
Compare
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.
Contributor checklist
playflavour,debug, using FCM pushFixes #1234syntaxDescription
Bug: when a push or a background poll cold-starts the process, the message it stores never notifies. This has been the case since the notification refactor (#2019, first released in 1.33.0). Users see it as "no notifications if I haven't opened the app for a while", because Android kills the cached process and the next message cold-starts it.
Cause:
NotificationProcessoris anAuthAwareComponent.AuthAwareComponentsHandlerstarts it after a random delay of up to a second, and only then do the handlers subscribe to thechangeNotificationflows ofMmsDatabase,SmsDatabaseandThreadDatabase. Those flows keep no replay, so the push stores its message before anyone is listening, and its Added event is dropped.Fix: each message a notification handler deals with is now marked in the existing
notifiedcolumn ofsmsandmms, which nothing else uses any more. Each time the handlers subscribe,MissedMessageEventsfirst sends one Added event for each thread with unread incoming messages that are still unmarked. The replay goes through the normal path, so privacy modes, muted and mentions-only threads, blocked contacts and message requests behave as they do for live events.smshas noAUTOINCREMENT; the lokiV46 "add autoincrement" migration recreates it from the sameCREATE_TABLE. So deleting its newest rows (expiry, delete-for-me) frees their ids for the next inserts, and a "newer than id N" check would skip those messages.read = 0 AND notified = 0, which matches the existing(read, notified, thread_id)index on both tables. Incoming rows are stored withread = 0.Testing:
MissedMessageEventsTestruns the real queries against an in-memory database built fromSmsDatabase.CREATE_TABLEandMmsDatabase.CREATE_TABLE, plus theiris_outgoingcolumns. It covers:notifiedfilter, 2 tests fail; without the undispatched subscription, 1 fails.am kill, then the other account sent a message, so the push cold-started the receiver.dev, the message was stored about 1s beforeNotificationProcessorsubscribed, and no notification was posted.dev, the first launch marked the stored messages and replayed nothing.ShowNoNameOrContentmode wasn't tested on a device.