Skip to content
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

Cannot stop live-view after starting it #13

Open
icheered opened this issue Oct 9, 2023 · 6 comments
Open

Cannot stop live-view after starting it #13

icheered opened this issue Oct 9, 2023 · 6 comments

Comments

@icheered
Copy link
Contributor

icheered commented Oct 9, 2023

Camera: Nikon D5300

When starting the viewfinder (live-view) the camera raises the mirror and you can capturePreviewAsBlob at high speed. When trying to disable the viewfinder it will error:

Error: libapi.mjs?v=263350c0:9 Uncaught (in promise) Error: I/O in progress

My first guess is that it has something to do with the scheduling of events like @RReverser mentions in his blog.

Notes

  1. I can still change other settings like ISO while in liveview.
  2. Using the gphoto2 CLI I can enable and disable liveview as normal
  3. Updating libgphoto2 to the latest version does not fix the issue
@irvandikky
Copy link

irvandikky commented Oct 9, 2023

I'm also always got

Could not refresh preview: Error: Unspecified error
    at throw_msg (libapi.mjs?v=54d10e0e:9:16162)
    at libapi.wasm:0xe8f33
    at ret.<computed> (libapi.mjs?v=54d10e0e:9:125562)
    at invoke_vi (libapi.mjs?v=54d10e0e:9:191780)
    at libapi.wasm:0xe28c0
    at libapi.wasm:0xc70ff
    at libapi.wasm:0xe8cfc
    at ret.<computed> (libapi.mjs?v=54d10e0e:9:125562)
    at Object.doRewind (libapi.mjs?v=54d10e0e:9:126851)
    at libapi.mjs?v=54d10e0e:9:127444

Is there any reference?

@RReverser
Copy link
Collaborator

When trying to disable the viewfinder it will error:

What do you mean by disabling the viewfinder? Manually on the camera? Or somehow via the API?

@icheered
Copy link
Contributor Author

icheered commented Oct 9, 2023

Via the API. I call camera.setConfigValue() with name='viewfinder' and value='1' which raises the mirror (audible), but when calling the function again but with value='0' to lower the mirror again it will give the previously mentioned "I/O in progress" error.

This is the settings object that I retrieve from the camera:

    "name": "viewfinder",
    "info": "",
    "label": "Nikon Viewfinder",
    "readonly": false,
    "type": "toggle",
    "value": "0",
    "category": "actions"
}

@RReverser
Copy link
Collaborator

Just to be sure, are you awaiting the promise from setConfigValue before continuing?

@RReverser
Copy link
Collaborator

Basically yeah, this sounds like typical scheduling problem. That #schedule wrapper in the API should take care of it and make sure that you're not trying to lower the mirror in the middle of a frame capture. If it doesn't, then either the uiTimeout needs to be increased or there is some other ordering bug.

@RReverser
Copy link
Collaborator

not trying to lower the mirror in the middle of a frame capture

FWIW this doesn't happen in official CLI because they are not thread-safe, run in single-threaded mode and from their PoV all USB operations are blocking so can't execute concurrently in principle.

In our case it's async APIs under the hood which is why the promise queue is needed - if kinda acts like a mutex, ensuring that no operations overlap, otherwise you get the mentioned "device busy" issue.

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

No branches or pull requests

3 participants