-
Notifications
You must be signed in to change notification settings - Fork 22
Resolve issues with foreground tasks getting cancelled #207
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
Conversation
radinamatic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
APK tested on an Android 11 tablet, 6GBs from the CK12 channel imported without a single hickup in the logcat or UI 👏🏽 💯 ![]()
| logcat | task completed |
|---|---|
| Android11-TabA7.log | ![]() |
Nice! |
rtibbles
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks to the PR description, I understand this at a high level - although don't feel completely equipped to comment on specific changes. But it also works in manual testing, and feels like a decent amount of cleanup and consolidation too!
| implementation 'androidx.concurrent:concurrent-futures:1.1.0' | ||
| implementation 'androidx.work:work-runtime:2.9.0' | ||
| implementation 'androidx.work:work-multiprocess:2.9.0' | ||
| implementation "androidx.lifecycle:lifecycle-service:2.7.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did Android Studio warn you about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It did not! 🤦 Besides highlighting the inherited classes as red (missing), which still required you to click through and look at the class itself.
| # PROGRESS_LIMIT gives sufficient precision for a % progress calculation | ||
| if total_progress > PROGRESS_LIMIT: | ||
| progress = progress // total_progress * PROGRESS_LIMIT | ||
| progress = PROGRESS_LIMIT * progress // total_progress |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes... the previous version would always go to 0... I guess the math didn't check out!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally had math.floor(...) and tested it with that, then I thought "oh yeah there's integer division // which is simpler" (self-sabotage)

Summary
androidx.lifecycle:lifecycle-service:2.7.0sinceSystemForegroundServicerelies on it (possible this was the problematic oversight)PythonProviderclass which implementsAutoCloseablefor use with try-with-resources, to provider the android context to the python side, and automatically ensure we don't create context memory leaksContextUtilto utilize thePythonProviderif it's activeWorkerinstead ofRemoteListenableWorkersetForegroundAsyncthat was mistakenly deleted, but does not call it repeatedly-- calling it repeatedly seemed to have no benefit against the issue but to spam the logsWorkerServicewhich was aRemoteWorkerServicefor runningRemoteListenableWorkersonProgressUpdatehook method to worker base class which is called when the task's progress is updated, and by default callssetProgressAsyncand updates the notification (this may be the true fix)//division instead of usingmath.floor(...)changed in Overflow error when updating task progress #204android.permission.POST_NOTIFICATIONSpermission and check for it since Android Studio was complaining about it missing (I don't recall this happening previously)References
Fixes #205