google / cameraview

[DEPRECATED] Easily integrate Camera features into your Android app
Apache License 2.0
4.74k stars 1.03k forks source link

CameraView.Callback#onPictureTaken data argument can be null #209

Open drd opened 6 years ago

drd commented 6 years ago

This doesn't seem to happen very often, but over the last 90 days I see 6 crashes where our onPictureTaken callback throws an NPE because we had assumed this to be @NotNull. All of these occurred on 4.x versions (4.2.2, 4.0.4, and 4.3 in descending order of occurrences). I'm guessing that the intent of this callback is to never have null data, so there must be a bug somewhere in the Camera1 code. Since it's just passing along the results of https://developer.android.com/reference/android/hardware/Camera.PictureCallback.html#onPictureTaken(byte[],%20android.hardware.Camera), which does not make any claims about the nullity of the data, I suspect the best approach would be to either ignore if the data is null, or attempt a retry. Opinions?