Improve SAF performance and defer custom filename template processing to the end of the call #257
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.
As encountered in #252, some devices have a horrendous SAF implementation that takes upwards of 8 seconds just to check for the existence of
bcr.properties
in the output directory. The main cause of the delay is that theDocumentFile.findFile()
implementation is very inefficient and performs a separate query to the document provider for each child in the directory. The first commit addresses this by reimplementing the method to use a single query.However, even with the optimized query, it still takes >500ms on some devices, so the second commit updates
RecorderThread
to defer custom filename template processing until the end of the call.To illustrate the absurdity of this slowness, when using native
File
s with the default output directory (no-SAF) on the same device, the same set of operations takes 2ms.Fixes: #252