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 on some Android 14 physical devices when stopping recording. #369

Closed
siddharthadevops opened this issue Jul 15, 2024 · 2 comments
Closed
Labels
Android bug Something isn't working

Comments

@siddharthadevops
Copy link
Contributor

(record: ^5.1.2)

Android device.

App crashes due to an unhandled excepcion

Add your record configuration
RecordConfig get _recordConfig => const RecordConfig(
bitRate: 64000,
sampleRate: 16000,
numChannels: 2,
);

Record and stop the recording.

Exception:
E/AndroidRuntime(32182): FATAL EXCEPTION: MediaCodecEncoder Thread
E/AndroidRuntime(32182): Process: com.weebumessenger.weebu, PID: 32182
E/AndroidRuntime(32182): java.lang.IllegalStateException: codec is released already
E/AndroidRuntime(32182): at android.media.MediaCodec.native_stop(Native Method)
E/AndroidRuntime(32182): at android.media.MediaCodec.stop(MediaCodec.java:2531)
E/AndroidRuntime(32182): at com.llfbandit.record.record.encoder.MediaCodecEncoder.stopAndRelease(MediaCodecEncoder.kt:171)
E/AndroidRuntime(32182): at com.llfbandit.record.record.encoder.MediaCodecEncoder.onError(MediaCodecEncoder.kt:161)
E/AndroidRuntime(32182): at com.llfbandit.record.record.encoder.MediaCodecEncoder.processOutputBuffer(MediaCodecEncoder.kt:155)
E/AndroidRuntime(32182): at com.llfbandit.record.record.encoder.MediaCodecEncoder.access$processOutputBuffer(MediaCodecEncoder.kt:15)
E/AndroidRuntime(32182): at com.llfbandit.record.record.encoder.MediaCodecEncoder$AudioRecorderCodecCallback.onOutputBufferAvailable(MediaCodecEncoder.kt:201)
E/AndroidRuntime(32182): at android.media.MediaCodec$EventHandler.handleCallback(MediaCodec.java:1952)
E/AndroidRuntime(32182): at android.media.MediaCodec$EventHandler.handleMessage(MediaCodec.java:1850)
E/AndroidRuntime(32182): at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(32182): at android.os.Looper.loopOnce(Looper.java:232)
E/AndroidRuntime(32182): at android.os.Looper.loop(Looper.java:317)
E/AndroidRuntime(32182): at android.os.HandlerThread.run(HandlerThread.java:85)

Add any other context about the problem here.

I debugged the bug and found out that for some reason the OnError function is called after stopping playback and discarding the Recorder object on the Flutter side.

E/AndroidRuntime(32182): on com.llfbandit.record.record.encoder.MediaCodecEncoder.onError(MediaCodecEncoder.kt:161)

As a workaround, I added a variable (ThreadSafe) to ensure that stopAndRelease is not called twice. And I also converted the mFinished variable to support multithreading. This solved the problem.
I didn't propose a PR because I have zero experience developing in Kotlin and I'm not sure how multitasking works with this package and in Kotlin in general.

@Shinhwe
Copy link

Shinhwe commented Jul 25, 2024

same issue here

can you share your code?

thx

@TMuthu
Copy link

TMuthu commented Jul 25, 2024

Facing same issue, when try to start the recording.

@llfbandit llfbandit added bug Something isn't working Android labels Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants