Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23473] Android: Getting an error in the logs when using the Camera (Regression)

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2017-03-07T14:28:27.000+0000
Affected Version/sRelease 5.2.2
Fix Version/sRelease 6.1.0
ComponentsAndroid
Labelsn/a
ReporterAshraf Abu
AssigneeGary Mathews
Created2016-06-03T02:47:22.000+0000
Updated2017-03-07T22:26:07.000+0000

Description

Resolving TIMOB-23230 brought attention to this error. Logs as follows:-
ERROR] :  TiBlob: (main) [449,5770] null
[ERROR] :  TiBlob: java.io.IOException
[ERROR] :  TiBlob: 	at java.io.InputStream.reset(InputStream.java:208)
[ERROR] :  TiBlob: 	at org.appcelerator.titanium.TiBlob.guessAdditionalContentTypeFromStream(TiBlob.java:239)
[ERROR] :  TiBlob: 	at org.appcelerator.titanium.TiBlob.guessContentTypeFromStream(TiBlob.java:214)
[ERROR] :  TiBlob: 	at org.appcelerator.titanium.TiBlob.loadBitmapInfo(TiBlob.java:270)
[ERROR] :  TiBlob: 	at org.appcelerator.titanium.TiBlob.blobFromFile(TiBlob.java:140)
[ERROR] :  TiBlob: 	at org.appcelerator.titanium.TiBlob.blobFromFile(TiBlob.java:113)
[ERROR] :  TiBlob: 	at ti.modules.titanium.media.TiCameraActivity$3.onPictureTaken(TiCameraActivity.java:563)
[ERROR] :  TiBlob: 	at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1092)
[ERROR] :  TiBlob: 	at android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] :  TiBlob: 	at android.os.Looper.loop(Looper.java:148)
[ERROR] :  TiBlob: 	at android.app.ActivityThread.main(ActivityThread.java:5417)
[ERROR] :  TiBlob: 	at java.lang.reflect.Method.invoke(Native Method)
[ERROR] :  TiBlob: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
[ERROR] :  TiBlob: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
This was tested on an Android 6.0, Nexus 6. Test code as follows:-

var window = Ti.UI.createWindow();
var overlay = Ti.UI.createView();
var button = Titanium.UI.createButton({
    color : '#fff',
    bottom : "10dp",
    width : "130dp",
    height : "50dp",
    font : {
        fontSize : "14dp",
        fontWeight : 'bold',
        fontFamily : 'Helvetica Neue'
    },
    title : 'Take Picture'
});
 
button.addEventListener('click', function() {
    Ti.Media.takePicture();
});
 
window.add(overlay);
overlay.add(button);
window.addEventListener('open', function(e){
   var cameraPermission = "android.permission.CAMERA";
   var storagePermission = "android.permission.READ_EXTERNAL_STORAGE";
   var hasCameraPerm = Ti.Android.hasPermission(cameraPermission);
   var hasStoragePerm = Ti.Android.hasPermission(storagePermission);
   var permissionsToRequest = [];
   if (!hasCameraPerm) {
    permissionsToRequest.push(cameraPermission);
   }
   if (!hasStoragePerm) {
    permissionsToRequest.push(storagePermission);
   }
   if (permissionsToRequest.length > 0) {
    Ti.Android.requestPermissions(permissionsToRequest, function(e) {
        if (e.success) {
            showCamera();
        } else {
            Ti.API.info("ERROR: " + e.error);
        }
    });
   } else {
        showCamera();
   }
});
Ti.Media.addEventListener('cameraready', function(e){
    Ti.Media.takePicture();
});
var container = Ti.UI.createView({
        top:'10%',
        height:'80%'
    });
 
var img = Ti.UI.createImageView({
    });
 
container.add(img);
window.add(container);
window.open();
 
function showCamera() {
    Ti.Media.showCamera({
       success : function(e) {
                    Ti.API.info('GOT SUCCESS CALLBACK');
                    var imgWid = e.media.width;
                    var imgHeight = e.media.height;
                    var mSize = container.size;
                    var mW = mSize.width;
                    var mH = mSize.height;
 
                    var wS = imgWid/mW;
                    var hS = imgHeight/mH;
                    var tS = (wS < hS) ? wS : hS;
 
                    var dstWid = imgWid/tS;
                    var dstHeight = imgHeight/ tS;
 
                    Ti.API.info(imgWid+' '+imgHeight+' '+mW+' '+mH+' '+wS+' '+hS+' '+tS+' '+dstWid+' '+dstHeight);
                    var resize = e.media.imageAsResized(dstWid,dstHeight);
                    img.image = resize;
       },
       overlay : overlay,
       mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO],
       saveToPhotoGallery : true
    });
}

Comments

  1. Andy Waldman 2017-02-17

    I cant seem to reproduce the error specified above running in the same environment
  2. Frankie Merzadyan 2017-02-21

    Test case does not reproduce errors in logs like reported when run using Studio/Appc CLI. Ran on Samsung S6 Galaxy using latest SDK. App does not run when run natively in IntelliJ, TiActivity is not written into AndroidManifest but that is because it is not built and packaged like in running titanium apps using AppC CLI.
  3. Hans Knöchel 2017-03-06

    [~gmathews] Hey man! Is this fixed with our most recent Android camera fixes?
  4. Gary Mathews 2017-03-07

    I also cannot reproduce the error, there have been changes since this was reported which may have fixed this issue. Closing as invalid.
  5. Samir Mohammed 2017-03-07

    Closing ticket as it is marked as invalid.

JSON Source