:memo: The recently released WorkManager 2.5.0 is more suitable for use in a multi-process environment and provides many stability improvements. So if you have an app that manages multiple processes and needs a robust way to manage background work (no more initialization errors ⚠), this is the version for you. You need to make a few changes to the code, read on to find out more. At the end of this article, I'll also list some other behavior changes and additions to this version of the WorkManager library. Introducing: work-multiprocess This new multi-process artifact provides performance improvements by unifying job scheduling into a single process. To start using this artifact, add it to your application.
You can now select a specific process that the WorkManager uses to queue the WorkRequest and run its in-process scheduler.
The configuration using Configuration.Provider is shown below.
Note: You need to pass the fully qualified process name as the parameter to setProcessName , which consists of your app package name followed by a colon and the host's process name, for example com.example:remote . When using work-multiprocess, you need to use RemoteWorkManager (not WorkManager) to manage your work requests. RemoteWorkManager will always queue your work using the specified process. This ensures that you do not accidentally initialize a new WorkManager in the calling process. The in-process scheduler will also run in the same process specified.
AdvantagesWhen you configure WorkManager as described above and schedule jobs using RemoteWorkManager, your work will be managed more quickly and reliably in multi-process applications. This is because SQLite contention is greatly reduced (because we no longer rely on file-based locking), and cross-process job coordination is no longer required because your application only runs a single WorkManager instance in the process you specify.
Behavior change: twisted_rightwards_arrows: Operation coordination Previously, when ActivityManager failed to instantiate a JobService to start a job, the job would be silently dropped due to underlying issues in the platform. WorkManager now ensures that when creating an "app" instance by coordinating a WorkRequest object with a job, each WorkRequest will have a backing scheduler job. Limiting internal database growth We found that one of the reasons for the app crashing was low device storage. This mainly happened on devices with low storage. However, when the app was scheduling a lot of work, the low device storage was partially caused by WorkManager. By default, the internal WorkManager database retains records of completed jobs for 7 days. This period has now been reduced to 1 day, significantly reducing the size of the database. We've reduced the buffer duration so that you can control how long jobs should be kept with the keepResultsForAtLeast() API. New testing API :sparkles: If you use ListenableFuture with WorkManager, testing just got easier — the TestListenableWorkerBuilder Kotlin extension now takes any class extending ListenableWorker , giving you more flexibility during testing. Bug fixes: In addition to new features, this release also includes multiple bug fixes to improve the stability, reliability, and performance of WorkManager. You can view all changes and bug fixes in the release notes.
How to improve WorkManager Contribute to WorkManager via GitHub :woman::computer: WorkManager, along with several other Jetpack libraries, accepts contributions via GitHub. Alan Viverette wrote a thorough blog post about the entire process.
Please let us know if you encounter any problems :memo: Most of the bugs fixed in the 2.5.0 release were reported via the public issue tracker.
The best way to create a fixable issue is to create an issue that we can reproduce . To help us reproduce the issue, we recommend that you use this WorkManager example or provide your sample code with the issue description.
It's time to take action and update the WorkManager library used in your application. |
<<: Android 12's new theme system exposed: greatly improved appearance
>>: Do you really know how to use Apple's Files app? You may not know these five features
Hello everyone, this is the 5th issue of the Envi...
Produced by: Science Popularization China Author:...
After Liang Jun was promoted to general manager o...
In the Internet age, short videos are king. 2018 ...
Clarifying the purpose of an event should be the ...
The Internet wave has swept in, bringing populari...
In this era of rapid development, if you want to ...
Think about this morning. Did you reach for your p...
Hyper HT, a medium-to-large luxury pure electric ...
[[154784]] With the continuous rise of a series o...
Since the end of the "Thousands of Group War...
The blind box craze has made Pop Mart popular, ma...
Sony officially announced at the beginning of this...
In response to reports of unexplained cases of ac...
Recently, a topic "A woman's wisdom teet...