Re: FILE_ADDED events getting lost

Dave Taylor <[email protected]> Tue, 6 Oct 2020 12:39:23 -0700
Newsgroups gmane.comp.multimedia.gphoto.user
Message-ID <CAL2tZyd6puow-rzh-c0HUVcTc7wuvQNm2bVpxCGjZYQz8rd33Q@mail.gmail.com>
On Tue, Oct 6, 2020 at 10:36 AM Marcus Meissner <[email protected]> wrote:
>
> On Tue, Oct 06, 2020 at 09:39:37AM -0700, Dave Taylor wrote:
> > On Mon, Oct 5, 2020 at 10:54 PM Marcus Meissner <[email protected]> wrote:
> > >
> > > Hi,
> > >
> > > - Is this libgphoto2 using libusb1 or libusb0?
> > >
> > >   If you are using libusb0, it is possible to lose USB interrupts if you are not
> > >   waiting for events actively.
> >
> > Not sure how I would find out for the version that came with Debian
> > buster.  I did an ldd on my executable, and it doesn't appear to be
> > referencing libusb as a dynamically loaded library.  How would I tell
> > which version was compiled in?
>
> gphoto2 --version
>
> will list either libusb0 or libusb1 in its output.

Thanks!  I'm seeing usb1.

> > > - just to check, you are polling with gp_camera_wait_for_event until GP_EVENT_TIMEOUT
> > >   is returned?
> > >
> > >   There might be multiple events buffered.
> >
> > Yes.  I fetch all the buffered events, and the timeout is always below
> > 10ms for each call, but the actual elapsed time for some reason can
> > vary widely.
>
> There might be waits of 150ms in the function, so a bit more coarse grained waiting
> might be better

So if I have a timeout below the time needed, say 150ms, might it
abort the event it was preparing?  Or possibly delay it until later?

I will set the timeouts to 200ms and see if reliability improves.
Thanks for the idea!

> > I never pass more than 10ms as a timeout, but it gets really slow
> > sometimes, on the order of 100ms to 1s.  I haven't correlated why/when
> > it happens yet, but when it does, I'm definitely not going to get a
> > GP_EVENT_FILE_ADDED, but this isn't the only time it happens.  It can
> > respond in normal time and still not return FILE_ADDED.
> >
> > Please let me know if there's anything I can do to help isolate the issue.
>
> Hmm. weird :/

Agreed.  I'm guessing it doesn't sound familiar to you, which tells me
maybe I'm doing something wrong on my end to upset libgphoto2?  Is
there anything I should be calling besides gp_camera_wait_for_event()
to keep libgphoto2 in a happy state while waiting for the FILE_ADDED
event to come in from an external shutter press?

        =-ddt->