Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9362] Android: first use of camera crashes on SDK 2.0.1+ (works on 1.8.2-)

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionCannot Reproduce
Resolution Date2012-06-19T18:10:04.000+0000
Affected Version/sRelease 2.0.1
Fix Version/sn/a
ComponentsAndroid
Labelscommunity, core, regression
ReporterParand Darugar
AssigneeOpie Cyrus
Created2012-06-01T12:39:32.000+0000
Updated2017-03-30T21:28:17.000+0000

Description

There is a consistent crash when using the camera on Android: - Install your application (eg. kitchensink) by downloading the .apk (NOT by deploying to the Android device via Eclipse). - The first time you use the camera, after you've taken the picture, as soon as you hit "Save", the app will crash before your camera success callback is called Once you restart the app the camera save function works fine - ie. the crash only occurs on first use of camera. To isolate this I created the simplest possible app that only fires up the camera and takes a picture. The camera code is taken directly from KitchenSink. You can also replicate the bug using KitchenSink. The app works fine when built using the 1.7.2 and 1.8.2 SDK, and crashes on first use when built with the 2.0.1 or 2.0.2 SDK. So it seems somewhere between 1.8.2 and 2.0.1 the camera code for Android broke.

Comments

  1. Marcel Klapschus 2012-06-08

    can confirm this on SDK 2.0.2 too. Tested on Samsung Galaxy S -> same behaviour.
  2. Ping Wang 2012-06-11

    From the behavior described in the ticket, it's very similar to TIMOB-8514.
  3. Opie Cyrus 2012-06-15

    Unable to reproduce the failure against master. Ran the following app deployed via tistudio and also manually copied apk to device then installed via file manager which should be the same process as downloading the apk. Beyond the expected restart of app upon first launch, the behavior was correct through preview, capture to saving. If error still persists and ticket is re-opened, please attached exact test case used to reproduce the error.
       var win = Titanium.UI.createWindow({backgroundColor: 'red'});
       Titanium.Media.showCamera({
       
       	success:function(event)
       	{
       		var cropRect = event.cropRect;
       		var image = event.media;
       
       		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()
       	{
       	},
       	error:function(error)
       	{
       		// create alert
       		var a = Titanium.UI.createAlertDialog({title:'Camera'});
       
       		// set message
       		if (error.code == Titanium.Media.NO_CAMERA)
       		{
       			a.setMessage('Please run this test on device');
       		}
       		else
       		{
       			a.setMessage('Unexpected error: ' + error.code);
       		}
       
       		// show alert
       		a.show();
       	},
       	saveToPhotoGallery:true,
       	allowEditing:true,
       	mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO]
       });
       win.open();
       
  4. Opie Cyrus 2012-06-15

    Should be noted that I tried the same test inside a heavy weight window with the same results.
  5. Parand Darugar 2012-06-16

    This is definitely reproducible, even with kitchen sink. There's even a comment on the question I asked in Q&A with someone else reporting the same issue: http://developer.appcelerator.com/question/137640/android-first-time-use-of-camera-crashes-2nd-time-onwards-works Here's the exact code the produces the problem: --------------- var window = Titanium.UI.currentWindow; function camera_receipt() { Titanium.API.info('############ showing camera'); Titanium.Media.showCamera({ success: function(event) { Ti.API.info('--- receipt.js: Camera SUCCESS'); var cropRect = event.cropRect; var receipt_image = event.media; }, cancel: function() { Ti.API.info('--- receipt.js: Camera CANCEL'); window.close(); }, error:function(error) { Ti.API.info('--- receipt.js: Camera ERROR'); var a = Titanium.UI.createAlertDialog({title:'Camera'}); if (error.code == Titanium.Media.NO_CAMERA) { a.setMessage('Device does not have camera capabilities'); } else { a.setMessage('Unexpected error: ' + error.code); } a.show(); window.close(); }, allowImageEditing:false, saveToPhotoGallery: Ti.Platform.osname == "iphone"? false: true, mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO] }); } camera_receipt(); ---------------
  6. Stephen Tramer 2012-06-18

    We need additional information: * Was this test performed against master (currently master@63645c4) ? * We need a list of tested devices. This could be either a 4.x or a device-specific issue. When this information is provided please reopen this ticket.
  7. Marcel Klapschus 2012-06-18

    I had this crash on a Samsung Galaxy S Plus (I-9001) with Android 2.3
  8. Parand Darugar 2012-06-18

    Crashes on 4 separate phones. Mine is a Galaxy Vibrant running 2.2, the other three I don't have handy but I can find if needed. It's crashed on every phone we've tried it on regardless of android version.
  9. Parand Darugar 2012-06-18

    This was tested on 2.0.1 and 2.0.2 where it crashes, and on 1.7.2 and 1.8.2 where it does not crash.
  10. Neeraj Gupta 2012-06-18

    @Parand - Can you please test it quickly with 2.1.0 (master) build? We have not been able to reproduce this issue so it would help us narrow down the issue.
  11. Parand Darugar 2012-06-18

    @Neeraj, happy to. I looked briefly at how to build appcelerator from source but didn't get far, is there a 2.1.0 build available somewhere I can try? This and one more issue are holding up releasing my app so I'm very motivated to help ;-)
  12. Neeraj Gupta 2012-06-19

    @Parand - http://builds.appcelerator.com.s3.amazonaws.com/index.html. Use "master" from the drop down.
  13. Parand Darugar 2012-06-19

    Tried building with SDK version 2.1.0v20120619132308 and I'm happy to report the issue is no longer there - using the camera for the first time does not cause a crash. Looks like whatever the issue was has been resolved in the lastest code base. Thank you guys.
  14. Neeraj Gupta 2012-06-19

    Reported has confirmed that this issue cannot be reproduced with the latest 2.1.0 build.
  15. Lee Morris 2017-03-30

    Closing ticket as I am unable to reproduce the issue using the following environment; Pixel (7.1) MacOS 10.11.6 (15G31) Studio 4.8.1.201612050850 Ti SDK 6.0.3 GA Appc NPM 4.2.8 Appc CLI 6.1.0 Ti CLI 5.0.11 Alloy 1.9.5 Arrow 1.10.1 Xcode 8.2 (8C38) Node v4.6.0 Java 1.7.0_80

JSON Source