Closed Bug 1489972 Opened 1 year ago Closed 1 year ago

An error is displayed if we deny and allow the permissions for camera

Categories

(Firefox for Android :: Audio/Video, defect, P1)

ARM
Android
defect

Tracking

()

RESOLVED WONTFIX
Tracking Status
firefox62 --- wontfix
firefox63 --- wontfix
firefox64 --- wontfix
firefox65 --- wontfix
firefox66 --- wontfix

People

(Reporter: sflorean, Assigned: petru)

Details

Environment: 
Device: Nokia 6(Android 7.1.1);
Build: Nightly 64.0a1 (2018-09-09);

Steps to reproduce:
1. Go to https://webrtc.github.io/samples/src/content/getusermedia/gum/;
2. Tap on "Open camera";
3. From doorhanger, tap on "Deny";
4. Tap again on "Open camera" and choose "Allow".

Expected result:
A video is displayed with my built-in camera active showing the content.

Actual result:
An error is displayed.

Notes:
- not reproducible on Google Pixel (Android 9), LG G4(Android 6.0.1); 
- not reproducible with audio only;
- reloading the page has the same actual result.
- Video: https://drive.google.com/open?id=0B_kDj8vLfC8IbHhEcXVaT05mX3oxZERGbU1zVThVbC1uS0w0
Summary: An error is displayed if we deny than allow the permissions for camera → An error is displayed if we deny and allow the permissions for camera
Let's investigate, since these two bugs may be related, it would be good to know if there's a deeper camera permissions issue.
Assignee: nobody → petru.lingurar
Status: NEW → ASSIGNED
The issue is happening because although the app has the `CAMERA` permission,
when it tries to iterate over the available cameras to get their characteristics `Camera.open()`[1] fails
>E/WEBRTC-JC: Failed to open Camera 0, Facing back, Orientation 90, skipping due to: Fail to connect to camera service
and so, with no available cameras the whole process fails.

[1] https://searchfox.org/mozilla-central/source/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureDeviceInfoAndroid.java#110
Tested this more with Sorina (couldn't reproduce on our devices) and I see in logs

> I/CameraService: Camera 0: Access for "org.mozilla.fennec_aurora" has been restricted

This [1] happens when trying [2] to open the camera [3][4][5].
This could only happen if app's uId or package name has been explicitly restricted.

Interestingly enough, doing the same restrictions check, right above `Camera.open(i)` [6],
> AppOpsManager#checkOp(AppOpsManager.OPSTR_CAMERA, Process.myUid(), getPackageName()) 
returns `AppOpsManager#MODE_ALLOWED`
and then immediately after, Camera.open() says we are restricted.

[1] https://android.googlesource.com/platform/frameworks/av/+/oreo-mr1-release/services/camera/libcameraservice/CameraService.cpp#2204
[2] https://github.com/aosp-mirror/platform_frameworks_base/blob/oreo-mr1-release/core/java/android/app/AppOpsManager.java#L1903
[3] https://github.com/aosp-mirror/platform_frameworks_base/blob/oreo-mr1-release/services/core/java/com/android/server/AppOpsService.java#L1150
[4] https://github.com/aosp-mirror/platform_frameworks_base/blob/oreo-mr1-release/services/core/java/com/android/server/AppOpsService.java#L1376
[5] https://github.com/aosp-mirror/platform_frameworks_base/blob/oreo-mr1-release/services/core/java/com/android/server/AppOpsService.java#L2588
[6] https://searchfox.org/mozilla-central/rev/2edebf41a2b2e624859bf15ed5a98bdd002f73b4/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureDeviceInfoAndroid.java#110
Tried to use camera2 APIs but the issue still exists.
Since I cannot reproduce this locally on the devices I have I have asked Sorina to borrow me the Nokia 6 device to base my testing on.
Adding 66 as affected. This work will roll into the new year.
Given that I could not reproduce the described issue on any other devices than this Nokia and nothing I've tried seemed to work I've decided to test the camera functionality with other applications:
I found that following the steps Sorina described in comment 0 also causes the same basic issue in any other app that uses camera.

- With latest Chrome (71.0) browser app:
> android.hardware.camera2.CameraAccessException: CAMERA_DISABLED (1): connectHelper:944: Camera "1" disabled by policy
video - https://drive.google.com/file/d/1YqxhK276QyLAbTShUtT-jxdzZDDC0lKO/view?usp=sharing

- With device's default "Camera" app:
> E/CAM_OneCamera1Opnr: Could not open camera. CAMERA_DISABLED (1): connectHelper:944: Camera "0" disabled by policy
video - https://drive.google.com/file/d/1y4pXSoQAQ5bnQWtluVaD8RMkbbrCf0yB/view?usp=sharing

- With [Camera2Basic Google sample](https://github.com/googlesamples/android-Camera2Basic) app:
> W/System.err: android.hardware.camera2.CameraAccessException: CAMERA_DISABLED (1): connectHelper:944: Camera "0" disabled by policy
video - https://drive.google.com/file/d/1y4pXSoQAQ5bnQWtluVaD8RMkbbrCf0yB/view?usp=sharing

- With latest Firefox Release (64.0.1):
> I/CameraService: Camera 0: Access for "org.mozilla.firefox" has been restricted
video https://drive.google.com/open?id=0B_kDj8vLfC8IbHhEcXVaT05mX3oxZERGbU1zVThVbC1uS0w0

- With latest Firefox Nightly I initially see the same error
> I/CameraService: Camera 1: Access for "org.mozilla.fennec_petru.lingurar" has been restricted
Then followed by a doorhanger in which the site asks to share camera and in logs
> E/GeckoConsole: [JavaScript Error: "uncaught exception: Couldn't find any cameras or microphones being used" {file: "jar:jar:file:///data/app/org.mozilla.fennec_petru.lingurar-1/base.apk!/assets/omni.ja!/components/TabSource.js" line: 60}]
Followed by the only option to "Choose a tab to stream" (this option seems new to Nightly. Don't know in which ticket it was added.)
video https://drive.google.com/file/d/1VcWV8uFhxcp2iTMgLHItAtPCoJBidWNx/view?usp=sharing


So this seems like a device issue and not a bug in our app.
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.