After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 786821 - Could not claim the USB device (-53)
Could not claim the USB device (-53)
Status: RESOLVED OBSOLETE
Product: shotwell
Classification: Other
Component: camera
0.22.x
Other Linux
: Normal normal
: ---
Assigned To: Shotwell Maintainers
Shotwell Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-08-25 22:21 UTC by JOSEPH CONNER
Modified: 2019-01-25 16:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Error message (93 bytes, text/plain)
2017-08-25 22:21 UTC, JOSEPH CONNER
  Details
fix for "could not claim USB device (-53)" problem (1.20 KB, patch)
2017-11-01 13:58 UTC, Richard B. Kreckel
none Details | Review
Fix unmounting devices on MTP conflict (1.68 KB, patch)
2017-11-08 14:36 UTC, Jens Georg
committed Details | Review

Description JOSEPH CONNER 2017-08-25 22:21:22 UTC
Created attachment 358453 [details]
Error message

Ubuntu Linux 17.04 64 bit, Camera: Canon PowerShot SX120IS,

Unable to fetch previews from the camera:
Could not claim the USB device (-53)

Occasionally but not always,connecting the camera and turning on the viewer launches Shotwell. When Shotwell launches, occasionally but not always, the camera icon is visible in the left hand pane. 

Shotwell and the camera should always be launched and connected whenever the camera is connected by usb to the computer when power for the camera is turned on.
Comment 1 Jens Georg 2017-08-26 09:01:20 UTC
You could try with 0.27.0 from https://launchpad.net/~yg-jensge/+archive/ubuntu/shotwell-unstable - that should  have a fix for it, but also has a nasty data corruption issue.
Comment 3 JOSEPH CONNER 2017-08-28 19:40:28 UTC
What additional information may I provide? If you walk me through anything in particular I will attempt to explore this with you.
Comment 4 Jens Georg 2017-08-29 06:33:45 UTC
For now, please check version 0.27.0. The reason for this is pretty clear, 0.27.0 (or git master) should have a work-around
Comment 5 JOSEPH CONNER 2017-09-15 22:30:24 UTC
I attempted to install 0.27.0. Unfortunately, I could find only source code, but not DEB files which I would need. I am not knowledgable enough to compile the source code.

I finally purchased an Ercrysto Card Reader +HUB which solved my download issues. 

If you can provide me a link to DEB files for 0.27.0 then I will give it a try.

Blessings, Joe Conner, Poulsbo, WA USA
Comment 7 richw@richw.org 2017-09-24 05:46:03 UTC
Before I try shotwell-unstable, could I ask for more details about the "nasty data corruption issue"?  I hope you'll understand my hesitation here.
Comment 8 richw@richw.org 2017-09-24 06:27:41 UTC
I was brave / daring / reckless just now and tried shotwell-unstable (0.27.0) on my Ubuntu 16.04.3 LTS system.  When I tried to import photos from a Samsung Galaxy S5 phone, Shotwell just hung "forever", saying it was "Starting import, please wait", but without actually importing anything.
Comment 9 Jens Georg 2017-10-03 18:16:38 UTC
Did you enable any transfer mode on your phone? I get this behavior when plugging in to USB and the phone is in charge-only mode
Comment 10 richw@richw.org 2017-10-03 18:25:00 UTC
The phone asked if I wanted to allow or deny access to its data.  I allowed access, but Shotwell hung forever without importing anything.
Comment 11 Jens Georg 2017-10-07 06:36:47 UTC
If you run gphoto2 -L, do you get anything back?
Comment 12 richw@richw.org 2017-10-07 15:35:48 UTC
$ gphoto2 -L
                                                                               
*** Error ***              
An error occurred in the io-library ('Could not claim the USB device'): Could not claim interface 0 (Device or resource busy). Make sure no other program (gvfs-gphoto2-volume-monitor) or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device.
*** Error (-53: 'Could not claim the USB device') ***       

For debugging messages, please use the --debug option.
Debugging messages may help finding a solution to your problem.
If you intend to send any error or debug messages to the gphoto
developer mailing list <gphoto-devel@lists.sourceforge.net>, please run
gphoto2 as follows:

    env LANG=C gphoto2 --debug --debug-logfile=my-logfile.txt -L

Please make sure there is sufficient quoting around the arguments.

$
Comment 13 Richard B. Kreckel 2017-10-26 20:55:36 UTC
FWIW, the patch from 0.27.0 in the ImportPage.refresh_camera() doesn't solve the problem on my Aquaris M4.5 Android device. Also, I get the same error as reported above by richw@richw.org when invoking gphoto2.
Comment 14 Richard B. Kreckel 2017-10-27 20:40:10 UTC
As it is, the error message tells the user that shotwell was unable to claim the USB device, and nothing more. Whatever that means to the user. The workaround to unmount the volume from the file manager doesn't occur to most of them.

A more explicit error dialog for error -53 would greatly improve the user experience. The one from gphoto2 could serve as inspiration. What about "Could not claim the USB device (-53). Make sure no other program is using the device and that it is not mounted."
Comment 15 richw@richw.org 2017-10-28 04:02:14 UTC
The camera, I assume, is getting mounted automatically when it is plugged in.  But even if I unmount the camera, I'm still unable to get Shotwell to connect to the camera.  I tried this just now, and I got an error box saying this:

Shotwell
Unable to fetch previews from the camera:
Unspecified error (-1)

The only way I've been able to upload photos lately has been to copy the JPG files from the camera to the computer's hard drive, then use Shotwell's "Import from Folder" function on the hard drive copies.  This is unreasonably complicated for an ordinary user to be expected to have to do.

Uploading from a camera used to work, a long time ago, but it's broken now.  My dear, 95-year-old mother (who really doesn't understand the difference between Linux and Windows) is still running Ubuntu 12.04, on which Shotwell can be made to work with some coaxing from me.  I really want to upgrade her to a new Ubuntu version with support, but I don't dare do so now because it would break Shotwell and leave her asking me if she needs a new computer. :-(
Comment 16 Jens Georg 2017-10-28 08:30:37 UTC
Which desktop are you on? It works perfectly fine on 17.10 with GNOME with all of my PTP/MTP devices.
Comment 17 Richard B. Kreckel 2017-10-28 09:41:37 UTC
(In reply to Richard B. Kreckel from comment #13)
> FWIW, the patch from 0.27.0 in the ImportPage.refresh_camera() doesn't solve
> the problem on my Aquaris M4.5 Android device. Also, I get the same error as
> reported above by richw@richw.org when invoking gphoto2.

For the record: This was on Debian stretch (stable) running Gnome 3.22.2.
Comment 18 Jens Georg 2017-10-28 09:49:56 UTC
Are you able to talk to the device with gphoto2 if no desktop session is running?
Comment 19 richw@richw.org 2017-10-28 16:36:39 UTC
I'm running Ubuntu 16.04.3 LTS with MATE.

My phone is a Samsung Galaxy S5 running Android 6.0.1.

I can try other desktop session options in a few days' time, once a long-running xterm job is done.  However, switching from MATE to a different desktop is not an acceptable long-term strategy for me.
Comment 20 richw@richw.org 2017-10-31 06:24:45 UTC
I tried running Shotwell using the Unity desktop, and the result was exactly the same -- same errors as with the MATE desktop.
Comment 21 Richard B. Kreckel 2017-10-31 22:43:15 UTC
(In reply to Jens Georg from comment #18)
> Are you able to talk to the device with gphoto2 if no desktop session is running?

Yes, I can get a complete file listing with gphoto2 -L from the device if no desktop session is running.

Also, I can talk to the device with gphoto2 after unmounting it from the desktop session.

OTOH, if a desktop session is running, I get error -53: 'Could not claim the USB device. And if a desktop session of another user is running (which has mounted the device), I get a plain error -7: 'I/O problem'.

(Again, this is on Debian stretch (stable) running Gnome 3.22.2.)
Comment 22 Jens Georg 2017-11-01 08:36:33 UTC
That's an interesting difference in behavior. Additionally, I don't understand why shotwell doesn't prompt the user to unmount; that probably needs some more investigation. 

richw: The issue was more to check when there is NO desktop running at all; It might be that the two issues are different and GPhoto is not able to talk to your device at all, while Richard's device is just blocked by gvfs.
Comment 23 Richard B. Kreckel 2017-11-01 12:55:19 UTC
(In reply to Jens Georg from comment #22)
> That's an interesting difference in behavior. Additionally, I don't
> understand why shotwell doesn't prompt the user to unmount; that probably
> needs some more investigation.

Ah! In method ImportPage.try_refreshing_camera(fail_on_locked=true), variable RefreshResult has value 1==BUSY, as returned by ImportPage.refresh_camera(). But the BUSY case does not prompt the user to unmount! Indeed, if I modify the program and let it go to the LOCKED case, a meaningful dialog appears.

Next problem, a few lines down: Shotwell doesn't display the "Shotwell needs to unmount the camera..." dialog but the "The camera is locked by another application" dialog. Apparently, File.find_enclosing_mount(null) has returned null. Why is this?
Comment 24 Richard B. Kreckel 2017-11-01 13:26:25 UTC
(In reply to Richard B. Kreckel from comment #23)
> Next problem, a few lines down: Shotwell doesn't display the "Shotwell needs
> to unmount the camera..." dialog but the "The camera is locked by another
> application" dialog. Apparently, File.find_enclosing_mount(null) has
> returned null. Why is this?

The uri of find_enclosing_mount() is "gphoto2://[usb:005,017]/". But, according to gvfs-mount -l, it should be "mtp://[usb:005,017]/". Indeed, if I replace "gphoto2" with "mtp" when I create File uri, shotwell can unmount the camera and access all photos on it.
Comment 25 Jens Georg 2017-11-01 13:28:57 UTC
Do you know where the gphoto2 is coming from?
Comment 26 Richard B. Kreckel 2017-11-01 13:49:01 UTC
(In reply to Jens Georg from comment #25)
> Do you know where the gphoto2 is coming from?

From method CameraTable.get_port_uri(string port) in src/camera/CameraTable.vala:1004.
Comment 27 Richard B. Kreckel 2017-11-01 13:58:04 UTC
Created attachment 362746 [details] [review]
fix for "could not claim USB device (-53)" problem

I can confirm that the attached patch fixes the problem for me. I don't understand enough of gvfs to be sure it is correct, though.
Comment 28 Jens Georg 2017-11-01 15:12:47 UTC
Ah! I think your device is blocked by gvfs-mtp-volume-monitor, not gvfs-gphoto2-volume-monitor.
Comment 29 Richard B. Kreckel 2017-11-01 16:45:26 UTC
(In reply to Jens Georg from comment #28)
> Ah! I think your device is blocked by gvfs-mtp-volume-monitor, not
> gvfs-gphoto2-volume-monitor.

Seems so. Both processes are running. A more flexible fix is needed, then?
Comment 30 Richard B. Kreckel 2017-11-01 20:50:09 UTC
(In reply to Richard B. Kreckel from comment #27)
> I can confirm that the attached patch fixes the problem for me.

For the record: That patch works on Debian stable (9.1) and on current Debian testing (buster/sid).
Comment 31 Jens Georg 2017-11-02 12:10:29 UTC
richw@richw.org, can you please also check gvfs-mount -l ?
Comment 32 richw@richw.org 2017-11-02 14:46:55 UTC
I connected my phone.  I got a prompt on the phone to deny or allow access to device data; I chose "allow".

A Caja window (remember, I'm using the MATE desktop) appeared for the phone, showing two top-level items, "Card" and "Phone".

"gvfs-mount -l" at this point returned no output and exit status 0.

Not sure if this detail is relevant or not, but I've configured my phone's camera app to store photos on an SD card, due to limitations in the phone's own memory.
Comment 33 richw@richw.org 2017-11-02 18:27:44 UTC
I successfully imported photos to Shotwell from my Samsung tablet (where the photos are stored in the device's own memory, not in a card).

I will try switching my phone's camera app to store photos directly in the camera's memory, rather than on a card, and see if that makes a difference.  However, I would hope it's not unreasonably hard to make Shotwell capable of looking for photos on a card -- for some users/devices, there may not be a viable alternative.
Comment 34 Jens Georg 2017-11-02 19:27:05 UTC
I still think there is some problem of gphoto2 communicating with the aquarius. I can check if we have that device available at work as one of our test devices, but I don't have high hopes that I can find one.
Comment 35 Richard B. Kreckel 2017-11-05 14:39:29 UTC
(In reply to Jens Georg from comment #34)
> I still think there is some problem of gphoto2 communicating with the
> aquarius. I can check if we have that device available at work as one of our
> test devices, but I don't have high hopes that I can find one.

Oh, I thought I was chasing a general problem.
For the record:
* Gphoto2 doesn't do anything special with the Aquaris M4.5, it calls LibUSB's libusb_claim_interface function.
* LibUSB doesn't doe anything special either. The ioctl(fd, IOCTL_USBFS_CLAIMINTF, &iface) in claim_interface() fails (file linux_usbfs.c:1416) with EBUSY on the Aquaris M4.5, but apparently not on other devices. Weird.

Anyway, since it works fine when the phone is unmounted, can Shotwell's error message please be improved? "Could not claim the USB device (-53)" is just irritating. Some hint at unmounting it from the file manager would be nice. (The diagnostic message of gphoto2 includes such a hint, and this is helpful.)
Comment 36 Jens Georg 2017-11-06 21:41:59 UTC
Oh, sorry, I mixed up the phones.
Comment 37 Jens Georg 2017-11-08 14:36:44 UTC
Created attachment 363222 [details] [review]
Fix unmounting devices on MTP conflict

Apparently there are devices that are occupied bz the MTP volume
monitor. Fix unmounting those cameras as well
Comment 38 Jens Georg 2017-11-08 14:38:30 UTC
Can you please test this patch? I assume it should fix  Richard B. Kreckel's problem.
Comment 39 Richard B. Kreckel 2017-11-08 23:01:24 UTC
(In reply to Jens Georg from comment #38)
> Can you please test this patch? I assume it should fix  Richard B. Kreckel's
> problem.

Tested the patch: Yes, it does solve my problem with the Aquaris M4.5.
Comment 40 Jens Georg 2017-11-09 11:36:38 UTC
Attachment 363222 [details] pushed as 4d4041a - Fix unmounting devices on MTP conflict
Comment 41 richw@richw.org 2017-11-28 07:17:29 UTC
I'm running Shotwell 0.27.1, on an Ubuntu 16.04 LTS system, installed via the Ubuntu PPA.

Shotwell still will not talk to my Samsung Galaxy S5 phone.

I connected the phone, and I responded to an "allow access to device data" prompt on the phone by touching "allow".  Shotwell recognizes the phone (under "Cameras") as "SAMSUNG_Android".  It says "Connecting to camera, please wait...", but nothing more happens, even after several minutes.
Comment 42 richw@richw.org 2017-11-28 07:25:31 UTC
I've tried the above with both the phone (device) and the memory card as the picture storage location, but Shotwell can't find the photos either way.

Unlike what happened earlier, with 0.27.1 I'm not getting any of the confusing (and, to a novice, likely incomprehensible) error boxes about not being able to "claim USB device".  But it's still not working.

I can work around this issue, to be sure, by copying photos from the phone to /tmp and then doing an "import from folder" operation, but I trust you'll understand why I'm unwilling to accept this as a real solution.
Comment 43 richw@richw.org 2017-12-23 04:00:18 UTC
Hi.  Any more word on this issue?
Comment 44 Jens Georg 2017-12-23 11:16:14 UTC
Can you please check whether or not the camera is accessible by gphoto2 -L when you do not boot into any desktop environment?
Comment 45 richw@richw.org 2018-01-08 03:21:04 UTC
I recently upgraded my phone from a Samsung Galaxy S5 running Android 6 ("Marshmallow") to a Samsung Galaxy S8 running Android 7 ("Nougat").

When I connected my new phone to my Ubuntu 16.04 LTS desktop and launched Shotwell 0.27.2, I got a message asking for permission to unmount the phone's file system in order for Shotwell to continue.  I said yes, and Shotwell successfully downloaded the photos on the phone.

So, for me, the problem appears to be solved.  Whether this is because of my new phone, or because I am now running Shotwell 0.27.2 (instead of 0.27.1), I can't tell.  I still have my old phone and may try experimenting with it if I have time.