Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27691] iOS: App is crashing after recording the video on device

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionNeeds more info
Resolution Date2020-01-14T00:04:13.000+0000
Affected Version/sRelease 8.3.0
Fix Version/sn/a
ComponentsiOS
LabelsACF
ReporterMotiur Rahman
AssigneeVijay Singh
Created2019-12-17T13:41:41.000+0000
Updated2020-01-22T13:43:46.000+0000

Description

Hello, Customer have an issue very strange. This app is for ios, He is working with TiSDK 8.3.0. Please have a look at the video. The error has not logs files on Studio console but it is crashing on physical device. The first error is related to crash app after recording video. The other error is related to go to background navigate between apps and return to my app. The same situation the app is crashing. Example code: Available on [Here| https://github.com/jorgehip/hipCameraCrash/tree/02-MoveCameraToAlloy] I have tested on following environment and able to reproduce the issue: SDK: 8.3.0.GA, 8.1.0.GA Appcelerator Command-Line Interface, version 7.1.2 Device: iPhone 6 plus (12.4.3) Customer is getting this issue on iPhone X (iOS 13.x) 1. I cannot reproduce the second issue (background crash issue). 2. I can reproduce the first issue but not every time. It occurs after capturing video 3/4 times. Please let us know if you need any more information. Thanks

Attachments

FileDateSize
Background Crash.mp42019-12-17T13:40:22.000+00003325534
RPReplay_Final1576362358.MP42019-12-17T13:33:14.000+000010175372
testCameraCrash 15-12-19 7-52 PM.crash2019-12-17T13:39:12.000+000077451

Comments

  1. Dominic Maricic 2019-12-18

    The background crash seems to happen only (or just a lot more often) on iPhone vs iPad. These issues are causing our users crashes every few minutes so these are critical. Did not occur in previous SDK versions.
  2. Srinivasan Pulipakkam 2019-12-18

    [~homeinspectorpro] We are investigating it, will schedule it in the next sprint in the new year once we confirm a fix is required.
  3. Vijay Singh 2019-12-20

    Create video player once and update media, every time after capturing video. See following updated alloy.js - alloy.js
       // The contents of this file will be executed before any of
       // your view controllers are ever executed, including the index.
       // You have access to all functionality on the Alloy namespace.
       //
       // This is a great place to do any initialization for your app
       // or create any global variables/functions that you'd like to
       // make available throughout your app. You can easily make things
       // accessible globally by attaching them to the Alloy.Globals
       // object. For example:
       //
       // Alloy.Globals.someGlobalFunction = function(){};
       
       // added during app creation. this will automatically login to
       // ACS for your application and then fire an event (see below)
       // when connected or errored. if you do not use ACS in your
       // application as a client, you should remove this block
       
       var fdir = "",
           inspectionDir = "";
       if (Ti.Filesystem.isExternalStoragePresent()) {
           Alloy.Globals.fdir = Ti.Filesystem.externalStorageDirectory;
           Alloy.Globals.inspectionDir = Ti.Filesystem.externalStorageDirectory;
       } else {
           if (OS_ANDROID) {
               Alloy.Globals.fdir = Ti.Filesystem.applicationDataDirectory;
               Alloy.Globals.inspectionDir = Ti.Filesystem.applicationDataDirectory;
           } else {
               Alloy.Globals.fdir = Ti.Filesystem.applicationDataDirectory + "../Library/Caches/";
               Alloy.Globals.fdir.setRemoteBackup = false;
               Alloy.Globals.inspectionDir = Ti.Filesystem.applicationDataDirectory;
           }
       }
       
       var root = {};
       root.template = [];
       root.pictures = [];
       root.videos = [];
       Alloy.Globals.root = root;
       
       
       (function() {
       
       })();
       Alloy.Globals.counterVideos = 1;
       var videoPlayer = Ti.Media.createVideoPlayer({
           scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FIT,
           autoplay : true
       });
       Alloy.Globals.saveVideo = function(callback) {
           require("/permissions").checkCameraPermission(function() {
               //var nextVideoId = Math.floor(Math.random() * 100);
               var nextVideoId = Alloy.Globals.counterVideos;
       
               Ti.Media.showCamera({
                   success : function(e) {
                       Alloy.Globals.counterVideos = Alloy.Globals.counterVideos+1;
                       //callback(null, e);
                       Ti.API.info("e.media.length:" + e.media.length);
                       var tempFile = Ti.Filesystem.getFile(Alloy.Globals.inspectionDir, nextVideoId + '.mp4');
                       tempFile.write(e.media);
                       videoPlayer.setMedia(e.media);
       
                       function setBackgroundImage(thumbResponse, error) {
                           console.log('--> setBackgroundImage() - thumbResponse: ', thumbResponse, ', error: ', error);
                           if (error) {
                               alert('could not capture video');
                               return;
                           }
       
                           var thumbanilImage = thumbResponse.image;
                           var thumbFile = Ti.Filesystem.getFile(Alloy.Globals.inspectionDir, nextVideoId + '.jpg');
                           thumbFile.write(thumbanilImage);
       
                           var imageView = Ti.UI.createView({
                               width : "352",
                               height : "288",
                               backgroundImage : thumbFile.nativePath
                           });
       
                           var lbl = Titanium.UI.createLabel({
                               text : " Video ",
                               backgroundColor : "#fff",
                               font : {
                                   fontSize : 20
                               },
                               color : "black",
                               left : 5,
                               top : 5
                           });
                           imageView.add(lbl);
                           var eventCalled = 0;
                           imageView.addEventListener('postlayout', function(e) {
                               if (eventCalled == 0) {
                                   eventCalled++;
                                   Ti.API.info('Inside postlayout event');
                                   Ti.API.info('size : ' + imageView.size.width + ' x ' + imageView.size.height);
                                   var blob = imageView.toImage();
       
                                   Ti.API.info("JSON.stringify(blob):" + JSON.stringify(blob));
                                   Ti.API.info('blob.length : ' + blob.length);
                                   Ti.API.info('blob.apiName : ' + blob.apiName);
                                   var thumbFileNew = Ti.Filesystem.getFile(Alloy.Globals.inspectionDir, nextVideoId + '.jpg');
                                   thumbFileNew.write(blob);
                                   var videoFile = {
                                       imageFileName : thumbFileNew.getName(),
                                       thumb : thumbFileNew.getName(),
                                       video : tempFile.getName(),
                                       isVideo : true
                                   };
                                   
                                   Alloy.Globals.root.pictures.push(videoFile); 
       
                                   callback(videoFile);
                                   window.close();
                                   window.remove(imageView);
                                   imageView = null;
                                   window = null;
                                   blob = null;
                                   thumbanilImage = null;
                                   thumbFile = null;
                                   thumbFileNew = null;
                                   blob = null;
                                   videoFile = null;
                               }
                           });
                           var window = Titanium.UI.createWindow();
                           window.add(imageView);
                           window.open();
       
                       }
       
       
                       videoPlayer.requestThumbnailImagesAtTimes([0], Titanium.Media.VIDEO_TIME_OPTION_NEAREST_KEYFRAME, setBackgroundImage);
       
                   },
                   cancel : function(e) {
                       callback(e, null);
                   },
                   error : function(e) {
                       callback(e, null);
                   },
                   mediaTypes : [Titanium.Media.MEDIA_TYPE_VIDEO],
                   videoMaximumDuration : 30000,
                   videoQuality : Titanium.Media.QUALITY_LOW
       
               });
           });
       };
       
  4. Srinivasan Pulipakkam 2020-01-14

    If the response from [~vijaysingh] doesn't resolve the issue , please re-open with additional information
  5. Samir Mohammed 2020-01-22

    Closing ticket, Please reopen if needed.

JSON Source