Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): prevent app crash caused by NPE on intent data or mediaFile #232

Merged
merged 3 commits into from Aug 3, 2023

Conversation

ath0mas
Copy link
Contributor

@ath0mas ath0mas commented Nov 6, 2021

Platforms affected

Android

Motivation and Context

Prevent app crash after capture and show error if no content or no access to it

Description

  1. minimal fix MediaCapture CaptureVideo immediately closing app on Android 11 #227
    Unify null checks for all three capture types, first on retrieved intent data uri (failing with CAPTURE_NO_MEDIA_FILES), and then on no mediaFile created (failing with CAPTURE_INTERNAL_ERR)
  2. Simplify how video uri is retrieved from Video capture intent (see Add the ability to specify where the capture should be saved #210 comment)

Testing

App crashing because of audio capture in some conditions (see #227 comment) now resolves with failure instead.
Not perfect, expecting #215 work on FileProvider to solve the problem but for now it is not an app crash anymore.

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@erisu erisu changed the title Android: Prevent app crash caused by NPE on intent data or mediaFile fix(android): prevent app crash caused by NPE on intent data or mediaFile Aug 1, 2023
Copy link
Member

@erisu erisu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM

I also tested and confirmed that the app no longer crashes.

The front-end also received the Error: no mediaFile created from error object as expected.

@erisu erisu merged commit 69bb93d into apache:master Aug 3, 2023
5 of 10 checks passed
4.x automation moved this from In progress to Done Aug 3, 2023
@ath0mas ath0mas deleted the mediafile-npe-crash branch August 3, 2023 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
4.x
Done
Development

Successfully merging this pull request may close these issues.

MediaCapture CaptureVideo immediately closing app on Android 11
3 participants