Replies: 2 comments 1 reply
-
A background thread, sure, but I don't think they use a background process by default? Only the
Unfortunately the answer is that I don't know because I've never tried that setup. I can tell you that two Dart isolates sharing an |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the swift response! It helped me gain some valuable insights. I need to support scenarios where the WorkManager task executes even when the main application is not running. One specific scenario that highlights the challenge is as follows:
In this situation, as I understand it, it's highly probable that the WorkManager task and the main application will be running in completely separate Android processes. The WorkManager task would be initiated by the Android OS upon boot and network availability, independently of any existing application process. When the user later launches the app, a new application process will be created. Given that IsolateNameServer instances are scoped to individual Dart VM instances within a single process, it seems unlikely that the WorkManager task's isolate (running in its own process) would be able to directly access the IsolateNameServer instance of the main application (running in a separate process created later). |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been reviewing the available documentation for Drift and WorkManager, but I'm still seeking clarification on a specific use case.
My application requires uploading collections of files to a server using WorkManager tasks. Each task needs to:
These WorkManager tasks have a constraint requiring internet connection, meaning they could be executed when the main application is not running. Upon the next startup of the application, it needs to retrieve the upload completion status of each WorkManager task.
In a discussion (#3249), it was mentioned: "So as long as the two isolates share a IsolateNameServer instance (I think they do since they're running in the same process), you can use the driftDatabase function from package:drift_flutter with the shareAcrossIsolates: true option)."
However, based on information from Android documentation regarding WorkManager, it seems that WorkManager tasks often run in a separate Android process from the main application. This would imply that they would not share the same IsolateNameServer instance.
Given this potential discrepancy, I'm unsure if the simple setup using
driftDatabase()withshareAcrossIsolates: true, as described in thedrift_flutter packagedocumentation (https://pub.dev/packages/drift_flutter), is a viable solution for my use case, particularly when the WorkManager task is executed while the main application is closed.Could you please clarify whether using
shareAcrossIsolates: truewithdriftDatabase()is a reliable approach for communication between the main application and WorkManager tasks?Beta Was this translation helpful? Give feedback.
All reactions