Process the files in a separate thread on Android #2142
Merged
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.
Motivation (required)
At the moment, when picking files on Android, all the processing (copying the file into the app's cache & extracting metadata) is made in the main thread.
This causes the app UI to become unavailable, and may trigger Android's Application Not Responding alerts, or have the application killed.
This changes runs the processing in a separate thread, that notifies the RN bridge once finished.
Ideally we could have a thread pool and have each file processed independently inside a thread, but I am not familiar enough with Java to do this properly.
Test Plan (required)
I tested this both in Emulator and on a physical Android 13 phone, using the example app.
It worked fine with many videos or photos and the app UI was responsive.
I am trying to resurrect an older Android device to run the tests on it.