Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20260] Android 6: CameraView with overlay crash with message "AppName is not responding"

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-02-04T22:03:18.000+0000
Affected Version/sRelease 5.1.2, Release 5.1.1
Fix Version/sRelease 5.2.0
ComponentsAndroid
LabelsAndroid6.0, camera, module_media, qe-testadded
Reporter Ricardo Ramirez
AssigneeAshraf Abu
Created2016-01-20T23:56:19.000+0000
Updated2017-07-10T11:04:25.000+0000

Description

Issue Description

Android 6.0 camera view with overlay sometimes hangs after taking a picture. The hang resumes for about 45 seconds to a minute after which the app crashes with message "AppName is not responding". After closing the app camera issue persist. Even native camera app is not working as the result of this crash. The only way to restore both apps to working state is to restart users device. This was tested on on Nexus 9 tablet and Nexus 5X devices running Marshmallow 6.0.1

Steps to replicate:

Create a new Alloy Default Project

Open the app folder and replace the existing folders with the attached files

Run

Press "Open Camera" button; you should be presented with camera screen with an

overlay.

Press "Take" button

If the app does not crash a preview screen will appear with captured picture. If that

happens either press "Keep" button to return to main page or press "Retake" button to come back to camera screen.

Keep taking pictured until crash is reproduced (it sometimes takes a few tries to

reproduce).

Attachments

FileDateSize
cameraTest.zip2016-01-20T23:55:48.000+00007213

Comments

  1. Ricardo Ramirez 2016-02-02

    I'm sorry ! please download the full test-case here: https://drive.google.com/file/d/0BwTWo-c2a0b9OFhTZzVtR0IzMDQ/view?usp=sharing
  2. Ashraf Abu 2016-02-04

    5_2_X PR: https://github.com/appcelerator/titanium_mobile/pull/7679 Master PR: https://github.com/appcelerator/titanium_mobile/pull/7680
  3. Lokesh Choudhary 2016-02-04

    Verified the fix. There is no ANR & issue if camera not being released due to it. Closing. Environment: Appc Studio : 4.5.0.201601262138 Ti SDK : 5.2.0.v20160204140025 Ti CLI : 5.0.6 Alloy : 1.7.33 MAC Yosemite : 10.10.5 Appc NPM : 4.2.3-2 Appc CLI : 5.2.0-242 Node: 4.2.2 Nexus 6P - Android 6.0
  4. Mike Fogg 2016-08-12

  5. Ashraf Abu 2016-08-16

    [~mfogg] So you are getting multiple success? Which is caused by https://github.com/appcelerator/titanium_mobile/pull/7679/files? Could you provide the a sample app if you can and the log.
  6. Mike Fogg 2016-08-16

  7. Mike Fogg 2016-08-25

    For anyone who's running into this issue (and feels like hacking in a solution like we did), the solution we came up with was to only allow the "onAutoFocus" callback to be fired once. We modified that function to include:
       // Globally add this
       ...
       private static boolean blockAutoFocus = false;
       ...
       
    And then replace the takePicture() function with:
       static public void takePicture()
       	{
       	    try {
       	        String focusMode = camera.getParameters().getFocusMode();
       	        if (!(focusMode.equals(Parameters.FOCUS_MODE_EDOF)
       	                || focusMode.equals(Parameters.FOCUS_MODE_FIXED) || focusMode
       	                .equals(Parameters.FOCUS_MODE_INFINITY))) {
       
       	            AutoFocusCallback focusCallback = new AutoFocusCallback()
       	            {
       	                public void onAutoFocus(boolean success, Camera camera)
       	                {
                                   if(blockAutoFocus) return;
                                   blockAutoFocus = true;
       
       	                    camera.takePicture(shutterCallback, null, jpegCallback);
       
       	                    if (!success) {
       	                         Log.w(TAG, "Unable to focus.");
       	                    }
                               
                               if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
       							camera.cancelAutoFocus();
       	                    }
       	                }
       	            };
                           
                           blockAutoFocus = false;
       	            camera.autoFocus(focusCallback);
       	        } else {
       	            camera.takePicture(shutterCallback, null, jpegCallback);
       	        }
       	    } catch (Exception e) {
       	        if (camera != null) {
       	            camera.release();
       	        }
       	    }
       	}
       
    This has "solved" the problem for us in the short term. Definitely not a long term solution.
  8. Zakhar Zhuravlev 2017-07-10

    I'm also caught this error in 6.1.1.GA, but I don' t understand is it fixed or I should do something?

JSON Source