Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-25565

Android: Ti.Media.showCamera with an overlay fires success callback multiple times on some devices

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: Release 6.0.0
    • Fix Version/s: Release 7.0.2
    • Component/s: Android
    • Labels:
      None
    • Environment:

      Ti SDK 6.3.0.GA
      Android OS - 6.0.1
      Device - Moto G4 Play

    • Story Points:
      5
    • Sprint:
      2017 Sprint 24 SDK, 2017 Sprint 25 SDK, 2017 Sprint 26 SDK, 2018 Sprint 01 SDK, 2018 Sprint 02 SDK

      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

        Attachments

          Activity

            People

            • Assignee:
              gmathews Gary Mathews
              Reporter:
              prashant_saini Prashant Saini
              Reviewer:
              Yordan Banev
              Tester:
              Josh Longton
            • Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • It looks like Backbone Issue Sync is not enabled for your project.

                  Git Source Code