Titanium JIRA Archive
Appcelerator Community (AC)

[AC-6454] Memory leak using camera on iOS

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
Reporterengwei
AssigneeFazlul Haque
Created2019-12-06T12:41:21.000+0000
Updated2020-01-04T14:40:10.000+0000

Description

Repeated use of showCamera, taking a photo and selecting [Use Photo] causes app to crash when JScore framework is enabled. On SDK 7.5.1 if I set {noformat}false{noformat} then the memory gets deallocated when camera is closed. However, on SDK 8.0.2 and above disabling JScore seems to make no difference and memory usage climbs until the app crashes. Using a new alloy project I've tested using the following JS to replicate the error.
var button = Ti.UI.createButton({
	title: 'Open Camera',
});
 
button.addEventListener('click', function() {
	Ti.Media.showCamera({
		success: function (e) { },
		cancel: function (e) { },
		error: function (e) { },
		saveToPhotoGallery: false,
		mediaTypes: [ Ti.Media.MEDIA_TYPE_PHOTO ]
	});
});

$.index.add(button);
$.index.open();
I've attached screenshots of the readout in Instruments of memory allocations taking 10 photos. * 7.5.1 JSCore enabled shows memory leak * 7.5.1 JSCore disabled shows memory deallocated correctly * 8.0.2 JSCore disabled shows memory leak (no difference to enabled)

Attachments

FileDateSize
7.5.1-jscore-disabled.png2019-12-06T12:39:51.000+0000210508
7.5.1-jscore-enabled.png2019-12-06T12:39:51.000+0000209904
8.0.2-jscore-disabled.png2019-12-06T12:39:51.000+0000213590

Comments

  1. Fazlul Haque 2019-12-25

    Hello [~engwei], Thanks for reporting this issue. Would you please check this issue on latest version of SDK 8.3.0.GA? As we can see you have reproduced this issue on old SDK versions. Thanks
  2. Fazlul Haque 2019-12-29

    Hello [~engwei], I have tested your code on my end and cannot reproduce the crash. I have taken more than 10 photos randomly but the app is not crashing. *Test Environment:* SDK: 8.3.0.GA Appcelerator Command-Line Interface, version 7.1.2 iPhone 6plus (iOS 12.4.4) In this case can you please share some crash logs from your device? Thanks
  3. engwei 2020-01-04

    Hello Fazlul, Yes I have recreated this in 8.3.0.GA. The memory allocations graph is the same as previous versions. In order for me to get the phone to crash I have to take 17 photos on an iPhone 5. However there is no crash log for this. I found an iPhone 6 to test on - it started with iOS 11.1 and it had exactly the same memory issue. I updated it to 12.3.4 and tried again. This time there was some garbage collection which is an improvement, but the phone still eventually crashed. Again there is no crash log. The real issue here is that the memory allocation builds, and while it may occasionally clear using iOS 12.3.4, eventually it maxes out. When doing this in conjunction with other processes in a larger app, the chances of the app crashing are much higher. *Test Environment:* SDK: 8.3.0.GA Appcelerator Command-Line Interface, version 7.1.2 iPhone 5 (iOS 10.3.4) & iPhone 6 (iOS 11.1 & iOS 12.3.4) Thanks, Adam

JSON Source