fix(android): read stream-only content URIs and copy content in safeFilePath, release 2.23.0 - #229
Merged
Merged
Conversation
…ilePath, release 2.23.0 A provider that hands out a content URI as a pipe (some cloud and archive providers) failed most calls with "setDataSource failed", because MediaExtractor and MediaMetadataRetriever need random access. The plugin now checks every new content URI off the main thread before dispatching a call and copies only such a stream-only source once into the cache; every other content URI is still read in place. EditorVideo.safeFilePath copies a content video into a temporary file on Android instead of throwing, the same way a network video is downloaded. The content URI device suite now runs against MediaStore, a seekable document provider and a pipe, served by a test provider in the example app.
…cking other calls - A copy of a stream-only source is kept while any call that reads it is in flight. Before, a render of five stream-only clips could delete one of its own copies and fail with "Failed to instantiate extractor". - Only calls with the same task id or a source still to check wait for a check; other calls no longer wait behind a long copy. - The check copies from the stream it opened instead of opening the source twice, and a failed check still answers the call. - Stale copies are cleared off the main thread, calls still waiting when the engine detaches are dropped, and a stream-only source used on two layers is linked instead of copied again. - safeFilePath docs: the copy is used for the video from then on.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Follow-up to #227 (
EditorVideo.content), covering the points still open from #221.setDataSource failed: status = 0xFFFFFFEA, becauseMediaExtractorandMediaMetadataRetrieverneed random access. Before dispatching a call, the plugin now checks every content URI it has not seen yet on a background thread (StreamOnlySources). Only a source that is not a regular file is copied, once, into the cache. Every other content URI is still read in place. Calls keep their order while a check runs, so a cancel never overtakes the task it cancels.EditorVideo.safeFilePathcopies a content video into a temporary file on Android instead of throwing, the same way a network video is downloaded. The copy runs natively (copyContentToFile); no file data goes through the channel. Other platforms still throw anUnsupportedError. The plugin's own calls keep reading the URI in place throughcontentOrSafeFilePath.content_uri_test.dartnow runs the whole suite against three sources: MediaStore, a seekable document provider, and a pipe. The pipe and the document provider are served by a new test provider in the example app (TestMediaProvider). The suite also gains a test forsafeFilePath.Related Issue: #221
Verification
content_uri_test.dart, 54/54 passing. Before the fix, 11 of the 18 pipe tests failed.content://media/picker/0/com.android.providers.media.photopicker/...) and a SAF document URI (content://com.android.externalstorage.documents/...). Metadata, thumbnails, audio extraction, waveform, a render with a dissolve and a reversed clip, a two-layer composition, split and audio merge all passed without warnings.concurrency_test,thumbnail_stream_testanderror_handling_testpass.flutter analyze,flutter test(500) and the Android unit tests (271) pass.Type of Change