[TIMOB-25565] Android: Ti.Media.showCamera with an overlay fires success callback multiple times on some devices
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-01-24T22:25:36.000+0000 |
Affected Version/s | Release 6.0.0 |
Fix Version/s | Release 7.0.2 |
Components | Android |
Labels | n/a |
Reporter | Prashant Saini |
Assignee | Gary Mathews |
Created | 2017-11-20T16:11:53.000+0000 |
Updated | 2018-01-25T00:17:01.000+0000 |
Description
Using an
overlay
in Ti.Media.showCamera()
requires to capture picture programmatically using Ti.Media.takePicture()
method, but when used with autohide:false
, the success
callback is fired repeatedly on my Moto G4 Play device. This Moto device is able to auto-focus perfectly & that's why the console shows the relevant log but it's certainly a bug as it's impossible to create a custom-overlay camera feature to capture pics continuously without closing the camera.
On the other hand, my Samsung On5 device was not firing success callback multiple times but it was also not able to auto-focus on things. So it seems the issue is related to auto-focus feature which is very much required & thus making overlay useless on my Moto G4 Play device.
*Steps to reproduce:*
1- Tap 'Open Camera' button
2- Tap Take Picture
button & do not press back button in order to keep camera window open
3- Try to notice if your device is able to auto-focus or not by moving the camera around quickly.
4- If your device is able to auto-focus on different objects, then only success callback will be fired multiple times.
Here's a sample code for this:
var view = Ti.UI.createView({
height : Ti.UI.SIZE,
width : Ti.UI.SIZE,
bottom : 50
});
var button = Ti.UI.createButton({
title:' Take Picture '
});
button.addEventListener('click', function () { Ti.Media.takePicture(); });
view.add(button);
var captureBtn = Ti.UI.createButton({
title:' Open Camera ',
});
captureBtn.addEventListener('click', startCamera);
var win = Ti.UI.createWindow({
backgroundColor : "#e4e2df"
});
win.add(captureBtn);
win.open();
function startCamera() {
if (Ti.Media.hasCameraPermissions()) {
showCamera();
} else {
Ti.Media.requestCameraPermissions(function (e) {
e.success && showCamera();
});
}
}
function showCamera() {
Ti.Media.showCamera({
autohide : false,
saveToPhotoGallery : true,
overlay : view,
success : function(e) {
Ti.API.info('Path = ' + e.media.nativePath);
}
});
}
Here's the output of this code on Moto G4 Play device:
[INFO] : Path = file:///storage/emulated/0/Pictures/Titanium Android Samples/tia-1117983170.jpg
[WARN] : TiCameraActivity: (main) [5721,41280] Unable to focus.
[INFO] :
[INFO] : Path = file:///storage/emulated/0/Pictures/Titanium Android Samples/tia341194327.jpg
[WARN] : TiCameraActivity: (main) [768,42048] Unable to focus.
[INFO] :
[INFO] : Path = file:///storage/emulated/0/Pictures/Titanium Android Samples/tia-679926680.jpg
[WARN] : TiCameraActivity: (main) [685,42733] Unable to focus.
[INFO] :
[INFO] : Path = file:///storage/emulated/0/Pictures/Titanium Android Samples/tia433451119.jpg
[WARN] : TiCameraActivity: (main) [599,43332] Unable to focus.
[INFO] :
[INFO] : Path = file:///storage/emulated/0/Pictures/Titanium Android Samples/tia-1426643918.jpg
[WARN] : TiCameraActivity: (main) [398,43730] Unable to focus.
[INFO] :
[INFO] : Path = file:///storage/emulated/0/Pictures/Titanium Android Samples/tia1408998036.jpg
[WARN] : TiCameraActivity: (main) [282,44012] Unable to focus.
[INFO] :
[INFO] : Path = file:///storage/emulated/0/Pictures/Titanium Android Samples/tia-625031907.jpg
[WARN] : TiCameraActivity: (main) [970,44982] Unable to focus.
Here's is the Java code link causing this issue : https://github.com/appcelerator/titanium_mobile/blob/949d3cda48dbf98381cbdcbad191d48cd4868df7/android/modules/media/src/java/ti/modules/titanium/media/TiCameraActivity.java
Hello [~prashant_saini], Are you still having the issue? Can you try in another device using Android api (27) and let us know how it goes. Best
Hi Rahman, unfortunately my Moto G4 Play device has not got Android N update yet & main issue is that only this device is firing callback multiple times & other Samsung device I mentioned is not firing but Samsung is not also able to auto-focus on nearby scenes as oppose to its own camera app. Its own camera app is working properly & even Ti.Media without overlay is able to auto-focus on Samsung device, but both these issues (overlay + auto-focus) are very frustrating as I cannot find any particular solution other than writing my own Camera module. One important point to note here is that I created a native Android app for taking pictures in same way as Ti.Media does without overlay, & it is working really fine. Even Facebook, WhatsApp, Instagram & any other app on Play Store is taking pictures fine. Last point to note that Ti SDK < 6.x doesn't cause this issue, so I am damn sure this is related to Ti SDK 6.x, but still I hope it should not be there in Ti SDK 7 as I know that large no. of experienced developers has faced weird issues in Ti SDK 6.x
master: https://github.com/appcelerator/titanium_mobile/pull/9637
7_0_X: https://github.com/appcelerator/titanium_mobile/pull/9706
[~prashant_saini], It looks good on our side but, we do not have a moto G4 device. Can you please check on your Moto G4 device with this SDK : https://www.dropbox.com/s/3xnxy52q66alnca/7.1.0.v20171227103832.zip?dl=0
Hi Lokesh, I have tested it on my Moto G4 device & it's working perfect now! Thanks for providing SDK to test it myself :) (y)
[~prashant_saini], Thanks.
FR Passed for both master & backport. Waiting for merge to get enabled.
Master & backport PR merged.
Verified the fix with SDK 7.1.0.v20180124153334 & 7.0.2.v20180124142857. Closing. Studio Ver: 5.0.0.201712081732 OS Ver: 10.13.2 Xcode Ver: Xcode 9.2 Appc NPM: 4.2.11 Appc CLI: 7.0.1 Daemon Ver: 1.0.1 Ti CLI Ver: 5.0.14 Alloy Ver: 1.10.10 Node Ver: 8.9.1 NPM Ver: 5.5.1 Java Ver: 1.8.0_101 Devices: ⇨ samsung SM-G955U1 — Android 7.0 ⇨ google Nexus 5 — Android 6.0.1