NativeCamera still does not work on LG G2 (Bug #3995)


Added by Martin Tosas over 10 years ago. Updated over 9 years ago.


Status:New Start date:2014-11-04
Priority:Normal Due date:
Assignee:Alexander Smorkalov % Done:

0%

Category:android
Target version:-
Affected version:2.4.9 (latest release) Operating System:Android
Difficulty: HW Platform:ARM
Pull request:

Description

This is the same device as bug#3353. I'm not sure if it's better to update the old bug so I have filed a new one.

I was looking forward to try the NativeCamera in my LG G2 but still crashes the same way as in bug#3353.

I updated my OS to Android 4.4.2 (in bug#3353 it was Android 4.2.2) and I tried to run Tutorial 1 sample both with OpenCV-2.4.9-android-sdk and OpenCV-2.4.10-android-sdk. In both cases JavaCamera works but when I switch to NativeCamera it crashes. Logcat shows:

A/libc(9115): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 9115 (mples.tutorial1)

I attach the logcat:


log_LG_G2_OS_4.4.2_OpenCV-2.4.10-android-sdk.txt (44.9 kB) Martin Tosas, 2014-11-04 03:09 pm


Related issues

related to Bug #3353: NativeCamera does not work on LG G2 Done 2013-10-30

History

Updated by Leon Schneiderman over 10 years ago

Hi,

I shared the following findings with OpenCV folks about 2 months ago. The gist of the matter is that pretty much any Qualcomm's Snapdragon based device (which is a mammoth chunk of phones at the moment) is going to experience this type of crash. More details:

Crash happened when executing the following snippet from OpenCV's androidcamera module in camera_wrapper.cpp

  1. elif defined(ANDROID_r4_4_0)
    void* buffer_queue_obj = operator new(sizeof(BufferQueue) + MAGIC_TAIL);
    handler->queue = new(buffer_queue_obj) BufferQueue();
    void* consumer_listener_obj = operator new(sizeof(ConsumerListenerStub) + MAGIC_TAIL);
    handler->listener = new(consumer_listener_obj) ConsumerListenerStub();
    handler->queue->consumerConnect(handler->listener, true);

While an attempt is made to call consumerConnect, instead releaseBuffer is called with bogus things on the stack which causes releaseBuffer to crash.

It is caused by mismatched BufferQueue class between what is OpenCV is compiled against and what is present in Snapdragon based Qualcomm sw.

In particular, Qualcomm introduced a virtual method
virtual status_t setBuffersSize(int size);

This part is in open source (code aurora)
https://www.codeaurora.org/cgit/quic/la/platform/frameworks/native/tree/include/gui/BufferQueue.h?h=LNX.LA.2.7.3

Note, that "pure" Android source doesn't have this method
https://android.googlesource.com/platform/frameworks/native/+/android-4.4.4_r1.0.1/include/gui/BufferQueue.h

Anyway, if native camera is still to be supported this should be fixed. Unfortunately, I don't have enough time / resources to contribute a "proper" fix for that at the moment. I have a work-around for my project, where I just recompiled libnative_camera* lib of interest to me against against Qualcomm based platform. However, a "proper" solution could include both "pure" Android and "Qualcomm" Android versions of the library and load appropriate ones.

Updated by Maksim Shabunin over 9 years ago

Issue has been transferred to GitHub: https://github.com/Itseez/opencv/issues/4860

Also available in: Atom PDF