[TIMOB-24389] iOS: Appcelerator Titanium App Crashes after some usage time
GitHub Issue | n/a |
Type | Bug |
Priority | None |
Status | Closed |
Resolution | Not Our Bug |
Resolution Date | 2017-07-11T07:57:11.000+0000 |
Affected Version/s | Release 6.0.1 |
Fix Version/s | Release 6.0.3 |
Components | iOS |
Labels | n/a |
Reporter | Neeraj Mishra |
Assignee | Vijay Singh |
Created | 2017-02-09T05:03:20.000+0000 |
Updated | 2017-08-07T18:01:12.000+0000 |
Description
Problem Description:
Titanium App Crashes after some Camera usage time.
Steps to Reproduce:
- Use the attached app.js code in a classic app. tiapp.xml file is also attached.
- Touch "open camera"
- Take picture
- Touch "Use Photo"
- Repeat steps 30-35 times.
Actual Result
App crashes during the process of taking picture in above scenario.
Expected Results:
App should work usual and should not crash.
Some more details and question from customer:
Remarks:
- iOS 10.2 camera permission is set
- Happens once/twice a day.
- Not directly/always reproducible
- App closes and iOS springboard gets visible
- Fabric.io is configured for crash reporting, but no crashes are captured (seems that Fabric doesn't get the chance to capture the crash).
We couldn't get any logs of the issue due the fact production devices are not within reach.
Question: is it possible that iOS kills the app because the camera screen (iOS app) takes a lot of memory/resources?
Attachments
I cannot see a crash-log, please attach. And did this also happen n earlier versions of the SDK (5.5.x)? If we have those infos, we can patch it for 6.0.2, thx!
[~hansknoechel] : Attaching the crash log for the app I tested at my end. Also with couple of test with SDK 5.5.0 and CLI 5.5.0, i did not see any crash. I can't confirm it yet. I will check once more and post it here.
crash log.
Here is the related crash-log: {quote} TCC, This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data. {quote} So either they didn't add the
NSCameraUsageDescription
key to the plist like noted in both the 5.5.0 and 6.0.0 release, or the crash comes from an invalid test-case to reproduce the issue.Made the ticket private.
I was able to reproduce the issue. Here is the environment, and a description of what I did: NPM Version: 2.15.9 Node Version: 4.5.0 Mac OS: 10.12.1 Appc CLI: 6.1.0 Appc CLI NPM: 4.2.8 Titanium SDK version: 6.0.1. GA Appcelerator Studio, build: 4.8.1.201612050850 iOS Device: 10 I tested this by following the steps the reporter outlined. I clicked the button to take a picture, and the then clicked on the "Use Picture". After 35 times, the app crashed. The crashed occurred when clicking to take the picture.
[~hansknoechel] : Do you have any updates on it?
[~hansknoechel] : I have shared it over email.
I've fixed it. Tested with both main- and kroll-thread monitoring it with Instruments. The heap grows per image and is autoreleased a few seconds afterwards. I implemented an autorelease-pool around the sensitive core-image operation (the internal rotation of the image), retained the resulting image by the current context and released it after creating a blob from it. I also attached [two Instruments-traces](https://www.dropbox.com/s/h0jgv9pqr1hpqtt/OpenPhotoGallery-Traces.zip?dl=1) that show the leak (before) and the fix using the PR (afterwards), as well as some insights on the memory analysis. We could still include it in the 6.0.2.GA if the fix get's an approval before next Monday. [~emerriman] could your team test the issue today already? I know Vijay is on Holiday until Monday, so we could the fix in place before. Thx! PR: https://github.com/appcelerator/titanium_mobile/pull/8849 Test-Case (based on the one from the customer, modified to validate the fix by setting the image-view image as well):
Using this environment: NPM Version: 2.15.9 Node Version: 4.5.0 Mac OS: 10.12.3 Appc CLI: 6.1.0 Appc CLI NPM: 4.2.8 Appcelerator Studio, build: 4.8.1.201612050850 iOS Device: 10.0 I did FR, and found that the app still crashes after 30 times when cycling between taking a picture and using picture. I tried this on main thread and also with jscore and in both cases the app crashes. I had Instruments running, and attached is the log "InstrumentsLog24389.trace.zip"
[~hansknoechel] I verified the changes on main thread. In my case after 5-6 image memory get released and if I continue app get crashed after 16 more images . Instrument trace are https://www.dropbox.com/s/1quujgplkvjqs2g/Instruments_crash.trace.zip?dl=0 . Problem looks at core level. We have to dig out more for solution.
I can reproduce it again. The
adjustRotation
method is still causing it. I don't think it's on the core-level, because Kroll-objects are unaffected. The results from the CoreGraphics operations are causing it, as it can be seen in the Instruments details (see attached images). I tried releases the CGContext and CGImage manually, but a) this is done byUIGraphicsEndImageContext
and b) calling it manually will crash the app. The issue is caused by the reference image (imgRef}
) that doesn't get released, the actual result of the CG-operation is properly released. We need to check other solutions this week and I also want to create a native sample app to check the behavior there. Will ping back soon, thx!I have verified it by replacing line -
This is also causing the same problem. So the problem is not with adjustRotation method. Checking behavior with native sample app is good idea.
On basis of few points (mentioned below) 1.In case of KROLL THREAD due to below code snippet in KrollContext.m the heap is getting released early - if (loopCount == GC_LOOP_COUNT){ [self forceGarbageCollectNow]; } So heap do not grow much in this case. 2. In case of main thread, after reaching near crash point(e.g if crash is happening with 30 image, use 29 image), wait for approx. 10 mints (sometimes early). Heap will get release. 3. So similar to point 1 forceGarbageCollectNow called in mentioned PR, which will release heap early. PR :https://github.com/appcelerator/titanium_mobile/pull/8853
I continue to get a crash after 22-26 picture takings when both main thread and jscore framework are true. If either are false, I do not encounter the crash. Also, as you say [~vijaysingh], if I wait just before the crash then the heap will be released and I can continue taking pictures after some time. The question is: Is this the intended and now expected behavior?
Please note that this fix is only for this ticket (the customers has main-thread, no JSCore enabled). For JSCore, we track TIMOB-24206.
FR passed, using: MacOS 10.12 (16A323) Studio 4.8.1.201612050850 Ti SDK 6.1.0 Appc NPM 4.2.8 Appc CLI 6.1.0 Alloy 1.9.5 Xcode 8.2.1 (8C1002) Tested using the provided sample code by taking over 50 pictures in the app, built with main-thread enabled and disabled. No crash was encountered unless JScore was also enabled. This will be addressed by another ticket/PR. Verified in SDK 6.1.0.v20170307133328
[~hansknoechel], [~vijaysingh]: Can we get a backport to 6_0_X or have the fixVersion updated accordingly?
Backported PR : https://github.com/appcelerator/titanium_mobile/pull/8864 [~hansknoechel] Please review.
Verified in SDKs 6.0.3.v20170309031327 and 6.1.0.v20170307133328
Sorry but this is the only way of asking; The issue has to to with NSCameraUsageDescription amongst others in a multi-language app. However I cannot file an issue in Jira... How can I add an issue to Jira TIMOB? I can only create an issue into the Aptana Studio part...
Resolving this ticket as per comment by [~nmishra].
Closing ticket with reference to the previous comments.