Oct 1 | 8:20 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Oct 1 | 8:25 AM |
Abhishek K. | has entered the room |
Abhishek K. |
Hey Murphy
|
Mark M. |
hello Abhishek!
|
Mark M. |
how can I help you today?
|
Abhishek K. |
I'm facing an issue with with CoroutineWOrker
|
Mark M. |
I have not spent much time with that class, but I can try to help!
|
Abhishek K. |
I'm using suspendCancellableCoroutine to stop the coroutine and using cancellableContinuation.resumeWithException when any error happens with onError callback
|
Oct 1 | 8:30 AM |
Abhishek K. |
Now I'm downloading some file from network and whenever some error happens, flow goes to onError. Now when single file is getting downloaded and single WOrkRequest is running, everythign work fine
|
Abhishek K. |
flow comes to onError and as soon as cancellableContinuation.resumeWithException is called, flow goes to catch block and coroutine returns with Result.failure()
|
Abhishek K. |
But when I run more than 1 workrequest at the same time in parallel, problem happens. Problem is that for some WorkRequest, after calling cancellableContinuation.resumeWithException , flow takes a whole lot of time to come to catch block
|
Abhishek K. |
and it happens only when onError is called for all Worker at the same time almost
|
Abhishek K. |
any lead on this?
|
Mark M. |
sorry, but no -- that is well beyond my limited CoroutineWorker experience
|
Abhishek K. |
Okay.
|
Abhishek K. |
I have one more problem
|
Abhishek K. |
its with DocumentFile
|
Mark M. |
OK, I have more experience with that! :-)
|
Abhishek K. |
I'm using SD card in my product, it asks for root permission of SD card
|
Mark M. |
what do you mean by "asks for root permission of SD card"?
|
Oct 1 | 8:35 AM |
Abhishek K. |
root permission as in, to deal with any folder inside SD card, we need access permission from user, right?
|
Abhishek K. |
If I give root access permission, i can do anything with any folder inside the root. All folders are covered
|
Abhishek K. |
got it?
|
Mark M. |
I think you are using "permission" in a different way than I do -- what specific APIs are you using to accomplish this?
|
Abhishek K. |
View paste
|
Abhishek K. |
I'm using this to open the document tree
|
Mark M. |
you can get rid of those flags, but otherwise, now I understand what you mean
|
Abhishek K. |
Okay,
|
Abhishek K. |
So, Now the problem is that
|
Abhishek K. |
when I have already granted permission
|
Abhishek K. |
and device is restarted,
|
Abhishek K. |
var document = DocumentFile.fromTreeUri(application, treeUri)
|
Abhishek K. |
document.listFile() is null
|
Oct 1 | 8:40 AM |
Abhishek K. |
its happening only when device is restarted
|
Abhishek K. |
any lead?
|
Mark M. |
are you calling takePersistableUriPermission() after you receive the Uri, in onActivityResult()?
|
Abhishek K. |
no
|
Mark M. |
OK, start there
|
Abhishek K. |
View paste
|
Abhishek K. |
this is onActivityREsult
|
Abhishek K. |
just storing it
|
Mark M. |
after the val sdCardTreeUri line, call contentResolver.takePersistableUriPermission(sdCardTreeUri)
|
Mark M. | |
Abhishek K. |
will it solve it?
|
Mark M. |
probably
|
Mark M. |
I cannot rule out the possibility of some additional problem that you are encountering
|
Mark M. |
but, you can only use that Uri in that particular activity, not from another Context or another process
|
Mark M. |
unless you call takePersistableUriPermission()
|
Mark M. |
the blog post that I linked to covers this
|
Abhishek K. |
takePersistableUriPermission(sdCardTreeUri) is aksing for some flags also in addition to uri
|
Mark M. |
yes, that is where you use Intent.FLAG_GRANT_READ_URI_PERMISSION
|
Mark M. |
(and Intent.FLAG_GRANT_WRITE_URI_PERMISSION if you need it)
|
Abhishek K. |
Okay.
|
Abhishek K. |
Got it.
|
Abhishek K. |
no lead on the first problem?
|
Mark M. |
no, sorry, I have not used CoroutineWorker that much, let alone for a bunch of parallel work
|
Oct 1 | 8:45 AM |
Abhishek K. |
anywhere I can find any clue regarding that?
|
Mark M. |
¯\_(ツ)_/¯
|
Abhishek K. |
Hehe
|
Mark M. |
Stack Overflow and other public question-and-answer sites, I guess
|
Abhishek K. |
Anyway
|
Abhishek K. |
Thanks Mark
|
Mark M. |
and, FWIW, all the WorkManager stuff is in a library, so in theory you could debug it
|
Abhishek K. |
View paste
|
Abhishek K. |
View paste
|
Abhishek K. |
this is where it leads to
|
Abhishek K. |
View paste
|
Abhishek K. |
resumeWIth is overridden in 2 classes
|
Abhishek K. |
View paste
|
Abhishek K. |
and
|
Abhishek K. |
View paste
(10 more lines)
|
Abhishek K. |
I dont think how can I debug
|
Abhishek K. |
thos
|
Abhishek K. |
this*
|
Mark M. |
again, ¯\_(ツ)_/¯
|
Abhishek K. |
Okay
|
Abhishek K. |
Thanks anyway
|
Mark M. |
this is the sort of thing where if I had the problem in front of me, I might have more ideas
|
Oct 1 | 8:50 AM |
Mark M. |
but I just don't know enough about this particular portion of WorkManager to really comment "off the cuff"
|
Abhishek K. |
lol
|
Abhishek K. |
Okay
|
Abhishek K. |
Thanks for the solution of the second problem.
|
Mark M. |
you're welcome!
|
Abhishek K. | has left the room |
Abhishek K. | has entered the room |
Oct 1 | 9:10 AM |
Abhishek K. | has left the room |
Oct 1 | 9:25 AM |
Mark M. | turned off guest access |