Random crash with repeated Record/Preview
還沒有人認領這個 Issue。
評估
研究方向
未識別出儲存庫檔案或測試。先重現 issue 中描述的重複 Camera2 視訊和 MediaRecorder 啟動/停止循環,然後結合回報的相機錯誤檢查 CreateCaptureRequest、CreateCaptureSession 和 OnConfigureFailed 路徑。完成的標準是重複循環不再造成當機,且應用程式在錯誤後返回預期狀態。
由索引模型根據 Issue 內容生成。
描述
UPDATE: This appears to be related to https://github.com/android/camera-samples/issues/109, But with Camera2 instead of CameraX.
I've built a test app using Camera2 video and MediaRecoder. This was seemingly working, but I was having random crashes when stopping record when repeatedly starting/stopping recording. The result of this record state change is that the previewBuilder gets rebuilt with previewSurface + recordSurface (record Start), or just previewSurface (record Stop).
To track it down, I made the code cycle 100 times thru a 10 second record/stop at 15 second intervals. With this approach, I can almost always see a crash, though it could be at iteration 3 or at 80, sometimes not until 300. I've done this testing on multiple Galaxy S9/10 devices as well as on a Pixel 4. All fail the same way, eventually.
The crashes appear to happen either at CreateCaptureRequest or at CreateCaptureSession. And the errors vary from crash to crash, usually being one of these:
-
[Binder] java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List android.hardware.camera2.params.OutputConfiguration.getSurfaces()' on a null object reference
-
CAMERA_ERROR (3): waitUntilIdle:1701: Camera 0: Error waiting to drain: Connection timed out (-110)
-
android.hardware.camera2.CameraAccessException: CAMERA_ERROR (3): The camera device has encountered a serious error
-
android.os.ServiceSpecificException: createDefaultRequest:1644: Camera 0: Error creating default request for template 3: Function not implemented (-38) (code 10)
-
CameraCaptureSession Session 4: Failed to create capture session; configuration failed
I have not figured out how to recover from the error to get the app back into an expected state consistently. try/catch isn't working, as the error seems to occur in some async camera2 functionality. I can see that OnConfigureFailed is called, but by the time that's happened, it's already at some other part of the code which will fail. I tried to separate further along steps to be triggered by OnConfgured/OnReady, to isolate where the crash is happening, but it doesn't seem to be consistent, and this didn't stop the crash from happening.
My best guess is that some background activity, outside my app, is in conflict at the random point in time when my recording is changing states. But, I can't be sure of that.
I've added a ton of tracking into my code to try and isolate this, but no matter what I do, the result is the same. I'm stumped.
I also tried to make it so that I did not rebuild the previewBuilder with every record state change. But this didn't work because of the use of MediaRecorder for which there doesn't seem to be a way to Stop/Start it without recreating it.
- 主要語言
- Kotlin
- 星號
- 5.5k
- 分支
- 2.4k
- 平均合併
- 34 分鐘
- 30 天內合併 PR
- 1
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
android/camera-samples 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 65/100
android/camera-samples#546 ·
-
Crash on app start caused by empty resources可能已有人在做 @bradh 於 26 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 15/100
android/camera-samples#645 ·
-
camerax)未關閉
android/camera-samples#644 · 1 則留言 ·
-
難度 4/5 3-5 天 新手友好度 25/100
android/camera-samples#545 · 1 則留言 ·
-
難度 3/5 1-2 天 新手友好度 30/100
android/camera-samples#544 ·
查看 android/camera-samples 的全部 Issue
相似的 Issue
-
code-scan
難度 2/5 1-3 小時 新手友好度 74/100
ankidroid/Anki-Android#23806 ·
維護者通常 1 天內回覆
-
難度 1/5 1-3 小時 新手友好度 86/100
thisisartman/Meguri#211 ·
維護者通常 1 天內回覆
-
follow-up
難度 1/5 1 小時以內 新手友好度 75/100
維護者通常 1 天內回覆
-
area:android fleet
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
krishnanunnir/vulcan-launcher#135 ·
維護者通常 1 天內回覆