collect icon indicating copy to clipboard operation
collect copied to clipboard

Selfie camera not showing on Redmi?

Open yanokwa opened this issue 3 years ago • 19 comments

Software and hardware versions

Collect v2021.3.0

Problem description

My Redmi Note 8 Camera and the ODK app are not working properly despite giving ODK full permission to use the phone's camera. Also, all my other apps that needed camera access are working properly so I can attest that the ODK app is not working properly.

The app does not crash but this is what it looks like when it tries to use my phone's camera. I can't finish my survey if this goes on since an observer's selfie is needed to complete it

Screenshot_2021-11-09-15-34-32-325_org odk collect android

Screenshot_2021-11-09-10-49-40-698_com android settings

yanokwa avatar Nov 10 '21 22:11 yanokwa

I quickly verified that I can use the camera (QR scanning and the image/selfie widget) on my Android 11 test device (Pixel 4a) and everything looked good. I'm not seeing any non-fatals in Firebase that look like a match for this either.

Does the person reporting this work with other people using the same device (or another Redmi)?

seadowg avatar Nov 11 '21 09:11 seadowg

I probably experienced something similar but not the same on ODK Collect v2021.3.0 - v2021.3.2. All permissions were allowed on all devices.

I have tried the selfie function on Redmi Note 9 Pro with MIUI version 12.0.5 (Android 10) and 12.5.1 (Android 11). Upon hitting the Take Picture button, the selfie camera appears and shows the correct orientation of the camera. However after tapping the screen, the image does not appear in the form and thus the form cannot proceed due to the required flag being set to yes. I have tried the All Widgets form version 2021021001 demo project and the issue remained the same.

Some interesting point that I have observed is that if the main camera works and shows up properly in the form. I immediately tried the selfie next and found out that after tapping the screen, the previous image from the main camera appeared instead. I then went back to the main camera to replace the image and the selfie also changes to the replaced image after tapping the screen.

There was one instance where the selfie camera worked and appeared when I tried adding the demo project on top of existing projects. After opening the form, I tried to run the selfie camera first and it worked. However, I was not able to reproduce this result after resetting ODK and trying it again with the demo form and other forms.

Most other Redmi Note 9 Pro devices that work have same or similar specs so I cannot conclude on what exactly went wrong.

erigmac avatar Nov 22 '21 04:11 erigmac

@erigmac thanks so much for investigating.

@kkrawczyk123 do we have, or can we get access to a Redmi Note 8 or 9?

seadowg avatar Nov 22 '21 09:11 seadowg

@seadowg I am not able to reproduce this issue on Redmi 7 and Redmi Nore 9. Selfie widget and selfie video widget work as expected. I have also tried for the required version of selfie widget and it also works as expected. I don't have access to more Redmi devices.

kkrawczyk123 avatar Nov 22 '21 09:11 kkrawczyk123

@yanokwa are you able to check how many ODK Collect installs are running on Redmi devices?

seadowg avatar Nov 23 '21 13:11 seadowg

report.pdf

grzesiek2010 avatar Nov 23 '21 14:11 grzesiek2010

I am not able to reproduce this issue on Redmi 7 and Redmi Nore 9.

@kkrawczyk123 what OS were the devices using? Just want to check if we've definitely got the same setup as @erigmac.

seadowg avatar Nov 23 '21 17:11 seadowg

@seadowg Android 9 on Redmi 7 and Android 10 on Redmi Note 9.

kkrawczyk123 avatar Nov 24 '21 15:11 kkrawczyk123

@kkrawczyk123 is it a Note 9 Pro?

Most other Redmi Note 9 Pro devices that work have same or similar specs so I cannot conclude on what exactly went wrong.

@erigmac do you mean that some devices don't have any problems using the front facing camera with ODK Collect.

seadowg avatar Nov 24 '21 17:11 seadowg

@kkrawczyk123 is it a Note 9 Pro?

Most other Redmi Note 9 Pro devices that work have same or similar specs so I cannot conclude on what exactly went wrong.

@erigmac do you mean that some devices don't have any problems using the front facing camera with ODK Collect.

@seadowg Some correction needs to be made to this statement here.

I recently went to the field to verify the situation and found out that ALL Redmi Note 9 Pro devices are affected with the issue mentioned.

Other Xiaomi models we are running including: Redmi 9, Redmi 9A, Redmi 9T, Redmi Note 9, Redmi Note 10S, Redmi 10 are not affected

I will update here if the situation changes.

erigmac avatar Nov 25 '21 01:11 erigmac

@seadowg I was not able to reproduce this issue on Redmi 9T, Android 10. I checked it with selfie and video widget. MIUI version is: 12.0.9

srujner avatar Nov 25 '21 09:11 srujner

It looks like we're not going to have much luck reproducing this with our devices. I'll do an investigation to see if there are any errors/exceptions we could be swallowing that could be logged etc. I'm worried this could be a problem on other devices as well.

seadowg avatar Nov 30 '21 11:11 seadowg

@erigmac here's a debug (zipped) APK with some changes that might fix the problem you're having: collect-selfSignedRelease-v2021.3.2-119-gbd8c168ce.apk.zip (built from the changes at #4923). Let me know if you're able to try it out on a test device (you'll need to uninstall the version of Collect you have one there first) and if you need any help doing so!

seadowg avatar Dec 01 '21 11:12 seadowg

@seadowg OK, I will let you know once I have tested the debug APK on Redmi Note 9 Pro.

erigmac avatar Dec 02 '21 06:12 erigmac

@erigmac did you manage to get a chance to try out the APK?

seadowg avatar Dec 14 '21 15:12 seadowg

@seadowg Sorry it took a while to get hold of the devices, I have tested the APK on Redmi Note 9 Pro and it still didn't help with the selfie function.

I'm currently putting a constraint on the form based on the user to switch to the main camera and have the enumerator switch manually to the selfie camera for now.

Let me know if you need anything else to report since the apk is now installed.

erigmac avatar Dec 18 '21 08:12 erigmac

@erigmac thanks so much looking into it. Sorry the problem still seems to be there.

@yanokwa I think we'll need to look at acquiring a Redmi Note 9 Pro to investigate this further.

seadowg avatar Dec 20 '21 11:12 seadowg

Given that this is a niche device and selfies are a niche feature, I don't think it's worth it to keep investigating. @seadowg is there a way we can detect if this is happening on other devices?

yanokwa avatar Jan 02 '22 23:01 yanokwa

is there a way we can detect if this is happening on other devices?

Not that we know of. Given there isn't a crash, and we haven't been able to reproduce, we have no idea of what to look for in terms of state/exceptions. I think getting hold of a device (either through a purchase or a donation from someone who's seeing the problem) is the best way to move forward if we want to fix this.

One thought: our selfie widget requires a custom integration with Camera2 (Android's camera SDK) so we can automatically switch to the front facing camera, whereas our normal image widget just uses the camera app on the phone. We could investigate if we can achieve the same behaviour without writing our own camera integration (just using the phone's camera app) although I assume this was already looked into and wasn't possible. Any memory of that @grzesiek2010? If that isn't possible, a more drastic option would be to deprecate the selfie widget which would be a another discussion.

seadowg avatar Jan 05 '22 09:01 seadowg

@erigmac we've refactored the code responsible for using the selfie camera (now we use CameraX instead of Camera2). Could you test the latest version available on the store and let us know if the problem is fixed?

grzesiek2010 avatar Dec 21 '22 12:12 grzesiek2010

Hi @grzesiek2010,

Thank you very much for the update.

I will test the Redmi Note 9 Pro sometime in the next week.

However, the latest version 2022.4.2 caused the Redmi 9T (M2010J19SG) on Android 11 to crash when pressing the shutter button on the main camera. There are no issues with the selfie camera. I suppose that the crash logs here might be able to help you to see if the crash is related with the refactored code.

java.lang.IllegalArgumentException: supportsCameraApi:2548: Unknown camera ID -1 at android.hardware.camera2.CameraManager.throwAsPublicException(CameraManager.java:1075) at android.hardware.camera2.CameraManager.getCameraCharacteristics(CameraManager.java:465) at android.hardware.camera2.CameraManager.openCameraDeviceUserAsync(CameraManager.java:536) at android.hardware.camera2.CameraManager.openCameraForUid(CameraManager.java:799) at android.hardware.camera2.CameraManager.openCamera(CameraManager.java:706) at com.xiaomi.camera.imagecodec.impl.VirtualCameraReprocessor.openVTCamera(Unknown Source:31) at com.xiaomi.camera.imagecodec.impl.VirtualCameraReprocessor.createCaptureSessionIfNeed(Unknown Source:101) at com.xiaomi.camera.imagecodec.impl.VirtualCameraReprocessor.checkConditionIsReady(Unknown Source:36) at com.xiaomi.camera.imagecodec.impl.VirtualCameraReprocessor.access$1500(Unknown Source:0) at com.xiaomi.camera.imagecodec.impl.VirtualCameraReprocessor$ReprocessHandler.handleMessage(Unknown Source:102) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:236) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: android.os.ServiceSpecificException: supportsCameraApi:2548: Unknown camera ID -1 (code 3) at android.os.Parcel.createExceptionOrNull(Parcel.java:2391) at android.os.Parcel.createException(Parcel.java:2361) at android.os.Parcel.readException(Parcel.java:2344) at android.os.Parcel.readException(Parcel.java:2286) at android.hardware.ICameraService$Stub$Proxy.supportsCameraApi(ICameraService.java:906) at android.hardware.camera2.CameraManager.supportsCameraApiLocked(CameraManager.java:1128) at android.hardware.camera2.CameraManager.supportsCamera2ApiLocked(CameraManager.java:1104) at android.hardware.camera2.CameraManager.getCameraCharacteristics(CameraManager.java:423) ... 11 more

Please let me know if you need anything else.

erigmac avatar Dec 24 '22 03:12 erigmac

@erigmac Thanks for trying it out!

on Android 11 to crash when pressing the shutter button on the main camera.

The standard (non-selfie) image widget uses the device's default camera app, and it looks like the crash is happening there rather than in ODK Collect. It might be worth changing the default camera app if you continue to have that problem.

seadowg avatar Dec 27 '22 20:12 seadowg