Correct thread issue during Android copy/move - Thread.yield() #1150
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In memory starved or slow devices during the process of lodging many copy operations. We find some odd behavior that leads to the previous copies obtaining the copied file from the last iteration ran.
Lets say I am copying 3 photos
In that order. When the memory is intentionally starved or device is slowed down. We will find that (cat.jpg/dog.jpg) during the copy operation actually become fish.jpg. This behavior started after the merge of: #597
I started investigating how this could happen and I landed on this
Thread.yield()
line, which seems quite suspicious after reading the docsSo in one simple test I removed
Thread.yield()
and I could no longer replicate the issue. I believe this is the culprit for some of the odd reported issues. My guess is even though the executor is held to 1 queue due to the async nature of the calls and variety of OS - some may yield to the next pending task, which then collides on the variables and causes corruption/copies, etc.