-
Notifications
You must be signed in to change notification settings - Fork 19
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
fix: crash when stopping OngoingCallService [WPB-2320] [WPB-1836] [WPB-3457] #2084
fix: crash when stopping OngoingCallService [WPB-2320] [WPB-1836] [WPB-3457] #2084
Conversation
…B-3457] (#2057) Co-authored-by: Tommaso Piazza <196761+tmspzz@users.noreply.github.com>
Build 1017 failed. |
Test Results533 tests +24 532 ✔️ +24 5m 28s ⏱️ -41s Results for commit 040fe16. ± Comparison against base commit cbd5ae1. This pull request removes 1 and adds 25 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
Build 1026 failed. |
Codecov Report
@@ Coverage Diff @@
## develop #2084 +/- ##
=============================================
+ Coverage 39.14% 39.58% +0.43%
- Complexity 920 930 +10
=============================================
Files 305 305
Lines 11194 11254 +60
Branches 1491 1499 +8
=============================================
+ Hits 4382 4455 +73
+ Misses 6390 6370 -20
- Partials 422 429 +7
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
APKs built during tests are available here. Scroll down to Artifacts! |
Build 1032 succeeded. The build produced the following APK's: |
Cherry pick from the original PR:
PR Submission Checklist for internal contributors
The PR Title
SQPIT-764
The PR Description
What's new in this PR?
The PR is big, but 80% of that are tests. 😅
Issues
There are still multiple crashes related to stopping OngoingCallService:
ForegroundServiceDidNotStartInTimeException
orContext.startForegroundService() did not then call Service.startForeground()
, depending on Android version.Also, we have one service for all logged in users so there's a race condition because one account can close the service even if another one has an ongoing call.
Causes (Optional)
The problem is that if we start service as a foreground one, then it has to call
startForeground
and show notification, if we stop such service before it does that, then the app crashes.Solutions
We already tried to call
startForeground
with some placeholder notification when creating service, beforeonStartCommand
is called, but it's not enough and crashes still happen quite commonly, so to fix that the debounce is added to take 200 milliseconds to check whether starting this service is really necessary - if "stop service" happens within that time then it won't even start and prevent us from the crash. Also, stopping the service, if already started but before it's in the foreground, is done directly inside the service, so even if we call it to stop too soon, then it will still executeonStartCommand
, show a placeholder notification for a split second and then safely close the service.For the issue with multiple accounts, a common SharedFlow is provided which collects data for all accounts and then starts or stops the service if any of them has an ongoing call. The same is implemented for incoming call notification (we also show a single incoming call notification for all accounts). The service is started and then it handles keeping itself alive as long as there is an ongoing call for any of valid accounts.
Testing
Test Coverage (Optional)
PR Post Submission Checklist for internal contributors (Optional)
PR Post Merge Checklist for internal contributors
References
feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764
.