Nexus的10 camera.release挂起30秒 [英] Nexus 10 camera.release hangs for 30 seconds

查看:359
本文介绍了Nexus的10 camera.release挂起30秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一组正在为Android的一个实时视频处理应用程序开发人员。最近,一个客户报告我们的应用程序冻结出现这种情况只有在Nexus 10设备。我们买了自己的设备和测试:

We are a group of developers that are working on a realtime video processing app for android. Recently, a client reported a freeze in our app that happens only on Nexus 10 device. We bought the device ourselves and tested:

  • 在设备来到了Android 4.2 preinstalled - 没有挂起,也没有冻结在我们的应用程序
  • 的Andr​​oid升级到4.3之后,我们的应用程序冻结在关闭相机(见下文说明)
  • 将升级到4.4,我们的应用程序保持冻结
  • 闪烁了最新的Andr​​oid 5.0的Nexus 10工厂的形象,我们的应用程序仍然保持冻结
  • (编辑) - 这个问题已经解决了升级的Nexus 10至Android 5.1

有关冻结的更多信息:

我们的应用程序打开相机活动的onResume方法,安装preVIEW回调,设置preVIEW大小来最好的为我们的加工需求(对关系10,这是1920×1080),要么开始preVIEW(如果从睡​​眠状态恢复)或代表相同的,以SurfaceView回调surfaceCreated方法。在方法的onPause我们的应用程序中删除preVIEW回调,停止摄像机preVIEW并释放摄像头。然而,我们的调查显示, camera.release 方法,有时需要30秒才能完成。在这种30秒我们的应用程序是冷冻,因为我们用来控制从UI线程相机。后来我们搬到了摄像机控制,以单独的事件处理程序的线程现在 camera.release 挂起线程。虽然现在这是对用户不可见(UI不会被阻​​止),用户可以不使用相机的任何应用程序,直到我们的后台线程成功释放摄像头(后 camera.release 叫)。

Our app opens the camera in onResume method of activity, installs the preview callback, sets the preview size to best possible for our processing needs (on nexus 10 this is 1920x1080) and either starts the preview (if resuming from sleep) or delegates the same to surfaceCreated method of SurfaceView callback. In onPause method our app removes the preview callback, stops the camera preview and releases the camera. However, our investigation has shown that camera.release method sometimes takes 30 seconds to complete. In that 30 seconds our app was frozen because we used to control the camera from UI thread. Later we moved the camera control to separate event handler thread and now camera.release hangs that thread. Although this is invisible now to the user (UI is not blocked), the user cannot use the camera from any app until our background thread succeeds in releasing the camera (i.e. 30 seconds after camera.release was called).

在杭期间,我们观察到相机的服务如下日志输出:

During the hang period we observed the following log outputs from camera service:

10-21 16:08:54.193: E/Camera2-Device(122): waitUntilDrained: Waited 10050000 us, 2 requests still in flight
10-21 16:08:54.193: E/Camera2Client(122): stopPreviewL: Camera 0: Waiting to stop streaming failed: Connection timed out (-110)
10-21 16:09:04.293: E/Camera2-Device(122): waitUntilDrained: Waited 10050000 us, 2 requests still in flight
10-21 16:09:04.293: E/Camera2Client(122): stopPreviewL: Camera 0: Waiting to stop streaming failed: Connection timed out (-110)
10-21 16:09:14.453: E/Camera2-Device(122): waitUntilDrained: Waited 10050000 us, 2 requests still in flight
10-21 16:09:14.453: E/Camera2-StreamingProcessor(122): deletePreviewStream: Error waiting for preview to drain: Connection timed out (-110)
10-21 16:09:24.573: E/Camera2-Device(122): waitUntilDrained: Waited 10050000 us, 2 requests still in flight
10-21 16:09:24.573: E/Camera2-CallbackProcessor(122): deleteStream: Error waiting for HAL to drain: Connection timed out (-110)
10-21 16:09:24.578: E/libexynosv4l2(122): failed to ioctl: VIDIOC_REQBUFS (-1 - Invalid argument)
10-21 16:09:24.578: E/ExynosCameraHAL2(122): cam_int_reqbufs: VIDIOC_REQBUFS (fd:35) failed (-1)
10-21 16:09:24.843: E/Camera2-CallbackProcessor(122): deleteStream: Camera 0: Device does not exist
10-21 16:09:24.853: E/Camera2-StreamingProcessor(122): deletePreviewStream: Camera 0: Device does not exist

您可以看到,触发这种行为这里 - 相机的活动需要重新启动迅速几次,以增加进入这种状态的机会。我们注意到,它更经常发生在我们的应用程序比示例应用程序。我们的应用程序确实有些沉重帧处理,还采用GPU进行影像处理,此外相机还采用了加速计和方向传感器 - 所有这些都没有包含在示例应用程序

You can see the minimum example that triggers this behaviour here - camera activity needs to be restarted quickly few times to increase the chance of entering into this state. We noticed that it occurs much more often in our app than in example app. Our app does some heavy frame processing, also uses GPU for image processing and besides camera also uses accelerometer and orientation sensor - all those are not included in example app.

我们也看到对同样的问题,一对夫妇没有答案的StackOverflow问题(<一href="https://stackoverflow.com/questions/21324390/camera-release-takes-30-seconds-to-release-the-camera-in-nexus-10-is-there-an">question 1 问题2 )。能否请您解释一下codePATH会导致提到的日志输出,以及如何避免进入这种状态?

We have also seen a couple unanswered StackOverflow questions about the same problem (question 1 and question 2). Could you please explain what codepath will lead to mentioned log outputs and how to avoid entering that state?

我们没有遇到提到的相机冻结任何其他设备至今。

We did not encounter the mentioned camera freeze on any other device so far.

推荐答案

不幸的是,你正在运行到在Nexus 10相机非确定性的bug HAL。

Unfortunately, you're running into a non-deterministic bug in the Nexus 10 camera HAL.

虽然我们一直在努力,反复追查这个问题,我们显然还没有找到问题的所有实例这里。

While we've tried to track down this issue repeatedly, we obviously haven't found all instances of problems here.

在解决办法方面,你可以尝试简单地关闭了摄像装置,无需拆卸回调和停止preVIEW;它不应该是必要做分阶段关机

In terms of workarounds, you could try simply closing the camera device, without removing the callback and stopping preview; it shouldn't be necessary to do the shutdown in stages.

这篇关于Nexus的10 camera.release挂起30秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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