android / android/camera-samples
Camera2Video: java.lang.IllegalStateException at android.media.MediaRecorder.stop(Native Method)
- Dominant language
- Kotlin
- Stars
- 5.5k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
Hello. I have crash while pressing rec button.
**My steps to reproduce:**
1. Build and install camera2video app on a device
2. Choose any resolution(i have checked few of them, all are crashed)
3. See camera preview and rec button.
4. Press rec button -> crash
**Crash log:**
> E/MediaRecorder: stop called in an invalid state: 4
> E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-3
> Process: com.android.example.camera2.video, PID: 608
> java.lang.IllegalStateException
> at android.media.MediaRecorder.stop(Native Method)
> at com.example.android.camera2.video.fragments.CameraFragment$initializeCamera$1$1$2.invokeSuspend(CameraFragment.kt:297)
> at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
> at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
> at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
> at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
> at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
> at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
>
**Other details**
git head is: 852767fddd25b0f33e117d811bd5cdb6694b8904
phone: SM-950F
Any thoughts?
Contributor guide
Research direction
Build and install the camera2video app, choose a resolution, and reproduce the crash by pressing the record button. Then inspect CameraFragment.kt around line 297 and trace the MediaRecorder state leading to stop; the work is done when this reproduction no longer throws IllegalStateException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100