gphoto / libgphoto2

The libgphoto2 camera access and control library.
GNU Lesser General Public License v2.1
1.06k stars 325 forks source link

vusb camera capture hangs forever #835

Closed RReverser closed 2 years ago

RReverser commented 2 years ago

Describe the bug

When using vusb virtual camera, capturing hangs forever, although earlier docs (e.g. https://hackweek.opensuse.org/projects/simulate-ptp-cameras-in-libgphoto2) suggest that capturing used to work.

Name the camera

(virtual camera)

libgphoto2 and gphoto2 version

gphoto2 2.5.23

Copyright (c) 2000-2019 Marcus Meissner and others

gphoto2 comes with NO WARRANTY, to the extent permitted by law. You may
redistribute copies of gphoto2 under the terms of the GNU General Public
License. For more information about these matters, see the files named COPYING.

This version of gphoto2 is using the following software versions and options:
gphoto2         2.5.23         gcc, popt(m), exif, cdk, aa, jpeg, readline
libgphoto2      2.5.30.1       standard camlibs (SKIPPING docupen lumix), gcc, no ltdl, EXIF
libgphoto2_port 0.12.1         iolibs: disk ptpip serial vusb, gcc, no ltdl, EXIF, no USB, serial without locking

To Reproduce

Build with --enable-vusb and run e.g.

gphoto2 --capture-image-and-download

Here's the debug log, looks like an internal error.

out.log

msmeissn commented 2 years ago

did you put 1 .jpg file into the vusb cameras virtual directory? i need to check if "no image" is handled well enough.

RReverser commented 2 years ago

did you put 1 .jpg file into the vusb cameras virtual directory?

Hmm, no, I didn't know it's required... Is that documented somewhere? I thought vusb just produces some hardcoded static image in that case.

i need to check if "no image" is handled well enough.

Yeah it would be useful to print a helpful error in that case.

RReverser commented 2 years ago

Interesting, I see that the code does try to report a meaningful error message, I guess it's just not printed by gphoto2 CLI?

msmeissn commented 2 years ago

The problem is more that we returned GeneralError and the ptp2 driver ignored it. I am returning a different error now.

RReverser commented 2 years ago

Linking my comments from the commit here so that they don't get lost: https://github.com/gphoto/libgphoto2/commit/cf154a3d81fcd4b6ce12c57f428c2e712607e109#r84900329

RReverser commented 2 years ago

Actually, re:

There is also one more similar code at line 1107 above that still reports PTP_RC_GeneralError.

Aren't those two copies of code doing exactly the same thing? Looks like a mistake (note section starting from 1154 and compare with one at 1136):

https://github.com/gphoto/libgphoto2/blob/a3bd587689cf13a89c99f1fe7d0c1014a046835a/libgphoto2_port/vusb/vcamera.c#L1136-L1170

RReverser commented 2 years ago

FWIW it doesn't look like changing PTP error type alone fixed the hang-up when a file is missing.

RReverser commented 2 years ago

I don't think https://github.com/gphoto/libgphoto2/commit/8b462f8c835b9d3ab0cee4117e0b0458dac00445 fixed it :/

Now seeing "Setting port timeout to 20000 milliseconds." in logs, but after that it still hangs trying "gp_port_vusb_check_int", resulting "Reading PTP event failed: Timeout reading from or writing to the port (-10)" and so on and on forever.

msmeissn commented 2 years ago

i tried with gphoto2 --capture-image and it terminates for me.

can you get a debugtrace of gphoto2 --capture-image --debug --debug-logfile=xx.log