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

Crash caused by permissions not requested and also by user not accepting permissions #238

Closed
Chris-RH opened this issue Jan 18, 2023 · 3 comments
Assignees
Labels
Android Bug 🐛 Something isn't working fixed The issue has been fixed and will be available in the next release
Milestone

Comments

@Chris-RH
Copy link
Collaborator

(Submitted via email)

Describe the bug
Crash on opening android app when permission to record audio is not requested in manifest.
Crash also occurs when permission is requested, but user denies permission.
If the user does not give the permission, then CaptureBase.HasUserAuthorisationToCaptureAudio() returns NotDetermined, this most likely should be Denied. NotDetermined causes the crash when the recording is started.

Your Setup (please complete the following information):

  • Unity version: 2021.3.13f1
  • AVPro Movie Capture version: AVPro Movie Capture 5.1.0.0f1
  • Operating system version: Android
  • Capture component used: CaptureWithScreen and CaptureWithCamera
  • Capture settings (resolution, frame-rate, codec): N/A

Logs
[AVProMovieCapture] Failed to create recorder

@Chris-RH
Copy link
Collaborator Author

In CaptureBase.cs, Permission.RequestUserPermission() is used to trigger the permission dialog. This call is not synchronous and the execution continues.
On the next line: call RequestUserAuthorisationToCaptureAudioCallback() which sets _waitingForAudioCaptureDeviceAuthorisation = false; This results in the permission to be immediately resolved to NotDetermined.

Possible solution is to use callbacks, as stated in the Unity Documentation. That way _waitingForAudioCaptureDeviceAuthorisation is set to false only after user has made their choice.

image (1)

@MorrisRH MorrisRH self-assigned this Feb 1, 2023
@MorrisRH MorrisRH added the Bug 🐛 Something isn't working label Feb 1, 2023
@MorrisRH MorrisRH added this to the 0 - Next Release milestone Feb 1, 2023
@MorrisRH MorrisRH added the fixed The issue has been fixed and will be available in the next release label Feb 2, 2023
@MorrisRH
Copy link
Collaborator

MorrisRH commented Feb 2, 2023

The audio recording permission is now checked on the native side before creating the recorder so will no longer crash.

Audio permissions have been reworked to use the newer callback system (Unity 2020.2 and later), however the problem remains for older Unity's where there is no way to tell if permission has been requested and denied.

@Chris-RH
Copy link
Collaborator Author

Fix released in latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Bug 🐛 Something isn't working fixed The issue has been fixed and will be available in the next release
Projects
None yet
Development

No branches or pull requests

2 participants