crow-misia / libyuv-android

LibYUV for Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crashes happening in Play console

PranavK1104 opened this issue · comments

image

This is the crash happening which is logged in play console. Is there a resolution for the same.?

@PranavK1104
Without information such as version in use, error messages, and how it is used, etc., I can' t answer your question.
XXXBuffer class needs to call release method to free memory when it is not in use no longer.

  1. I am using 0.4.0 version.
  2. Allocating camerax frames using I420Buffer.allocate().
  3. I am calling I420Buffe.release() in finally block making sure the buffer is released.
  4. Mainly the crash is observed on redmi 6/6a/9a.

I am getting this crash logged in my google play console vitals.

Thank you for information.
I was able to reproduce the issue and will fix it.

@PranavK1104
In the validation code that was able to reproduce the problem, there was a memory leak because the release was omitted.
Check to ensure that memory leak, such as releasing source buffer but not destination buffer.
Since it is costly to allocate each frame, it is recommended to reuse it.

@crow-misia
Can you please post a code snippet on how it has be handled. I am checking my code to find the cause.

@PranavK1104

I ran this code and verified it.
When I removed the release method call on either srcBuffer/destBuffer, I got the same situation as your error!
If the error occurs even though you are releasing the images correctly, it is probably because the image size is too large and memory is low.

for (int i = 0; i < 100000; i++) {
    I420Buffer srcBuffer = null;
    Nv21Buffer destBuffer = null;
    try {
        srcBuffer = I420Buffer.allocate(1920, 1080);
        destBuffer = Nv21Buffer.allocate(1920, 1080);

        // Any operation.
        ConvertKt.convertTo(srcBuffer, destBuffer);
    } finally {
        // release both buffers.
        if (srcBuffer != null) {
            srcBuffer.release();
        }
        if (destBuffer != null) {
            destBuffer.release();
        }
    }
}

Hello @crow-misia ,

Tried your suggestions but still I am getting those errors in my play console. Do you have a fix from your end in the library to handle the image size large case?

@PranavK1104

Large images require a large size of memory in order to allocate actual memory depending on the image size.
No mechanism is available to process large images with less memory.

@crow-misia The images allocated are directly from camerax. So whatever resolution I am getting from camerax, assigning it to allocate buffer.

@PranavK1104
When using camerax's ByteBuffer as the conversion source, there is no need to allocate a new Buffer.
Please use Buffer's wrap static method.
Only the conversion destination needs to be allocated.

When processing camerax frames, I think it is necessary to prevent the next frame from being processed before the conversion process is finished, but I guess that is not the case.

This issue is stale because it has been open for 30 days with no activity.

This issue was closed because it has been inactive for 14 days since being marked as stale.