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

[Android] App Crashes consistently when calling stop() #381

Closed
nirmalatgallabox opened this issue Aug 16, 2024 · 12 comments
Closed

[Android] App Crashes consistently when calling stop() #381

nirmalatgallabox opened this issue Aug 16, 2024 · 12 comments
Labels

Comments

@nirmalatgallabox
Copy link

Package version
5.0.4 and above

Environment

  • OS: Android

Describe the bug

App crashes consistently when AudioRecorder().stop() method is called.
This crash happens on Android 9 emulator and some of the real devices including

  • Moto G54 5G (Android 14)
  • Redmi Note 8 (Android 9)
  • Moto G14 (Android 13)

RecordConfig(encoder: AudioEncoder.aacLc, bitRate: 128000)

To Reproduce

Steps to reproduce the behavior:

  1. Start the audio recorder by calling start()
  2. Stop the audio recorder after few seconds by calling stop()

Expected behavior

Calling stop() Should stop recording and provide the recorded audio file path

Additional context

Please find the complete log in the below file which was recorded during crash.

audio_crash_log_report.txt

@nirmalatgallabox nirmalatgallabox changed the title [Android] App Crashes consistently when calling stop() [Android] App Crashes consistently when calling stop() Aug 16, 2024
@llfbandit
Copy link
Owner

This should be already fixed in record_android: 1.2.5
Can you confirm that you were not in a lower version?

@nirmalatgallabox
Copy link
Author

nirmalatgallabox commented Aug 17, 2024

I just tried record_android: 1.2.5,

Now app is not crashing but getting the below exception from native platform, this happens when stop() is called

audio_crash_report_2.txt

@nirmalatgallabox
Copy link
Author

Now we are got some more crashes
Crashed Devices

  • Redmi 13C (Android 14)
  • Oppo A38 (Android 14)
  • Model: Redmi 9 Power (Android 10)

@llfbandit Do you have any update on this?

@llfbandit
Copy link
Owner

llfbandit commented Aug 21, 2024

Yes :)
Are you able to check the modifications from the repository before release?
FYI, I didn't reproduced the issue with my device, so...

@nirmalatgallabox
Copy link
Author

Sure, will check and let you know.

You can actually reproduce the issue, if you run on Android 9 Simulator

@llfbandit
Copy link
Owner

Well I don't rely on simulators in audio recording area. Too much inconsistencies.

@nirmalatgallabox
Copy link
Author

nirmalatgallabox commented Aug 21, 2024

Now got a new error, this happens after start() is called

E/AudioRecorder(31752): Unable to instantiate PCM reader.
E/AudioRecorder(31752): java.lang.Exception: Unable to instantiate PCM reader.
E/AudioRecorder(31752):         at com.llfbandit.record.record.PCMReader.createReader(PCMReader.kt:101)
E/AudioRecorder(31752):         at com.llfbandit.record.record.PCMReader.<init>(PCMReader.kt:28)
E/AudioRecorder(31752):         at com.llfbandit.record.record.recorder.RecordThread.startRecording$lambda$0(RecordThread.kt:92)
E/AudioRecorder(31752):         at com.llfbandit.record.record.recorder.RecordThread.$r8$lambda$ldmev7sgpiaTAinIeDKedqNmCzU(Unknown Source:0)
E/AudioRecorder(31752):         at com.llfbandit.record.record.recorder.RecordThread$$ExternalSyntheticLambda0.run(Unknown Source:2)
E/AudioRecorder(31752):         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AudioRecorder(31752):         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AudioRecorder(31752):         at java.lang.Thread.run(Thread.java:764)
E/AudioRecorder(31752): Caused by: java.lang.IllegalArgumentException: Invalid audio buffer size 6989 (frame size 4)
E/AudioRecorder(31752):         at android.media.AudioRecord.audioBuffSizeCheck(AudioRecord.java:731)
E/AudioRecorder(31752):         at android.media.AudioRecord.<init>(AudioRecord.java:380)
E/AudioRecorder(31752):         at android.media.AudioRecord.<init>(AudioRecord.java:284)
E/AudioRecorder(31752):         at com.llfbandit.record.record.PCMReader.createReader(PCMReader.kt:93)
E/AudioRecorder(31752):         ... 7 more

Tested Devices

  • Android 9 Simulator
  • Poco M4 Pro (Android 13)

@llfbandit
Copy link
Owner

Argh, this has nothing to do with the current issue. You can pull again, I propagated another fix for this.

@nirmalatgallabox
Copy link
Author

@llfbandit

Got this exception after pull

D/MPEG4Writer( 8964): Audio track stopping. Stop source
D/MPEG4Writer( 8964): Audio track source stopping
D/MPEG4Writer( 8964): Audio track source stopped
E/MPEG4Writer( 8964): Missing codec specific data
E/MPEG4Writer( 8964): Dumping Audio track's last 10 frames timestamp and frame type 
E/MPEG4Writer( 8964): 
I/MPEG4Writer( 8964): Received total/0-length (150/1) buffers and encoded 150 frames. - Audio
I/MPEG4Writer( 8964): Audio track drift time: 0 us
D/MPEG4Writer( 8964): Audio track stopped. Stop source
D/MPEG4Writer( 8964): Stopping writer thread
D/MPEG4Writer( 8964): 0 chunks are written in the last batch
D/MPEG4Writer( 8964): Writer thread stopped
E/AudioRecorder( 8964): Failed to stop the muxer
E/AudioRecorder( 8964): java.lang.IllegalStateException: Failed to stop the muxer
E/AudioRecorder( 8964):         at android.media.MediaMuxer.nativeStop(Native Method)
E/AudioRecorder( 8964):         at android.media.MediaMuxer.stop(MediaMuxer.java:454)
E/AudioRecorder( 8964):         at com.llfbandit.record.record.container.MuxerContainer.stop(MuxerContainer.kt:30)
E/AudioRecorder( 8964):         at com.llfbandit.record.record.encoder.MediaCodecEncoder.stopAndRelease(MediaCodecEncoder.kt:198)
E/AudioRecorder( 8964):         at com.llfbandit.record.record.encoder.MediaCodecEncoder.finish(MediaCodecEncoder.kt:185)
E/AudioRecorder( 8964):         at com.llfbandit.record.record.encoder.MediaCodecEncoder.processOutputBuffer(MediaCodecEncoder.kt:171)
E/AudioRecorder( 8964):         at com.llfbandit.record.record.encoder.MediaCodecEncoder.access$processOutputBuffer(MediaCodecEncoder.kt:16)
E/AudioRecorder( 8964):         at com.llfbandit.record.record.encoder.MediaCodecEncoder$AudioRecorderCodecCallback.onOutputBufferAvailable(MediaCodecEncoder.kt:225)
E/AudioRecorder( 8964):         at android.media.MediaCodec$EventHandler.handleCallback(MediaCodec.java:1699)
E/AudioRecorder( 8964):         at android.media.MediaCodec$EventHandler.handleMessage(MediaCodec.java:1646)
E/AudioRecorder( 8964):         at android.os.Handler.dispatchMessage(Handler.java:106)
E/AudioRecorder( 8964):         at android.os.Looper.loop(Looper.java:193)
E/AudioRecorder( 8964):         at android.os.HandlerThread.run(HandlerThread.java:65)

Tested Devices

  • Android 9 Simulator

@llfbandit
Copy link
Owner

llfbandit commented Aug 26, 2024

I guess I finally found the bug.
You can pull latests commits.

I also tested on Emulator with Android 9 where I reproduced the issue too.

@nirmalatgallabox
Copy link
Author

Yeah, Now it is working fine, thanks for your update :)

@llfbandit
Copy link
Owner

Released in record_android 1.2.6

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

No branches or pull requests

2 participants