Make NotificationResultProcessor.emit wait until the batch is processed - #7640
Open
Johennes wants to merge 1 commit into
Open
Make NotificationResultProcessor.emit wait until the batch is processed#7640Johennes wants to merge 1 commit into
Johennes wants to merge 1 commit into
Conversation
Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
Contributor
|
Thank you for your contribution! Here are a few things to check in the PR to ensure it's reviewed as quickly as possible:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7640 +/- ##
===========================================
- Coverage 80.99% 80.97% -0.02%
===========================================
Files 2781 2781
Lines 81847 81859 +12
Branches 11257 11258 +1
===========================================
- Hits 66291 66288 -3
- Misses 11211 11228 +17
+ Partials 4345 4343 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Content
This change makes
NotificationResultProcessorown its lifecycle instead of relying on the push handler having been constructed first.emitstarts the collector if it is not running, and results go through an unlimited channel, which holds items until a receiver takes them, so nothing is lost while the collector is starting or between it being launched and actually subscribing.emitalso suspends until its batch has been processed, so the worker only completes once the notification or ringing call has been set up, and the wakelock or foreground service the worker holds covers the whole path rather than ending while the batch is still queued. Finally, a batch that throws while being processed is logged instead of cancelling the collector, which previously stopped all further notifications for the life of the process.Motivation and context
NotificationResultProcessorcurrently hands resolved push events from the fetch worker to a collector running on the app scope. That collector is only started fromDefaultPushHandler, which is only created when a push receiver runs in the current process, and the shared flow in between has no replay, so values emitted while nobody is subscribed are dropped. AFetchPendingNotificationsWorkerthatWorkManagerruns in a fresh process, for example a retry after the process was killed or an expedited job that was deferred, therefore fetches and decrypts the events and then emits them into nothing. No notification is shown and nothing is logged.Screenshots / GIFs
None.
Tests
See unit tests.
Tested devices
None.
Checklist