startRecording throws IOException in MediaRecorder prepare call
Opened this issue · 11 comments
This is on a Samsung device running Android 7.1.1
For background, fancycamera
is a dependency of the capacitor-video-recorder plugin. I've updated the plugin to use the latest version of fancycamera from maven (v1.2.2
).
Calling startRecording
throws an uncaught IOException which locks up my app. Here is the log output:
2020-04-06 15:27:32.745 D/InputMethodManager: HSIFW - flag : 0 Pid : 10941
2020-04-06 15:27:33.546 I/art: Background sticky concurrent mark sweep GC freed 345032(9MB) AllocSpace objects, 7(140KB) LOS objects, 68% free, 4MB/14MB, paused 1.493ms total 131.661ms
2020-04-06 15:27:35.760 V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 90928156, pluginId: VideoRecorder, methodName: startRecording
2020-04-06 15:27:35.760 V/Capacitor: callback: 90928156, pluginId: VideoRecorder, methodName: startRecording, methodData: {}
2020-04-06 15:27:35.761 I/RequestQueue: Repeating capture request cancelled.
2020-04-06 15:27:35.761 I/MediaRecorderJNI: native_reset
2020-04-06 15:27:35.761 I/MediaRecorderJNI: release
2020-04-06 15:27:35.764 I/MediaRecorderJNI: setup
2020-04-06 15:27:35.765 I/MediaRecorderJNI: setAudioSource(1)
2020-04-06 15:27:35.772 I/MediaRecorderJNI: setVideoSource(2)
2020-04-06 15:27:35.794 I/MediaRecorderJNI: setVideoSize(640, 480)
2020-04-06 15:27:35.794 I/MediaRecorderJNI: setParameter()
2020-04-06 15:27:35.795 I/MediaRecorderJNI: setParameter()
2020-04-06 15:27:35.796 I/MediaRecorderJNI: setVideoFrameRate(30)
2020-04-06 15:27:35.796 I/MediaRecorderJNI: setParameter()
2020-04-06 15:27:35.797 I/CameraDeviceState: Legacy camera service transitioning to state IDLE
2020-04-06 15:27:35.797 I/MediaRecorderJNI: setParameter()
2020-04-06 15:27:35.798 I/MediaRecorderJNI: setVideoEncoder(5)
2020-04-06 15:27:35.798 I/MediaRecorderJNI: setAudioEncoder(3)
2020-04-06 15:27:35.802 I/CameraDeviceState: Legacy camera service transitioning to state CONFIGURING
2020-04-06 15:27:35.804 I/RequestThread-1: Configure outputs: 0 surfaces configured.
2020-04-06 15:27:35.810 I/MediaRecorderJNI: setOutputFile
2020-04-06 15:27:35.811 I/MediaRecorderJNI: prepare
2020-04-06 15:27:35.815 E/MediaRecorder: prepare failed: -2147483648
2020-04-06 15:27:35.816 W/System.err: java.io.IOException: prepare failed.
2020-04-06 15:27:35.816 W/System.err: at android.media.MediaRecorder._prepare(Native Method)
2020-04-06 15:27:35.817 W/System.err: at android.media.MediaRecorder.prepare(MediaRecorder.java:1164)
2020-04-06 15:27:35.817 W/System.err: at co.fitcom.fancycamera.Camera2.setUpMediaRecorder(Camera2.java:607)
2020-04-06 15:27:35.817 W/System.err: at co.fitcom.fancycamera.Camera2.startRecording(Camera2.java:837)
2020-04-06 15:27:35.817 W/System.err: at co.fitcom.fancycamera.FancyCamera.startRecording(FancyCamera.java:323)
2020-04-06 15:27:35.817 W/System.err: at com.github.sbannigan.capacitor.VideoRecorder.startRecording(VideoRecorder.java:274)
2020-04-06 15:27:35.817 W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2020-04-06 15:27:35.817 W/System.err: at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99)
2020-04-06 15:27:35.817 W/System.err: at com.getcapacitor.Bridge$1.run(Bridge.java:520)
2020-04-06 15:27:35.817 W/System.err: at android.os.Handler.handleCallback(Handler.java:751)
2020-04-06 15:27:35.817 W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
2020-04-06 15:27:35.818 W/System.err: at android.os.Looper.loop(Looper.java:154)
2020-04-06 15:27:35.818 W/System.err: at android.os.HandlerThread.run(HandlerThread.java:61)
2020-04-06 15:27:35.909 D/Camera: app passed NULL surface
2020-04-06 15:27:35.928 W/SurfaceTextureRenderer: No output surfaces configured for GL drawing.
2020-04-06 15:27:35.943 I/CameraDeviceState: Legacy camera service transitioning to state IDLE
Previous to calling startRecording
my app displays the video preview correctly, so access to the camera and audio are not an issue.
Hi what device and OS version are you using
Just FYI: added jitpack to my build.gradle so I could install fancycamera version 1.2.4
and having the same problem.
Also: the error does not happen in the Android Studio device emulator (Pixel 3a, API 29), though I can't fully test functionality on the emulator since it doesn't actually save a real video to the device storage.
@triniwiz I was able to test it on a newer Android phone and same error.
Device Huawei Y6s, Android version 9.1.0.246
Hi again @triniwiz
Maybe a long shot, but I was wondering if you have any recommendations for what I can do to debug this issue?
I created an example repo with a simple version of my app to ease debugging here: https://github.com/disbelief/video-recorder-test
And I added an issue with all the details I've come up with thus far: disbelief/video-recorder-test#1
Any help/advice would be greatly appreciated.
Looking at the log this app passed NULL surface 2020-04-06 15:27:35.928 W/SurfaceTextureRenderer: No output surfaces configured for GL drawing. 2020-04-06
stands out it might since it showing the recording it might be a config issue you can try commenting some of the config changes an let the camcorder profile set everything needed
Thanks will I try cutting down on the custom configuration and relying on the defaults of the camcorder.
I think possibly that "NULL surface" is where the preview would be displayed typically... possibly two processes trying to access the camera output at the same time?
@triniwiz sorry, something else I just noticed: there's a stacktrace printed earlier in the logs saying "The camera device has been disconnected".
This is when the camera is first initialized in preview mode, before startRecording
is called.
Oddly the preview continues to work and the app does not crash. However perhaps this has something to do with the subsequent error thrown by startRecording?
Here's the earlier stack trace, which is thrown when startPreview
is called:
I/Capacitor/Console: File: http://localhost/static/js/main.4b5f70bb.chunk.js - Line 1 - Msg: VideoRecorderContainer.render
I/Capacitor/Console: File: http://localhost/static/js/main.4b5f70bb.chunk.js - Line 1 - Msg: VideoRecorder.onMount initializing camera
V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 128373272, pluginId: VideoRecorder, methodName: initialize
V/Capacitor: callback: 128373272, pluginId: VideoRecorder, methodName: initialize, methodData: {"camera":0,"previewFrames":[{"id":"video-recorder","stackPosition":"back","x":0,"y":177,"width":360,"height":360}],"quality":1,"audio":false}
D/Capacitor: Handling local request: http://localhost/favicon.ico
I/Capacitor/Console: File: http://localhost/static/js/main.4b5f70bb.chunk.js - Line 1 - Msg: VideoRecorderContainer.render
I/CameraManagerGlobal: Connecting to camera service
I/PermissionManager: camera remind result:true
I/CameraManager: open camera: 1, package name: ca.auka.videorecorder
I/BackgroundPermManager: pkgName: ca.auka.videorecorder,pid: 27309 ,uidOf3RdApk: 10132 ,permType: 0 ,permCfg: 1
I/HwCameraUtil: notifySurfaceFlingerCameraStatus : isFront = true , isOpend = true
I/HwCameraUtil: notifySurfaceFlingerFrontCameraStatus 8011 transact success!
I/PermissionManager: camera remind result:true
I/CameraManager: open camera: 1, package name: ca.auka.videorecorder
I/BackgroundPermManager: pkgName: ca.auka.videorecorder,pid: 27309 ,uidOf3RdApk: 10132 ,permType: 0 ,permCfg: 1
I/HwCameraUtil: notifySurfaceFlingerCameraStatus : isFront = true , isOpend = true
I/HwCameraUtil: notifySurfaceFlingerFrontCameraStatus 8011 transact success!
W/System.err: android.hardware.camera2.CameraAccessException: CAMERA_DISCONNECTED (2): checkPidStatus:1773: The camera device has been disconnected
W/System.err: at android.hardware.camera2.CameraManager.throwAsPublicException(CameraManager.java:753)
W/System.err: at android.hardware.camera2.impl.ICameraDeviceUserWrapper.createDefaultRequest(ICameraDeviceUserWrapper.java:161)
W/System.err: at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureRequest(CameraDeviceImpl.java:769)
W/System.err: at co.fitcom.fancycamera.Camera2.startPreview(Camera2.java:755)
W/System.err: at co.fitcom.fancycamera.Camera2.access$500(Camera2.java:70)
W/System.err: at co.fitcom.fancycamera.Camera2$2.onOpened(Camera2.java:389)
W/System.err: at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:147)
W/System.err: at android.os.Handler.handleCallback(Handler.java:907)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:105)
W/System.err: at android.os.Looper.loop(Looper.java:216)
W/System.err: at android.os.HandlerThread.run(HandlerThread.java:65)
W/System.err: Caused by: android.os.ServiceSpecificException: checkPidStatus:1773: The camera device has been disconnected (code 4)
W/System.err: at android.os.Parcel.createException(Parcel.java:1967)
W/System.err: at android.os.Parcel.readException(Parcel.java:1921)
W/System.err: at android.os.Parcel.readException(Parcel.java:1871)
W/System.err: at android.hardware.camera2.ICameraDeviceUser$Stub$Proxy.createDefaultRequest(ICameraDeviceUser.java:556)
W/System.err: at android.hardware.camera2.impl.ICameraDeviceUserWrapper.createDefaultRequest(ICameraDeviceUserWrapper.java:159)
W/System.err: ... 9 more
I/CameraDevice-JV-1: close camera: 1, package name: ca.auka.videorecorder
I/BackgroundPermManager: pkgName: ca.auka.videorecorder,pid: 27309 ,uidOf3RdApk: 10132 ,permType: 0 ,permCfg: 0
I/HwCameraUtil: notifySurfaceFlingerCameraStatus : isFront = true , isOpend = false
I/HwCameraUtil: notifySurfaceFlingerFrontCameraStatus 8012 transact success!
V/Capacitor/VideoRecorder: Notifying listeners for event onVolumeInput
D/Capacitor/VideoRecorder: No listeners found for event onVolumeInput
E/ion: ioctl c0044901 failed with code -1: Invalid argument
Does this indicate anything to you?
I'm also trying to have a camera functionality work with TeamHive/capacitor-video-recorder, but it's broken.
Android 9.0,
latest capacitor versions + jetifier executed.
Did you ever figure it out? @disbelief
I’m currently working on some v2 updates which should address a couple issues