Closed arekolek closed 7 years ago
That is a valid point. However, there are some complications:
With that said, I would like to postpone creation of such error handler. Instead, I will remove IllegalStateException
from our current implementation so that it won't crash the app.
@dmitry-zaitsev you also make valid points, however:
I will remove IllegalStateException from our current implementation
I guess the question here is how that will affect existing clients. What will happen instead of a crash? Will the UI just freeze? Will the user know what's going on? Will the developers be aware that there is a problem?
Indicating to the user that he's not going to be able to take that photo instead of just hanging the UI like there's still some hope.
Good point. I was thinking about adding a general error callback, which would indicate that camera could not be started, with possibly some (but not all) details.
I don't see how the disconnection is a problem here.
The problem is rather not in implementation on the library side. The problem is for the clients to try to react to those problems in a meaningful way. For example, handling failed autoFocus
is possible (with options being: retry, ignore, notify user), but that direction would quickly turn client's code into a huge pile of error handling code.
So, instead, as said above, I suggest we do the following:
autoFocus
or (to some extent) takePicture
, which can be safely retried. But, as you said, it is not enough in case if failure can't be ignored (for example, when camera failed to open at all).Done. The callback will be included into the next release (expect it until the end of this week) and will look like that:
Fotoapparat.with(context)
.cameraErrorCallback(cameraException -> {
// Parameter is CameraException. This method is always called on the main thread.
})
In Fotoapparat.with(context) .cameraErrorCallback(cameraException -> { // Parameter is CameraException. This method is always called on the main thread. })
Can not able to reopen camera. If I reOpen camera then the screen is just blank.
At the moment, in
io.fotoapparat.hardware.v1.Camera1
there is an error callback setup like this:This results in crashes like this one on Xiaomi Redmi Note 3 (Android 6.0.1):
Or this one on HUAWEI P8 (Android 5.0.1):
Logs got obfuscated:
Because of how logging is implemented in Fotoapparat:
I don't know what error codes 3 and 100 mean, because Android doesn't have them documented, but a library like Fotoapparat should leave developers with choices other than crashing the app when errors it can't handle happen.