Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24323] iOS : When 'allowEditing' is 'false', crash occurs in Titanium.Media.showCamera

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionDuplicate
Resolution Date2017-01-18T10:33:41.000+0000
Affected Version/sRelease 6.1.0
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterDongwoo Gim
AssigneeHans Knöchel
Created2017-01-18T06:26:28.000+0000
Updated2017-03-23T22:46:57.000+0000

Description

false 6.1.0.v20161217060946 is ok, but 6.1.0.v20161219221123 is crash. Maybe this code has problem. https://github.com/appcelerator/titanium_mobile/commit/d687cd2b3d314de8807f96f3d002c55d45bee7e1 When 'run-on-main-thread' is true, works normal. Test code here.
var win = Ti.UI.createWindow({
  title: 'test',
  backgroundColor: '#fff'
});


// This example is only able to capture video on the iOS platform.
// To capture video on the Android platform, see the Android Capture Video Example below.
function showCamera() {
  Titanium.Media.showCamera({
  	success:function(event) {
      console.log(event.media.width, event.media.height);

  		// called when media returned from the camera
  		Ti.API.debug('Our type was: '+event.mediaType);
  		if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {
  			var imageView = Ti.UI.createImageView({
  				width: win.width,
  				height: win.height,
  				image: event.media
  			});
  			win.add(imageView);
  		} else {
  			alert("got the wrong type back ="+event.mediaType);
  		}
  	},
  	cancel:function() {
  		// called when user cancels taking a picture
  	},
  	error:function(error) {
  		// called when there's an error
  		var a = Titanium.UI.createAlertDialog({title:'Camera'});
  		if (error.code == Titanium.Media.NO_CAMERA) {
  			a.setMessage('Please run this test on device');
  		} else {
  			a.setMessage('Unexpected error: ' + error.code);
  		}
  		a.show();
  	},
  	// saveToPhotoGallery:true,
      // allowEditing and mediaTypes are iOS-only settings
  	allowEditing: false,
  	mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO]
  });
}

setTimeout(function() {
  Titanium.Media.requestCameraPermissions(function (e) {
    if (e.success) {
      showCamera();
    } else {
      console.error(e);
    }
  });
}, 2000);

win.open();

Comments

  1. Hans Knöchel 2017-01-18

    Good catch, we will investigate it asap! It's [this line](https://github.com/appcelerator/titanium_mobile/commit/d687cd2b3d314de8807f96f3d002c55d45bee7e1#diff-da4efcba6ff32fa7582070baafb81526R789) causing the issue when running on kroll-thread, making it a duplicate of TIMOB-24270. I will add this test-case to that ticket and go from there. Thx!
  2. Lee Morris 2017-03-23

    Closing ticket as Duplicate with reference to the above comments.

JSON Source