PhoneGap的Getpicture中功能长延时,简历上召回 [英] Phonegap getPicture function long delay, resumes on recall

查看:394
本文介绍了PhoneGap的Getpicture中功能长延时,简历上召回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我捕捉科尔多瓦/ PhoneGap的应用3.2在Android设备上的照片时,有一个问题。

I am having a problem when capturing a photo in Cordova / Phonegap 3.2 app on Android devices.

当我运行 navigator.camera.getPicture 功能,相机返回约30秒后成功,有时更长。然而,当我再次点击拍照按钮(再次运行navigator.camera.getPicture功能,无需捕捉镜头),它immedietyl返回控制权返回给应用程序,并恢复该应用程序的过程。

When I run the navigator.camera.getPicture function, the camera returns success after around 30 seconds, sometimes longer. However, when I tap the camera button again (running the navigator.camera.getPicture function again, without capturing the shot), it immedietyl return the control back to the app and resumes the process of the app.

它看起来像应用程序就卡住我拍摄后的图像(虽然我返回到应用程序后,相机完成拍摄的照片),并且导致相机的唯一的东西继续经营,并进入成功函数是通过再次运行 Getpicture中功能。

It looks that like the app it stuck after I capture an image (although I do return to the app after the camera finished capturing the photo), and the only things that cause the camera to continue its operation and get into the success function is by running the getPicture function again.

这不会发生在iOS7,我体验到它仅适用于Android(与Android版本2.3.5,4.1.2 试过)。

This doesn't happen on iOS7, and I experience it only on Android (tried with Android versions 2.3.5, 4.1.2).

我把 navigator.camera.getPicture 调用之前发出警报,它运行正常。我也把警报中签功能,它不运行。所以我认为,在捕获插件别的东西造成的延迟。

I put an alert before the navigator.camera.getPicture call and it runs ok. I also put an alert in the success function and it doesn't run. So I assume that something else in the capture plugin causes the delay.

我检查的CPU,它是低的。我禁用任何其他后台进程和调用web服务,以确保它不会导致此行为。

I've checked the CPU and it is low. I disabled any other background process and webservice calls to make sure that it doesn't cause this behavior.

我也使用一个非常小的图像尺寸,以确保图像的大尺寸不会导致此问题。所以我也消除了图像大小的因素。

I also used a very small image size to make sure that the the large size of the image doesn't cause this problem. So I also eliminated the image size factor.

该Getpicture中的功能:

The getPicture function:

 navigator.camera.getPicture(function () {   
        // On get photo success

        that._onPhotoURISuccess.apply(that, arguments);
         return false;
    }, function (err) {


    }, {
        quality: CAPTURED_PHOTO_IMAGE_QUALITY,
        destinationType: Camera.DestinationType.FILE_URI, 
        encodingType: Camera.EncodingType.JPEG,
        saveToPhotoAlbum: SETTINGS_SAVE_TO_PHOTO_ALBUM,
        allowEdit: false,
        sourceType: Camera.PictureSourceType.CAMERA, 
        targetWidth: maxSize, // <= 1024
        targetHeight: maxSize, 
        correctOrientation: true,  
    });

日志中的行为1:

在保存图像:

03-27 21:11:10.812: V/webview(11988):  singleCursorHandlerTouchEvent -getEditableSupport  FASLE 
03-27 21:11:11.281: D/CordovaActivity(11988): Paused the application!
03-27 21:11:11.281: D/CordovaWebView(11988): Handle the pause
03-27 21:11:11.296: W/PluginManager(11988): THREAD WARNING: exec() call to Camera.takePicture blocked the main thread for 33ms. Plugin should use CordovaInterface.getThreadPool().
03-27 21:11:11.382: W/PluginManager(11988): THREAD WARNING: exec() call to WebSocket.send blocked the main thread for 18ms. Plugin should use CordovaInterface.getThreadPool().
03-27 21:11:12.117: W/IInputConnectionWrapper(11988): showStatusIcon on inactive InputConnection
03-27 21:11:17.070: D/CordovaActivity(11988): Incoming Result
03-27 21:11:17.070: D/CordovaActivity(11988): Request code = 34
03-27 21:11:17.070: D/CordovaActivity(11988): We have a callback to send this result to
03-27 21:11:17.585: D/dalvikvm(11988): GC_EXTERNAL_ALLOC freed 563K, 52% free 4167K/8519K, external 5208K/5208K, paused 85ms
03-27 21:11:18.734: D/dalvikvm(11988): GC_EXPLICIT freed 19K, 52% free 4161K/8519K, external 8280K/8422K, paused 64ms
03-27 21:11:18.750: D/Whitelist(11988): Unlimited access to network resources
03-27 21:11:18.757: I/CordovaLog(11988): Found start page location: index.html
03-27 21:11:18.757: D/Config(11988): The <log> tags is deprecated. Use <preference name="loglevel" value="DEBUG"/> instead.
03-27 21:11:18.757: I/CordovaLog(11988): Changing log level to DEBUG(3)
03-27 21:11:18.757: D/CordovaActivity(11988): Resuming the App
03-27 21:11:18.757: D/CordovaActivity(11988): CB-3064: The errorUrl is null
03-27 21:11:18.789: V/webview(11988): OnSizeChanged: Enter 
03-27 21:11:18.804: D/SoftKeyboardDetect(11988): Ignore this event
03-27 21:11:19.125: V/webview(11988): OnSizeChanged: Enter 

两分钟后,我决定再次点击拍照按钮:

Two minutes after, I've decided to click the camera button again:

03-27 21:13:07.539: D/dalvikvm(11988): GC_CONCURRENT freed 2057K, 52% free 4189K/8647K, external 408K/5208K, paused 4ms+5ms
03-27 21:13:37.539: D/dalvikvm(11988): GC_CONCURRENT freed 574K, 52% free 4177K/8647K, external 408K/5208K, paused 4ms+4ms
03-27 21:13:57.515: V/webview(11988):  singleCursorHandlerTouchEvent -getEditableSupport  FASLE 
03-27 21:13:57.984: D/CordovaActivity(11988): Paused the application!
03-27 21:13:57.984: D/CordovaWebView(11988): Handle the pause
03-27 21:13:58.000: W/PluginManager(11988): THREAD WARNING: exec() call to Camera.takePicture blocked the main thread for 33ms. Plugin should use CordovaInterface.getThreadPool().
03-27 21:13:58.351: D/FileTransfer(11988): upload file:///mnt/sdcard/Android/data/com.test.test/cache/1395947477121.jpg to http://test.test.com/service.asmx/SaveImage
03-27 21:13:58.351: D/FileTransfer(11988): fileKey: file
03-27 21:13:58.351: D/FileTransfer(11988): fileName: 26346703-41cc-452c-8e86-aac088c99781.jpg
03-27 21:13:58.351: D/FileTransfer(11988): mimeType: image/jpeg
03-27 21:13:58.359: D/FileTransfer(11988): params: {}
03-27 21:13:58.359: D/FileTransfer(11988): trustEveryone: false
03-27 21:13:58.367: D/FileTransfer(11988): chunkedMode: false
03-27 21:13:58.367: D/FileTransfer(11988): headers: {"Connection":"close"}
03-27 21:13:58.367: D/FileTransfer(11988): objectId: 4
03-27 21:13:58.398: D/FileTransfer(11988): httpMethod: POST
03-27 21:13:58.398: W/PluginManager(11988): THREAD WARNING: exec() call to FileTransfer.upload blocked the main thread for 96ms. Plugin should use CordovaInterface.getThreadPool().
03-27 21:13:58.398: D/FileTransfer(11988): Content Length: 28412
03-27 21:13:58.625: D/dalvikvm(11988): GC_CONCURRENT freed 453K, 51% free 4312K/8647K, external 408K/5208K, paused 4ms+5ms
03-27 21:13:58.914: D/FileTransfer(11988): Sent 28412 of 28412
03-27 21:13:59.156: W/IInputConnectionWrapper(11988): showStatusIcon on inactive InputConnection
03-27 21:13:59.257: D/FileTransfer(11988): response code: 200
03-27 21:13:59.281: D/FileTransfer(11988): response headers: {null=[HTTP/1.1 200 OK], Access-Control-Allow-Headers=[Content-Type], Access-Control-Allow-Origin=[*], Cache-Control=[private, max-age=0], Connection=[Close], Content-Length=[0], Date=[Thu, 27 Mar 2014 19:14:50 GMT], Server=[Microsoft-IIS/8.0], X-Android-Received-Millis=[1395947639258], X-Android-Response-Source=[NETWORK 200], X-Android-Sent-Millis=[1395947638596], X-AspNet-Version=[4.0.30319], X-Powered-By=[ASP.NET]}
03-27 21:13:59.281: D/FileTransfer(11988): got response from server
03-27 21:14:00.796: D/CordovaActivity(11988): Incoming Result
03-27 21:14:00.796: D/CordovaActivity(11988): Request code = 34
03-27 21:14:00.796: D/CordovaActivity(11988): We have a callback to send this result to
03-27 21:14:00.835: D/Whitelist(11988): Unlimited access to network resources
03-27 21:14:00.843: I/CordovaLog(11988): Found start page location: index.html
03-27 21:14:00.843: D/Config(11988): The <log> tags is deprecated. Use <preference name="loglevel" value="DEBUG"/> instead.
03-27 21:14:00.976: I/CordovaLog(11988): Changing log level to DEBUG(3)
03-27 21:14:00.976: D/CordovaActivity(11988): Resuming the App
03-27 21:14:00.976: D/CordovaActivity(11988): CB-3064: The errorUrl is null
03-27 21:14:01.070: V/webview(11988): OnSizeChanged: Enter 
03-27 21:14:01.078: D/SoftKeyboardDetect(11988): Ignore this event
03-27 21:14:01.289: V/webview(11988): OnSizeChanged: Enter 
03-27 21:14:01.609: D/skia(11988): purging 197K from font cache [29 entries]

更新2:,我已经注意到了另一件事。当我把一个警报上的Getpicture中函数的错误回调,我得到Cameera取消的错误。虽然当我再次启动摄像头,成功回调被调用。

Update 2: Another thing that I've noticed. When I put an alert on the error callback for the getPicture function, I get "Cameera cancelled" error. Although when I launch the camera again, the success callback is called.

更新3:另一人谁经历了同样的问题

这是我更详细的遭遇三种行为:

The three behaviors that I encounter in more details:

行为1:


  1. 我点击相机拍摄按钮

  2. 单击以保存在相机preVIEW窗口中的照片

  3. 没有任何反应,成功也不是失败的回调被称为(等了2分钟)

  4. 我再次点击拍照键,成功回调被调用时,我点击后退按钮时,相机preVIEW窗口

  5. 我可以看到在视图中的图片

  6. 获取从我第二次pressed相机按钮故障回调(我假定它从第二个是)

2的行为:


  1. 我点击相机拍摄按钮

  2. 5-30秒成功回调被调用后

  3. CPU为100%(上传图片)

  4. 上传成功叫功能

行为3:


  1. 我点击相机拍摄按钮

  2. 我取消捕获和返回应用

  3. 通话约后失败的回调。 15秒

  4. 如果我点击第2步后立即拍照键,我立刻让失败回调

这些是主要问题。常见的这三个很长的延迟和即时回调函数的延续,当我中断与第二个摄像头Getpicture中调用(pressing相机按钮)的延迟。

Those are the main issues. The common for those three are long delays and immediate continuation of the callback function when I interrupt the delay with a second camera getPicture call (pressing the camera button).

的问题是不相符的。在极少数情况下,如预期无延迟,但大部分时间我遇到的这些问题,它的工作。这些问题可能​​发生的权利后,我启动应用程序,或一段时间后,并没有办法对其进行调试,因为延迟发生在摄像头插件本身,而不是在我的code。

The issues are not consistent. In rare situations It does work as intended without delays, but most of the time I encounter those issues. The issues can happen right after I launch the app or after some time, and there is no way to debug them because the delay happens in the camera plugin itself, not in my code.

推荐答案

我面临同样的问题上的PhoneGap 2.9.0,做很多失败的试验,以解决这个问题之后,我做了以下

I faced the same problem on phonegap 2.9.0 , after doing many failed trials to solve the problem, I did the following


  • 我创建了一个新的PhoneGap 3.5.0项目

  • I created a new phonegap 3.5.0 project

我建立从CLI Android平台

I built the android platform from CLI

我复制了www文件夹到新项目的根文件夹

I copied the www folder to the new project root folder

我添加使用CLI的所有插件需要

I added all needed plugins using CLI

我没有在顶级config.xml文件的图标和启动画面进行必要的修改,因为文件的结构不同

I did the necessary changes in top-level config.xml file for icon and splash screen because file construction is different

我跑项目,现在是确定的。

I ran the project , and it is ok now.

这篇关于PhoneGap的Getpicture中功能长延时,简历上召回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆