infinum / Android-GoldenEye

A wrapper for Camera1 and Camera2 API which exposes simple to use interface.
Apache License 2.0
375 stars 53 forks source link

autoFocus failed #33

Open Danyaga opened 5 years ago

Danyaga commented 5 years ago

Hi, I used GoldenEye in some of my apps and I found a recurrent crash on some devices (Sony Xperia XA1, Samsung Galaxy S10+) which is a Fatal Exception: java.lang.RuntimeException autoFocus failed. In particular, I forced the Camera1 implementation to have a more consistent experience on all devices. Here the Stack trace.

In the documentation, I saw that it can be raised when "hardware or other low-level error, or because release() has been called on this Camera instance".

My question is: did you put any checks to avoid request to the auto focus when the camera is released? Any further suggestion to avoid this kind of issue?

domagojkorman commented 5 years ago

Hi @Danyaga ,

thanks for the report. This is something that I have to take a look into and will let you know what I find or if I need more info.

domagojkorman commented 5 years ago

Hi @Danyaga ,

when releasing the Camera, do you call GoldenEye#release(). GoldenEye#release() should release GestureDetector which tries to execute autoFocus. Do you have some kind of navigation? Do you release a camera when navigating?

Danyaga commented 5 years ago

Thx for the answer.

I call the GoldenEye#release(), during the Activity#onStop():

`override fun onStop() {

    super.onStop()

    this.goldenEye?.release()

}`

Do you think that the right place for it is another activity method? I'm not using Fragments, but just a plain "activity camera".