emulator camera does not take picture

Bug #1273890 reported by Kyle Nitzsche
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
android (Ubuntu)
Won't Fix
Undecided
You-Sheng Yang

Bug Description

Running ubuntu-emulator on trusty.

Camera does not take a picture, but it probably should :)

I am not sure which pkg needs work:

$ apt-cache policy ubuntu-emulator
ubuntu-emulator:
  Installed: 0.2+14.04.20140117-0ubuntu1
  Candidate: 0.2+14.04.20140117-0ubuntu1
  Version table:
 *** 0.2+14.04.20140117-0ubuntu1 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
        100 /var/lib/dpkg/status
$ apt-cache policy android
android:
  Installed: (none

Tags: yue
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in android (Ubuntu):
status: New → Confirmed
Rex Tsai (chihchun)
tags: added: yue
Revision history for this message
You-Sheng Yang (vicamo) wrote :

Don't know if we see the same thing. First, camera-app does not exist in i386 arch, which is weird, should file another bug for this. Second, that "take a shot" button is simply not enabled.

$ system-image-cli -i
current build number: 188
device name: generic
channel: ubuntu-touch/devel-proposed
alias: ubuntu-touch/vivid-proposed
last update: 2015-04-30 23:10:00
version version: 188
version ubuntu: 20150430.1
version device: 20150210
version custom: 20150430.1

Revision history for this message
You-Sheng Yang (vicamo) wrote :

05-04 10:45:29.157 D/libEGL (16252): loaded /system/lib/egl/libEGL_emulation.so
05-04 10:45:29.157 D/ (16252): HostConnection::get() New Host Connection established 0x9bd92b8, tid 16252
05-04 10:45:29.157 D/libEGL (16252): loaded /system/lib/egl/libGLESv1_CM_emulation.so
05-04 10:45:29.157 D/libEGL (16252): loaded /system/lib/egl/libGLESv2_emulation.so
05-04 10:45:29.167 E/EGL_emulation(16252): tid 16252: eglSwapInterval(857): error 0x3006 (EGL_BAD_CONTEXT)
05-04 10:45:29.267 D/CameraCompatibilityLayer(16252): Supported thumbnail sizes: 320x240,0x0
05-04 10:45:29.277 D/ (16252): HostConnection::get() New Host Connection established 0xb1a088d0, tid 16275
05-04 10:45:29.327 D/ (16252): HostConnection::get() New Host Connection established 0x9d5bbe8, tid 16288
05-04 10:45:29.907 W/CameraBase(16252): Camera service died!
05-04 10:45:29.907 W/CameraBase(16252): mediaserver's remote binder Camera object died
05-04 10:45:29.917 I/ServiceManager(16252): Waiting for service media.camera...
05-04 10:45:30.937 I/ServiceManager(16252): Waiting for service media.camera...
05-04 10:45:31.947 I/ServiceManager(16252): Waiting for service media.camera...
05-04 10:45:32.957 I/ServiceManager(16252): Waiting for service media.camera...
05-04 10:45:33.977 I/ServiceManager(16252): Waiting for service media.camera...
05-04 10:45:34.987 W/CameraBase(16252): CameraService not published, waiting...
05-04 10:45:40.007 I/ (16252): UASensorsAccelerometer* ua_sensors_accelerometer_new()():479
05-04 10:45:40.007 I/ (16252): uint32_t ua_sensors_accelerometer_get_min_delay(UASensorsAccelerometer*)():523
05-04 10:45:40.007 I/ (16252): UStatus ua_sensors_accelerometer_get_min_value(UASensorsAccelerometer*, float*)():536
05-04 10:45:40.007 I/ (16252): UStatus ua_sensors_accelerometer_get_max_value(UASensorsAccelerometer*, float*)():551
05-04 10:45:40.007 I/ (16252): UStatus ua_sensors_accelerometer_get_resolution(UASensorsAccelerometer*, float*)():566
05-04 10:45:40.007 I/ (16252): UStatus ua_sensors_accelerometer_enable(UASensorsAccelerometer*)():494
05-04 10:45:40.007 I/ (16252): UStatus ua_sensors_accelerometer_set_event_rate(UASensorsAccelerometer*, uint32_t)():60

Revision history for this message
Ricardo Salveti (rsalveti) wrote : Re: [Bug 1273890] Re: emulator camera does not take picture

On Mon, May 4, 2015 at 7:21 AM, Vicamo Yang <email address hidden> wrote:
> Don't know if we see the same thing. First, camera-app does not exist in
> i386 arch, which is weird, should file another bug for this. Second,
> that "take a shot" button is simply not enabled.

Apps that are click packages are probably only armhf at the moment. To
make it available on i386, the owner would need to produce a fat
package (containing both architectures), so it could be also available
for i386.

The issue with "take a shot" is probably related with the service
dying or not working properly.

Revision history for this message
You-Sheng Yang (vicamo) wrote :

Preparation:
1) install gdbserver inside the emulator

$ sudo mount -o remount,rw /
$ sudo apt-get update && sudo apt-get install --no-install-recommends gdbserver

2) create an sudo askpass script in /home/phablet/askpass

$ echo -e "#!/bin/sh\necho 0000" > /home/phablet/askpass
$ chmod 700 /home/phablet/askpass

3) get the pid and optionally the executable path of the victim process.

Usage:
./run-gdb.sh <pid> [<executable path>]

Revision history for this message
You-Sheng Yang (vicamo) wrote :

Program received signal SIGFPE, Arithmetic exception.
0xb63839b3 in android::PreviewWindow::setPreviewWindow (this=0xb89c9094, window=0xb89cb6f0, preview_fps=0) at device/generic/goldfish/camera/PreviewWindow.cpp:69
69 mPreviewAfter = 1000000 / preview_fps;
(gdb) bt
#0 0xb63839b3 in android::PreviewWindow::setPreviewWindow (this=0xb89c9094, window=0xb89cb6f0, preview_fps=0) at device/generic/goldfish/camera/PreviewWindow.cpp:69
#1 0xb637d16f in android::EmulatedCamera::setPreviewWindow (this=0xb89c9020, window=0xb89cb6f0) at device/generic/goldfish/camera/EmulatedCamera.cpp:248
#2 0xb637dd9b in android::EmulatedCamera::set_preview_window (dev=0xb89c9030, window=0xb89cb6f0) at device/generic/goldfish/camera/EmulatedCamera.cpp:696
#3 0xb7672566 in ?? () from /home/vicamo/work/canonical/ubuntu-phone/devices/phablet/x86/out/target/product/generic_x86/symbols/system/lib/libcameraservice.so
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Revision history for this message
You-Sheng Yang (vicamo) wrote :

@rsalveti, I found that camera-app is still available through apt, but it's just not packaged into ubuntu tarball.

Revision history for this message
You-Sheng Yang (vicamo) wrote :

It's libaalcamera.so (https://launchpad.net/ubuntu/+source/qtubuntu-camera) that sets illegal values:

  android_camera_set_preview_size(-1, -1)
  android_camera_set_preview_fps(0)

However, it's camera.goldfish.so that returns wrong preview fps range values. According to Android doc[1], the returned values should be scaled by 1000 but were not.

As for preview-size, it looks like a bug in AalViewfinderSettingsControl::chooseOptimalSize because it may still return invalid QSize even when there are non-optimal candidates available. Besides, the magic number in line 213 looks dangerous because sizes[1] may be illegal.

208 QSize AalViewfinderSettingsControl::chooseOptimalSize(const QList<QSize> &sizes) const
209 {
210 if (!sizes.empty()) {
211 if (m_aspectRatio == 0) {
212 // There are resolutions supported, choose one non-optimal one):
213 return sizes[1];
214 }
215
216 QList<QSize>::const_iterator it = sizes.begin();
217 while (it != sizes.end()) {
218 const float ratio = (float)(*it).width() / (float)(*it).height();
219 const float EPSILON = 10e-3;
220 if (fabs(ratio - m_aspectRatio) < EPSILON) {
221 return *it;
222 }
223 ++it;
224 }
225 }
226
227 return QSize();
228 }

[1]: http://developer.android.com/reference/android/hardware/Camera.Parameters.html#getPreviewFpsRange%28int[]%29

You-Sheng Yang (vicamo)
Changed in android (Ubuntu):
assignee: nobody → Vicamo Yang (vicamo)
Revision history for this message
You-Sheng Yang (vicamo) wrote :

1) ln -s camera.goldfish.so camera.default.so
2) scale fps values for KEY_SUPPORTED_PREVIEW_FPS_RANGE and KEY_PREVIEW_FPS_RANGE in function EmulatedCamera::Initialize() in device/generic/goldfish/camera/EmulatedCamera.cpp
3) hacky override widht and height in function android_camera_set_preview_size file ubuntu/libhybris/compat/camera/camera_compatibility_layer.cpp

Preview ok, still some unknow GL error:

V/CameraCompatibilityLayer( 9532): virtual void CameraControl::onFrameAvailable()
V/CameraCompatibilityLayer( 9532): void android_camera_update_preview_texture(CameraControl*)
W/GLConsumer( 9532): [unnamed-9532-1] bindTextureImage: clearing GL error: 0x502
V/CameraCompatibilityLayer( 9532): void android_camera_get_preview_texture_transformation(CameraControl*, float*)

Camera service still aborts at taking a shot, gdb hangs.

Revision history for this message
You-Sheng Yang (vicamo) wrote :

https://code-review.phablet.ubuntu.com/64 has disabled building camera.goldfish.jpeg.so, which is used in class NV21JpegCompressor when CAMERA_MSG_COMPRESSED_IMAGE is enabled. However, NV21JpegCompressor doesn't do error handling well so camera_service dies in an assertion.

Revision history for this message
You-Sheng Yang (vicamo) wrote :

But ubuntu/libhybris/compat/camera/camera_compatibility_layer.cpp always asks for CAMERA_MSG_COMPRESSED_IMAGE... So sad.

Revision history for this message
You-Sheng Yang (vicamo) wrote :

A short summary so far:
1) pull https://code-review.phablet.ubuntu.com/368
2) ln -s camera.goldfish.so /system/lib/hw/camera.default.so

TBD:
CAMERA_MSG_COMPRESSED_IMAGE not supported

You-Sheng Yang (vicamo)
Changed in android (Ubuntu):
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.