Fotoapparat
Fotoapparat copied to clipboard
Can't start preview because of the exception: java.io.IOException: setPreviewTexture failed
Sometimes (about 1 of 15 attempts) preview won't start, because of the following exception:
D/Fotoapparat: Can't start preview because of the exception: java.io.IOException: setPreviewTexture failed
It happens usually when the device is being rotated (the Activity gets recreated) on both my devices (Samsung Galaxy S5 and Samsung Galaxy Tab S2).
EDIT: just found the same issue in #178, but it appears not fixed, the exception is just ignored.
Thank you for tips how to solve this.
I think, it happens because Texture may not be available yet (it became destroyed once you rotate your device). So onSurfaceTextureAvailable/onSurfaceTextureDestroyed
methods must be used for saving actual Texture state here io.fotoapparat.view.CameraView
Thanks for your advice. If I understand it correctly, you think that I should initialize Fotoapparat
instance in cameraView.onSurfaceTextureAvailable
method?
EDIT: Since io.fotoapparat.CameraView
inherits from FrameLayout
and the SurfaceTexture
view is a private member, I am not able to set a callback to this view. However, this should be in responsibility of the Fotoapparat library, shouldn't it?