Downloaded Xamarin Camera2Basic project
Initially all works correctly as it's begin tested in Visual Studio 2017 emulator.
Commented out code inside "CameraCaptureStillPictureSessionCallback.cs" as shown below to allow the still image captured to be displayed on the emulator screen after clicking the "Take Picture" button:
public override void OnCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result)
{
//Owner.ShowToast("Saved: " + Owner.mFile);
//Log.Debug(TAG, Owner.mFile.ToString());
//Owner.UnlockFocus();
}
Clicking the "Take Picture" button hides itself, and shows another button labeled "Retake Picture" on the screen (which I added after the fact and the code is located in the Camera2BasicFragment.cs file, but the code is inconsequential to the issue).
Clicking the now visible "Retake Picture" button does the following:
- Hides itself
- Shows the "Take Picture" button
- Calls UnlockFocus()
UnlockFocus() allows the camera's stream to display continuously on the screen instead of the still image captured previously.
Now, when I click the "Take Picture" button again (to attempt to capture a new still image), the app crashes.
Visual studio does not provide any meaningful error messages. The closest useful bit of information are the error messages displayed int the Device Log:
07-26 23:29:03.201 10.1" Marshmallow (6.0.0) XHDPI Tablet Error 6987 BufferQueueProducer [ImageReader-640x480f100m2-6987-0] dequeueBuffer: can't dequeue multiple buffers without setting the buffer count
07-26 23:29:07.174 10.1" Marshmallow (6.0.0) XHDPI Tablet Error 6987 RequestThread-0 Hit timeout for jpeg callback!
07-26 23:29:03.201 10.1" Marshmallow (6.0.0) XHDPI Tablet Error 6987 Legacy-CameraDevice-JNI LegacyCameraDevice_nativeProduceFrame: Error while producing frame Function not implemented (-38).
I'm not sure what to make of these errors, or which settings/code to change to allow the "Retake Picture" functionality to work without crashing the app.
Any suggestions?
EDIT 1: Per request, where is a link to the project as I currently have it.
https://drive.google.com/file/d/0B7OSuA_ybXcFb081T210UlQzZkE/view?usp=sharing
Here is some other seemingly pertinent information:
This code was run using:
a. Windows 10 Pro, Visual Studio 2017 Community, Android Emulator For Visual Studio, Hyper-v Virtual Manager, Android 6.0 (Marshamallow SDK 23), Tablet sized template
b. 2013 Macbook Pro, Visual Studio For Mac (latest version), default emaulator, Android 6.0 (Marshmallow SDK 23), Tablet sized template.
The failure to take snapshot after second "LockFocus" call is observed in both environments.
The Mac made it easier to find some more meaninful errors:
a. The error I saw happened on method "produceFrame" inside LegacyCameraDevice.java