This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Camera OMXMetadata issue

Hi

I'm using 4AJ.1.1 mr0, and I found "frame.mMetaData = allocator(-1, metaDataSize, 1, NULL);" in OMXMetadata.cpp

will allocate memory, but never release

allocator() will open "/dev/zero" but didn't close it

and fd will increase until system limit (1024 in our environment)

then it will make ion_map() failed in MemoryManager

So now, I want to release "mMetaData" but I don't know when to do that

Thanks

  • Hi,

    I think the destructor of the CameraFrame class would be a good place. You can use camera_release_memory method that is inside the mMetaData pointer.

    Regards,

    Ivaylo

  • Hi,

    Thanks for your reply

    I try this approach but when I press capture button, camera will crash

    I add the code in class CameraFrame at CameraHal.h 

    virtual ~CameraFrame() {

         if ( NULL != mMetaData ) {

              mMetaData->release(mMetaData);

         }

    }

    is it correct?

  • Hi,

    it should be. I will check it myself. Also do you have a log with the crash details?

    Regars,

    Ivaylo

  • Hi,

    Here you are

    V/FocusManager( 1213): Start autofocus.
    V/camera ( 1213): mAutoFocusTime = 57ms
    V/camera ( 1213): onShutterButtonClick: mCameraState=1
    D/AudioPolicyManager( 124): getOutput() stream 7, samplingRate 0, format 0, channelMask 3, flags 0
    D/AudioPolicyManager( 124): getOutput() stream 7, samplingRate 0, format 0, channelMask 3, flags 0
    D/AudioPolicyManager( 124): getOutput() stream 7, samplingRate 44100, format 1, channelMask 1, flags 0
    D/AudioPolicyManager( 124): getOutput() stream 7, samplingRate 0, format 0, channelMask 3, flags 0
    I/AudioPlayer( 124): mLatencyUs = 348000
    V/camera ( 1213): mShutterLag = 1036ms
    W/TimeInterpolator( 124): time is rewinding: -86926 Tf=1 t0=807802642 pos0=-86926 dt=0 now=807802642 last=0 now_last=0
    F/libc ( 124): Fatal signal 11 (SIGSEGV) at 0x1ac52c0c (code=1), thread 1233 (NotificationThr)
    D/dalvikvm( 1213): GC_FOR_ALLOC freed 216K, 6% free 9088K/9607K, paused 17ms, total 18ms
    V/camera ( 1213): mShutterToPostViewCallbackTime = 97ms
    V/camera ( 1213): mShutterToRawCallbackTime = 98ms
    I/DEBUG ( 118): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    I/DEBUG ( 118): Build fingerprint: '//4.1.1/JRO03L/eng.20130304.164933:eng/test-keys'
    I/DEBUG ( 118): pid: 124, tid: 1233, name: NotificationThr >>> /system/bin/mediaserver <<<
    I/DEBUG ( 118): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 1ac52c0c
    I/DEBUG ( 118): r0 00000001 r1 00000000 r2 00000005 r3 00000547
    I/DEBUG ( 118): r4 1ac52c00 r5 4009e1ef r6 00000005 r7 401ac52c
    I/DEBUG ( 118): r8 00000000 r9 00004c5d sl 41c1f580 fp 00000001
    I/DEBUG ( 118): ip 400b8fec sp 428e2ce0 lr 40176dc3 pc 40176e02 cpsr 00000130
    I/DEBUG ( 118): d0 4141ea2000000000 d1 0000005400000000
    I/DEBUG ( 118): d2 0065007200610000 d3 0061004300490000
    I/DEBUG ( 118): d4 0000000000000000 d5 0000000000000000
    I/DEBUG ( 118): d6 0000000000000000 d7 0000000000000000
    I/DEBUG ( 118): d8 0000000000000000 d9 0000000000000000
    I/DEBUG ( 118): d10 0000000000000000 d11 0000000000000000
    I/DEBUG ( 118): d12 0000000000000000 d13 0000000000000000
    I/DEBUG ( 118): d14 0000000000000000 d15 0000000000000000
    I/DEBUG ( 118): d16 0000000000000001 d17 0000000000000000
    I/DEBUG ( 118): d18 4000000000000000 d19 bf66b5c5bba6444b
    I/DEBUG ( 118): d20 3fc54daff75d0b41 d21 3e66376972bea4d0
    I/DEBUG ( 118): d22 3fb562a9750d03a2 d23 bfd58aa5d4340e89
    I/DEBUG ( 118): d24 3ff562a9750d03a2 d25 0000000000000000
    I/DEBUG ( 118): d26 0000000000000000 d27 0000000000000000
    I/DEBUG ( 118): d28 0000000000000000 d29 0000000000000000
    I/DEBUG ( 118): d30 0000000000000000 d31 0000000000000000
    I/DEBUG ( 118): scr 60000010
    I/DEBUG ( 118):
    I/DEBUG ( 118): backtrace:
    I/DEBUG ( 118): #00 pc 00013e02 /system/lib/libc.so (dlmalloc+117)
    I/DEBUG ( 118): #01 pc 00016d2f /system/lib/libc.so (malloc+10)
    I/DEBUG ( 118): #02 pc 000008fb /system/lib/libstdc++.so (operator new[](unsigned int)+2)
    I/DEBUG ( 118): #03 pc 00009379 /system/lib/libcameraservice.so
    I/DEBUG ( 118): #04 pc 0000945f /system/lib/libcameraservice.so
    I/DEBUG ( 118): #05 pc 0002bcd9 /system/lib/hw/camera.omap4.so (Ti::Camera::AppCallbackNotifier::copyAndSendPictureFrame(Ti::Camera::CameraFrame*, int)+48)
    I/DEBUG ( 118): #06 pc 0002d8cf /system/lib/hw/camera.omap4.so (Ti::Camera::AppCallbackNotifier::notifyFrame()+806)
    I/DEBUG ( 118): #07 pc 0002dce1 /system/lib/hw/camera.omap4.so (Ti::Camera::AppCallbackNotifier::notificationThread()+68)
    I/DEBUG ( 118): #08 pc 00010f33 /system/lib/libutils.so (android::Thread::_threadLoop(void*)+94)
    I/DEBUG ( 118): #09 pc 00010aad /system/lib/libutils.so
    I/DEBUG ( 118): #10 pc 00012bb0 /system/lib/libc.so (__thread_entry+48)
    I/DEBUG ( 118): #11 pc 00012308 /system/lib/libc.so (pthread_create+172)
    I/DEBUG ( 118):
    I/DEBUG ( 118): stack:
    I/DEBUG ( 118): 428e2ca0 00000085
    I/DEBUG ( 118): 428e2ca4 401d2df1 /system/lib/libbinder.so (android::MemoryHeapBase::mapfd(int, unsigned int, unsigned int)+68)
    I/DEBUG ( 118): 428e2ca8 00000085
    I/DEBUG ( 118): 428e2cac 00000000
    I/DEBUG ( 118): 428e2cb0 00000001
    I/DEBUG ( 118): 428e2cb4 41c1dd90 [heap]
    I/DEBUG ( 118): 428e2cb8 00000000
    I/DEBUG ( 118): 428e2cbc 4141ea20
    I/DEBUG ( 118): 428e2cc0 00000054
    I/DEBUG ( 118): 428e2cc4 0000006c
    I/DEBUG ( 118): 428e2cc8 c0000000
    I/DEBUG ( 118): 428e2ccc 00000024
    I/DEBUG ( 118): 428e2cd0 00000000
    I/DEBUG ( 118): 428e2cd4 41c1f5d8 [heap]
    I/DEBUG ( 118): 428e2cd8 df0027ad
    I/DEBUG ( 118): 428e2cdc 00000000
    I/DEBUG ( 118): #00 428e2ce0 0000001b
    I/DEBUG ( 118): 428e2ce4 4017825b /system/lib/libc.so (dlmalloc+5326)
    I/DEBUG ( 118): 428e2ce8 c0000000
    I/DEBUG ( 118): 428e2cec 00000010
    I/DEBUG ( 118): 428e2cf0 c0000000
    I/DEBUG ( 118): 428e2cf4 41c1f570 [heap]
    I/DEBUG ( 118): 428e2cf8 00000000
    I/DEBUG ( 118): 428e2cfc 41c1f5d8 [heap]
    I/DEBUG ( 118): 428e2d00 40e9bfd8
    I/DEBUG ( 118): 428e2d04 00000000
    I/DEBUG ( 118): 428e2d08 00004c5d
    I/DEBUG ( 118): 428e2d0c 41c1f580 [heap]
    I/DEBUG ( 118): 428e2d10 00000001
    I/DEBUG ( 118): 428e2d14 40179d31 /system/lib/libc.so (malloc+12)
    I/DEBUG ( 118): #01 428e2d18 41c1f618 [heap]
    I/DEBUG ( 118): 428e2d1c 400b78ff /system/lib/libstdc++.so (operator new[](unsigned int)+6)
    I/DEBUG ( 118): #02 428e2d20 41c1f618 [heap]
    I/DEBUG ( 118): 428e2d24 404bd37d /system/lib/libcameraservice.so

    .........

    Thanks

  • Hi,

    it seems by looking at the code that problem has been fixed in the next release 4AJ.2.1. I have not been able to test it myself but I can suggest you try these two ways to fix it. By either freeing it at the end of AppCallbackNotifier::notifyFrame() before freeing the CameraFrame pointer. Or if you are willing to spend more time on it by wrapping camera_memory_t in a class and making it a smart pointer (You have to remove the freeing in BufferSourceAdapter::handleFrameCallback()). You can see how it is done in release 4AJ.2.1.

    I hope this is more helpful than the first time.

    Regards,

    Ivaylo

  • Hi,

    Thanks for your reply

    I tried your suggestion that freeing it at the end of AppCallbackNotifier::notifyFrame() and it's working