Bug 412255 - Unable to Import photos from camera
Summary: Unable to Import photos from camera
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Import-Gphoto2 (show other bugs)
Version: 6.3.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-23 18:46 UTC by hamelg
Modified: 2023-07-23 16:49 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In: 8.1.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description hamelg 2019-09-23 18:46:37 UTC
STEPS TO REPRODUCE
1. Connect my smartphone via usb
2. Launch digikam
3. select Import


OBSERVED RESULT

The GUI shows this error :

Failed to connect to the camera. Please make sure it is connected properly and turned on.

In the console, digikam displays theses errors :

digikam.general: Found camera from ids  8888   11894  camera is:  "Motorola Moto G (ID1)"  at  "usb:001,024"
digikam.geoiface: "setting backend marble"
digikam.general: Audio output backends: ("OpenAL", "Pulse", "null")
digikam.general: Number of supported audio codecs: 186
digikam.general: Number of supported video codecs: 259
digikam.geoiface: "ROADMAP"
digikam.geoiface: "setting backend marble"
QLayout: Attempting to add QLayout "" to Digikam::DNGConvertSettings "", which already has a layout
digikam.geoiface: "ROADMAP"
QFSFileEngine::open: No file name specified
digikam.import: Log ( ""   "" :  "Connecting to camera..."
digikam.import: Failed to initialize camera!
digikam.import: Libgphoto2 error:  Could not claim the USB device  ( -53 )
digikam.import: Log ( ""   "" :  "Connection failed."
digikam.geoiface: ----

EXPECTED RESULT
Digikam shows all the photos stored in my smartphone and allows me to import them.

SOFTWARE/OS VERSIONS
Digikam 6.3.0
KDE Frameworks 5.62.0
Qt 5.13.1 (built against 5.13.1)
The xcb windowing system

ADDITIONAL INFORMATION
I got the same error when using directly gphoto2 :

$ 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') ***  


When tracing gphoto2, I see it fails when it is trying to open the device file :
strace -e file gphoto2 --list-files
openat(AT_FDCWD, "/dev/bus/usb/001/024", O_RDWR|O_CLOEXEC) = 9

In fact, this file is already in use by kiod5 :

$ lsof /dev/bus/usb/001/024
COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME
kiod5   99742 azertx   19u   CHR 189,23      0t0 499545 /dev/bus/usb/001/024

Systemd is launching this process as soon as I plug my phone via usb.

● dbus.service - D-Bus User Message Bus
   Loaded: loaded (/usr/lib/systemd/user/dbus.service; static; vendor preset: enabled)
   Active: active (running) since Mon 2019-09-23 19:35:54 CEST; 55min ago
     Docs: man:dbus-daemon(1)
 Main PID: 33057 (dbus-daemon)
   CGroup: /user.slice/user-2230.slice/user@2230.service/dbus.service
           ├─33057 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --syst>
           ├─33117 /usr/bin/kglobalaccel5
           ├─33130 /usr/lib/dconf-service
           ├─33249 /usr/lib/kactivitymanagerd
           ├─33395 /usr/lib/kf5/kscreen_backend_launcher
           └─99742 /usr/lib/kf5/kiod5

The workaround is to kill kiod5 to free the device. After that, I can import photo from digikam/gphoto2.
Comment 1 Maik Qualmann 2019-09-23 19:24:51 UTC
The problem is known to me. If I try to open the phone with Dolphin before, digiKam can not access it anymore. Because a GPhoto2 instance of the KIOslave driver is already using it. Honestly, we can not do anything here. We will not support KIO for reasons of portability. The KIO module would have to release the interface quickly when it is not in use. The bug report might be better for the KIO driver as for digiKam.

Maik
Comment 3 pbhj 2019-10-31 21:08:08 UTC
This works for me in Kubuntu 19.04 using Digikam 5.9.0.

The error read:

"Libgphoto2 error:  Could not claim the USB device"

`sudo killall kiod5` enabled digikam to run properly; it worked on 18.10 prior to update to 19.04 (but I think there was also a digikam update, maybe from 5.8, in there too).
Comment 4 hamelg 2019-11-04 20:58:15 UTC
I use this small script to automate the workaround:
===
#!/bin/bash

usbaddr=`gphoto2 --auto-detect | grep -Po 'usb:[^ ]+' | sed 's/usb://;s|,|/|'`
[ -n "$usbaddr" ] && fuser -k -TERM /dev/bus/usb/$usbaddr
exec /usr/bin/digikam "$@"
Comment 5 Maik Qualmann 2020-06-23 17:55:18 UTC
*** Bug 423392 has been marked as a duplicate of this bug. ***
Comment 6 caulier.gilles 2020-07-31 12:53:42 UTC
digiKam 7.0.0 stable release is now published:

https://www.digikam.org/news/2020-07-19-7.0.0_release_announcement/

We need a fresh feedback on this file using this version.

Best Regards

Gilles Caulier
Comment 7 Pussy Boots 2020-12-20 03:12:17 UTC
I confirm this bug happens with digikam 7.1.0.

I think however is a KDE bug or in any event an upstream bug.

See:

https://bugs.kde.org/show_bug.cgi?id=412257

I hope it gets solved soon
Comment 8 caulier.gilles 2023-05-01 03:25:58 UTC
@hamelg@laposte.net

digiKam 8.0.0 is out. This entry still valid with this release ?

Best regards

Gilles Caulier
Comment 9 hamelg 2023-05-01 19:06:17 UTC
I confirm it just works now with 8.0. The workaround is no more needed.
Thanks much, good job !