Skip to content

getCurrentParameters()/getCapabilities().whenAvailable{} returns null if called too early #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jpribble opened this issue Jan 5, 2018 · 4 comments
Assignees
Labels

Comments

@jpribble
Copy link
Contributor

jpribble commented Jan 5, 2018

What are you trying to achieve or the steps to reproduce?

I'm trying to call Fotoapparat.getCurrentParameters().whenAvailable { ... } and Fotoapparat.getCapabilities().whenAvailable { ... } in my Activity's onStart().

override fun onStart() {
  super.onStart()
  camera.start()
  camera.getCurrentParameters().whenAvailable { … }
  camera.getCapabilities().whenAvailable { … }
}

How did you initialize FA?

override fun onCreate() {
  super.onCreate()
  …
  camera = Fotoapparat
    .with(this)
    .into(cameraView!!)
    .previewScaleType(ScaleType.CenterCrop)
    .photoResolution([custom_selector])
    .previewResolution([custom_selector])
    .lensPosition(single(LensPosition.Back))
    .focusMode(firstAvailable(
        continuousFocusPicture(),
        autoFocus(),
        fixed()))
    .flash(off())
    .frameProcessor { … }
    .previewFpsRange(highestFps())
    .cameraErrorCallback { … }
    .logger(logcat())
    .build()
}

What was the result you received?

Both calls return NULL and the log shows "Couldn't deliver pending result":

01-05 15:48:56.884 9089-9089/[package_name] D/Fotoapparat: Fotoapparat: getCapabilities
01-05 15:48:56.887 9089-13521/[package_name] D/Fotoapparat: CameraDevice: getParameters
01-05 15:48:56.888 9089-13094/[package_name] D/Fotoapparat: Couldn't deliver pending result.

What did you expect?

I expect the calls to return valid results and delay their async callbacks if the camera is still initializing.

Context:

  • FA version: 2.0.2
  • Devices/APIs affected: Samsung Galaxy S8 running Android 7.0.
  • Other Notes: This used to work in version 1.5.0.
@Diolor Diolor added the bug label Jan 6, 2018
@Diolor
Copy link
Member

Diolor commented Jan 7, 2018

(same will happen for current parameters)

@Diolor
Copy link
Member

Diolor commented Jan 16, 2018

Explicit, improved logs in #181

@jpribble
Copy link
Contributor Author

I'm still seeing this issue when testing the latest master code. Here are the logs:

01-18 10:52:17.208 11349-11349/ D/Fotoapparat: Fotoapparat:
01-18 10:52:17.228 11349-11349/ D/Fotoapparat: Fotoapparat: start
01-18 10:52:17.228 11349-11349/ D/Fotoapparat: Fotoapparat: getCurrentParameters
01-18 10:52:17.228 11349-12587/ D/Fotoapparat: Device: selectCamera
01-18 10:52:17.228 11349-12587/ D/Fotoapparat: CameraDevice: open
01-18 10:52:17.228 11349-11349/ D/Fotoapparat: Fotoapparat: getCapabilities
01-18 10:52:17.228 11349-12975/ D/Fotoapparat: CameraDevice: getParameters$suspendImpl
01-18 10:52:17.368 11349-12587/ D/Fotoapparat: CameraDevice: getCapabilities$suspendImpl
01-18 10:52:17.368 11349-12587/ D/Fotoapparat: CameraDevice: updateParameters$suspendImpl
01-18 10:52:17.368 11349-12975/ D/Fotoapparat: CameraDevice: getCapabilities$suspendImpl
01-18 10:52:17.368 11349-12590/ D/Fotoapparat: Couldn't deliver pending result: Operation failed internally.
01-18 10:52:17.368 11349-12587/ D/Fotoapparat: New camera parameters are: CameraParameters ...

@Diolor Diolor reopened this Jan 18, 2018
@dmitry-zaitsev dmitry-zaitsev self-assigned this Jan 18, 2018
@dmitry-zaitsev
Copy link
Member

I believe that pull request will fix it #188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants