在 iPad 上加载 > 256MB 的文件时应用程序崩溃

Posted

技术标签:

【中文标题】在 iPad 上加载 > 256MB 的文件时应用程序崩溃【英文标题】:App Crash when loading a file> 256MB on the iPad 【发布时间】:2014-07-21 14:34:24 【问题描述】:

我无法理解崩溃应用程序的原因是什么。如果有人遇到同样的问题,请告诉我。

科尔多瓦 3.5.0 插件版本: 文件传输 0.4.4 文件 1.2.0 InAppBrowse 0.5.0

iPad 2 版本 7.1.2 上传文件时出错 ios > 256MB

日志设备:

Jul 21 18:17:01 iPad-Sergej MyApp[160] <Warning>: CDVWebViewDelegate: Navigation started when state=1
Jul 21 18:17:01 iPad-Sergej MyApp[160] <Warning>: Failed to load webpage with error: CDVWebViewDelegate: Navigation started when state=1
Jul 21 18:17:01 iPad-Sergej MyApp[160] <Warning>: THREAD WARNING: ['File'] took '68.479980' ms. Plugin should use a background thread.
Jul 21 18:17:01 iPad-Sergej MyApp[160] <Error>: MyApp(160,0x3b50818c) malloc: *** mach_vm_map(size=408289280) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Jul 21 18:17:01 iPad-Sergej MyApp[160] <Error>: *** Terminating app due to uncaught exception 'NSFileHandleOperationException', reason: '*** -[NSConcreteFileHandle readDataOfLength:]: Cannot allocate memory'
*** First throw call stack:
(0x2e49af83 0x38f81ccf 0x2e49aec5 0x2ee49931 0x2ee49fe3 0xceee7 0xd1a8d 0xbcd09 0xbc9ff 0x2ee7b163 0x2e466167 0x2e465d7f 0x2e46411b 0x2e3ceebf 0x2e3ceca3 0x332c9663 0x30d1b14d 0xbffb7 0x3948eab7)
Jul 21 18:17:01 iPad-Sergej ReportCrash[161] <Notice>: ReportCrash acting against PID 160
Jul 21 18:17:02 iPad-Sergej ReportCrash[161] <Notice>: Formulating crash report for process MyApp[160]
Jul 21 18:17:02 iPad-Sergej mediaserverd[45] <Warning>: 18:17:02.266 [0x5ee000] CMSession retain count > 1!
Jul 21 18:17:02 iPad-Sergej com.apple.launchd[1] (UIKitApplication:com.MyApp[0xd3ac][160]) <Warning>: (UIKitApplication:com.MyApp[0xd3ac]) Job appears to have crashed: Abort trap: 6
Jul 21 18:17:02 iPad-Sergej backboardd[29] <Warning>: Application 'UIKitApplication:com.MyApp[0xd3ac]' exited abnormally with signal 6: Abort trap: 6
Jul 21 18:17:02 iPad-Sergej SpringBoard[33] <Warning>: [MPUSystemMediaControls] Updating supported commands for now playing application.
Jul 21 18:17:02 iPad-Sergej ReportCrash[161] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/MyApp_2014-07-21-181701_iPad-Sergej.ips using uid: 0 gid: 0, synthetic_euid: 501 egid: 0

代码函数上传:

function uploadVideo(meeting_id)   
    navigator.camera.getPicture(
        successGetFileFromCamera,
        failGetFileFromCamera,
        
            quality: 50,
            destinationType: navigator.camera.DestinationType.FILE_URI,
            sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY,
            mediaType: navigator.camera.MediaType.VIDEO
        
    );

function successGetFileFromCamera(fileURI) 
    uploadFileToServ(fileURI);


function uploadFileToServ(fileURI) 
    window.resolveLocalFileSystemURL(fileURI, successGetFileFromLocal, failGetFileFromLocal);

    function successGetFileFromLocal(fileEntry) 
        fileEntry.file(successFile, failFile);
        function successFile(fileObj) 
            var localURL = fileObj.localURL,
                fileName = fileObj.name;

            var options = new FileUploadOptions();
            options.fileKey = "my_video";
            options.fileName = fileName;
            options.mimeType="video/mp4";
            var params = ;
            params.meeting_id = meeting_id;
            options.params = params;
            options.chunkedMode = true;

            var ft = new FileTransfer();
            ft.onprogress = function(progressEvent) 
                if(progressEvent.lengthComputable) 
                    updateProgress(Number(((progressEvent.loaded / progressEvent.total) * 100).toFixed(1)));
                
            ;
            showProgress();

            ft.upload(localURL, encodeURI(window.host + "/myserver/mobile/uploadFile/t:" + window.Token), successUploadFileToServ, failUploadFileToServ, options);
        



【问题讨论】:

【参考方案1】:

我认为这是错误信息的关键部分:

无法分配内存

iPad 2 仅有 512MB 的 RAM,因此您似乎将硬件推向了极限。

【讨论】:

我猜到了。谢谢。

以上是关于在 iPad 上加载 > 256MB 的文件时应用程序崩溃的主要内容,如果未能解决你的问题,请参考以下文章

当内存超过 40MB 时,基于 Unity 的应用程序在 iPad 1 上崩溃

图像无法在 ipad/ipod 上加载

iphone - ios app maximum memory budget

打开标题地理PNG文件的软件?

一个iOS应用程序可以使用多少内存?

iOS 内存崩溃上的 Web 音频 API