Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash IllegalStateException MediaCodec.native_dequeueInputBuffer(MediaCodec.java) during compression #256

Open
emrisb opened this issue Mar 27, 2023 · 5 comments

Comments

@emrisb
Copy link

emrisb commented Mar 27, 2023

Hey,

Thanks for this awesome library. I have just implemented the library and release it. When I looked to Crashlytics, I have bunch of crash like below. I could not reproduce the crash so I don't have any user story for that. Do you have any opinion for solution?

Fatal Exception: java.lang.IllegalStateException:
       at android.media.MediaCodec.native_dequeueInputBuffer(MediaCodec.java)
       at android.media.MediaCodec.dequeueInputBuffer(MediaCodec.java:3039)
       at com.linkedin.android.litr.codec.MediaCodecEncoder.dequeueInputFrame(MediaCodecEncoder.java:81)
       at com.linkedin.android.litr.render.AudioRenderer$RenderThread.run(AudioRenderer.java:125)
       at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultPriorityThreadFactory$1.run$bridge(GlideExecutor.java:299)
@izzytwosheds
Copy link
Contributor

Thank you for reporting this. I will try to reproduce this and will get back to you.
My suspicion would be that we are trying to encode an audio frame but the encoder MediaCodec is stopped. I will try to understand how this can happen.

@florianPOLARSTEPS
Copy link

I am seeing the same issue happening quite frequently in my logs. I have not yet been able to reproduce it though.

@emrisb
Copy link
Author

emrisb commented Jun 15, 2023

@izzytwosheds I guess this issue happening when you get failed and if you retry right away with new compression. In that case onError is called before release completed for some components(MediaCodec, MediaExtractor, MediaMuxer). Not fully sure but maybe below change in TransformationJob or something similar to this might solve this issue.

from

@VisibleForTesting
    protected void error(@Nullable Throwable cause) {
        marshallingTransformationListener.onError(jobId, cause, statsCollector.getStats());
        release(false);
    }

to

@VisibleForTesting
    protected void error(@Nullable Throwable cause) {
        release(false);
        marshallingTransformationListener.onError(jobId, cause, statsCollector.getStats());
    }

@florianPOLARSTEPS
Copy link

@izzytwosheds I guess this issue happening when you get failed and if you retry right away with new compression. In that case onError is called before release completed for some components(MediaCodec, MediaExtractor, MediaMuxer). Not fully sure but maybe below change in TransformationJob or something similar to this might solve this issue.

from

@VisibleForTesting
    protected void error(@Nullable Throwable cause) {
        marshallingTransformationListener.onError(jobId, cause, statsCollector.getStats());
        release(false);
    }

to

@VisibleForTesting
    protected void error(@Nullable Throwable cause) {
        release(false);
        marshallingTransformationListener.onError(jobId, cause, statsCollector.getStats());
    }

I can confirm this. We are seeing the same pattern in our logs 👍

@izzytwosheds
Copy link
Contributor

Thanks for reporting this and finding the way to reproduce, guys! We will look into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants