Use a fallback default video resolution when it can't be obtained from mediaMetadataExrtactor #621
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.
Fixes #620
Issue
It was observed When using a .mov video located on the server (
https://
..., with a .mov video that was previously uploaded to a site's Media section), the player and the composer would behave randomly. As per my tests, it definitely does work right after uploading it to the Media section, but ceases to work after a few minutes of having it uploaded, and then it only works again if, after selecting the video and leaving the player playing in a loop, you then proceed to try saving the Story. By "work" I mean, the media metadata extractor is able to obtain the video resolution and other metadata without a problem, while it returnsnull
values for the same keys in other occasions on the same video / same url.Weird as it sounds, I couldn't find the correlation yet but I believe there might be the Android 10 permissions handling coming into play, since the
targetSdkVersion
was changed on WPAndroid to API level 29. I still have to dig more into it, and I think one potential safer approach would be to first download the video to a local copy, before attempting to extract and make the composition by reading the remote video file into a buffer on the fly.For now, this PR only takes care for the exact crash described above.
Fix
This PR catches the possible exceptions when trying to figure out the original video resolution.
However, when the mediaExtractor can't obtain the video height and width, it will likely also fail just a few steps later when trying to obtain any other relevant information for the composer to work.
In the tests I've made, it will fail in obtaining the default track to read, for example here:
The app won't crash and will show an error notification, but from what I could see it is likely not a retriable error. You will be offered the option to retry as per the error handling mechanism in place, but chances are it's easier to discard the Story and start all over.
At least, with this patch won't crash the app, but this is certainly a thing we need to continue looking into further.
To test:
CASE A: (recent added video doesn't crash)
CASE B: (after some minutes)
I'll cotinue working on this, but for now this patch should at least save the crash.