-
-
Notifications
You must be signed in to change notification settings - Fork 497
Fixed: Playstore reported a crash for android.app.RemoteServiceException$ForegroundServiceDidNotStopInTimeException.
#4502
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
base: main
Are you sure you want to change the base?
Conversation
|
@kelson42 We have fixed the crash. But the user does not know about this limitation, and they will think the download is stopped in the background, as we had some issues earlier where the download stopped in the background(They were actual issues, but this one is intentional). It can confuse users. So we have to inform them about this so that there is no confusion for users about this limitation. There could be 2 ways:
@kelson42 What do you think? |
|
@MohitMaliFtechiz This is definitly the second approach I would should. Can we do it in the running Download notification (and reopen one if it has been disabled)? I would propose to use the following message "Android's background download has timed-out. Do you want to resume?" In a nutshell I would replace what is current displayed with the message and and a "Yes" and "no" buttons. |
@kelson42 Yes, we can modify the current running notification, but there could be multiple notifications for multiple downloads. So, this should be for each notification or only for one? Or for minimal and clear we should we post only a single notification with your given message and buttons? |
Indeed, I have forgotten about this scenario. So you need:
|
|
Here I have something to highlight first.
If we put them as a pause notification, the user could not resume the download by clicking on the "Resume" button in the download. Because the service has stopped, so clicking on it will do nothing.
Yes, currently I am doing the same, only creating a single notification and removing all ongoing notifications along with the "Paused" notification(Since the user could not resume the download until they open the application). So, keeping those notifications will confuse users since they cannot restart the download from the notification. When they click on the "Yes" button, the app will open, and this timer will reset. But before opening the app, the users can not start the download since the time limit is not reset. |
…tion$ForegroundServiceDidNotStopInTimeException`. * Android 15 introduced a limitation where an app can run a foreground service in the background for only `6 hours per day`, unless the user explicitly opens the app again, which resets this timer. * To prevent this crash, we have overridden the `onTimeout` method in both `DownloadMonitorService` and `HotspotService`, and we now stop the service when the timeout limit is reached.
…fication. Users can tap the "Yes" button to open the app, which resets the background-execution timer. After that, they can easily resume their downloads. * All ongoing downloads are paused before stopping the service, ensuring that no misleading notifications remain visible (users cannot resume downloads from notifications because the service is already stopped). * When the user taps "Yes" in the notification, the app opens directly on the Downloads screen so they can resume their downloads. For custom apps, it simply opens the application, and the CustomReaderFragment handles navigating to the DownloadFragment.
954f53b to
c7857d4
Compare
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (23.30%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #4502 +/- ##
============================================
- Coverage 58.94% 58.89% -0.05%
- Complexity 1494 1505 +11
============================================
Files 319 320 +1
Lines 17115 17237 +122
Branches 2136 2143 +7
============================================
+ Hits 10088 10152 +64
- Misses 5624 5679 +55
- Partials 1403 1406 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I don't get it, we don't really do it, this is the android timeout triggering this.
So, you will recreate all the download notifications once the he has clicked on "resume"? |
* Added a `DownloadTimeoutDismissReceiver` which will listen for the "No" button event and dismiss the notification.
Let me clarify. When the Android background timeout is reached, the system will forcibly kill our foreground service. If we don’t pause the downloads ourselves before this happens, the downloads will be paused anyway, but in a problematic way:
Yes. When the user taps the “Yes” button, the app launches again. At that moment, we recreate all download notifications in their paused state. Since we navigate the user directly to the “Download” screen, they immediately see that all downloads are paused and can resume them easily. Edited: I was thinking that when the user clicks on the "Yes" button, then automatically resume all the paused downloads(When app comes in foreground). But if a user intentionally paused a download, it will also be resumed(Which is not a good idea). |
|
@kelson42 I have fixed the "No" button issue. But here, i am seeing some behaviour in our application. Due to this new limitation, there is a new scenario that comes in A one issue i am seeing if the download is in progress and we closes the application, and reopens it it keeps us on |
|
@MohitMaliFtechiz Remember me: why we don't resume automatically? |
@kelson42 For custom apps, it can be easily done because there is only a single file to download. But for the Kiwix app, there could be multiple downloads running at a time. And some of them user explicitly paused. So resuming them all automatically is not good IMO. Instead, we should add a param to our DB to track whether the download is paused by the system or user. If paused by the system, after reopening the application, we should resume those downloads automatically. |
… Android’s background execution limits. * Added a `PausedReason` field in `DownloadRoomEntity` so we can automatically resume downloads when the user returns to the application. * Fixed: In Custom apps, if a download was running and the user closed and reopened the app, the app incorrectly showed the Reader screen with an error stating that the current ZIM file is not valid, instead of showing the `DownloadScreen`. * Fixed: The “Android background limit” notification remained visible even after the user reopened the application manually.
…showing for not a valid ZIM file which should not show at this time, because download is in progress. * Updated the methods comment for better understanding.
|
@kelson42, I have updated the videos on the PR description. How automatically starting the downloads works, and how our "Limit" reach notification will look like, and how it's working for both Kiwix and custom apps. |
Fixes #4486
6 hours per day, unless the user explicitly opens the app again, which resets this timer. See https://developer.android.com/develop/background-work/services/fgs/timeout.onTimeoutmethod in bothDownloadMonitorServiceandHotspotService, and we now stop the service when the timeout limit is reached.DownloadTimeoutDismissReceiverwhich will listen for the "No" button event and dismiss the notification.PausedReasonfield inDownloadRoomEntityso we can automatically resume downloads when the user returns to the application.DownloadScreen.KiwixApp.mp4
CustomApp.mp4