Steps to reproduce: 1) Connect android phone, while having Amarok opened 2) Try to mount MTP "Android" device in Dolphin 3) See "MTP died unexpectedly" Reproducibility: 100%. Moment Amarok is closed, Dolphine works flawlessly.
Confirmed with Amarok MTP plugin enabled. As a workaround, disabling Amarok MTP plugin makes dolphing MTP work again. Unfortunately, MTP has been built to only allow a single operation at a time (for example, read, write or delete operation), while no other operation can be executed until the previous operation is complete. The message of the dolphin MTP operation should be better than "MTP died unexpectedly".
Jamie, yep, that is the point - it took a while for me to figure out that amarok is the culprit which blocks MTP. Dolphin should check for amarok, then ask user if user wants to disable amarok MTP plugin instead of just saying that it was unable to mount MTP device.
It's not just Amarok. Open two dolphin processes and you will get the same crash.
Moving to kio-extras. The mtp ioslave should use a kded plugin to globally handle the MTP operations, so that different processes will be able to use mtp concurrently.
Git commit 0cc17f0c1b91969d2e7dd5722086abc8b5105db9 by Jaime Torres. Committed on 21/07/2018 at 09:58. Pushed by jtamate into branch 'master'. Avoid a kio-mtp crash when trying to add a blocked device to the device cache Summary: When the device is blocked, for example by amarok mtp plugin, the result of LIBMTP_Open_Raw_Device_Uncached(rawDevice) is nullptr and LIBMTP_Get_Friendlyname(nullptr) crashes. Avoid to create a cache for a device that can't be opened. Test Plan: With Amarok started and its mtp plugin enabled, plug in an android device. Try to open it with dolphin, always the same kio backtrace: ``` ==13233== Invalid read of size 8 ==13233== at 0x1087ABCE: LIBMTP_Get_Friendlyname (in /usr/lib64/libmtp.so.9.4.0) ==13233== by 0x105EE67C: CachedDevice::CachedDevice(LIBMTP_mtpdevice_struct*, LIBMTP_raw_device_struct*, QString, int) (devicecache.cpp:44) ==13233== by 0x105F0A30: DeviceCache::checkDevice(Solid::Device) (devicecache.cpp:150) ==13233== by 0x105F1517: DeviceCache::DeviceCache(int, QObject*) (devicecache.cpp:94) ==13233== by 0x105F2FC1: MTPSlave::MTPSlave(QByteArray const&, QByteArray const&) (kio_mtp.cpp:70) ==13233== by 0x105F8BF9: kdemain (kio_mtp.cpp:54) ==13233== by 0x4016CC: main (kioslave.cpp:130) ==13233== Address 0x8 is not stack'd, malloc'd or (recently) free'd ``` And in dolphin, the message: MTP died unexpectedly After, the message: The file or folder udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1 does not exist. Reviewers: #frameworks, elvisangelaccio Reviewed By: elvisangelaccio Subscribers: broulik Differential Revision: https://phabricator.kde.org/D14158 M +1 -1 mtp/devicecache.cpp https://commits.kde.org/kio-extras/0cc17f0c1b91969d2e7dd5722086abc8b5105db9
*** Bug 383628 has been marked as a duplicate of this bug. ***
Git commit 6010d09233e5bb7a00606c44a2fbe5898ecc36e0 by Elvis Angelaccio, on behalf of Jaime Torres. Committed on 16/08/2018 at 08:58. Pushed by elvisangelaccio into branch 'Applications/18.08'. Avoid a kio-mtp crash when trying to add a blocked device to the device cache Summary: When the device is blocked, for example by amarok mtp plugin, the result of LIBMTP_Open_Raw_Device_Uncached(rawDevice) is nullptr and LIBMTP_Get_Friendlyname(nullptr) crashes. Avoid to create a cache for a device that can't be opened. Test Plan: With Amarok started and its mtp plugin enabled, plug in an android device. Try to open it with dolphin, always the same kio backtrace: ``` ==13233== Invalid read of size 8 ==13233== at 0x1087ABCE: LIBMTP_Get_Friendlyname (in /usr/lib64/libmtp.so.9.4.0) ==13233== by 0x105EE67C: CachedDevice::CachedDevice(LIBMTP_mtpdevice_struct*, LIBMTP_raw_device_struct*, QString, int) (devicecache.cpp:44) ==13233== by 0x105F0A30: DeviceCache::checkDevice(Solid::Device) (devicecache.cpp:150) ==13233== by 0x105F1517: DeviceCache::DeviceCache(int, QObject*) (devicecache.cpp:94) ==13233== by 0x105F2FC1: MTPSlave::MTPSlave(QByteArray const&, QByteArray const&) (kio_mtp.cpp:70) ==13233== by 0x105F8BF9: kdemain (kio_mtp.cpp:54) ==13233== by 0x4016CC: main (kioslave.cpp:130) ==13233== Address 0x8 is not stack'd, malloc'd or (recently) free'd ``` And in dolphin, the message: MTP died unexpectedly After, the message: The file or folder udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1 does not exist. Reviewers: #frameworks, elvisangelaccio Reviewed By: elvisangelaccio Subscribers: broulik Differential Revision: https://phabricator.kde.org/D14158 M +1 -1 mtp/devicecache.cpp https://commits.kde.org/kio-extras/6010d09233e5bb7a00606c44a2fbe5898ecc36e0
*** Bug 383317 has been marked as a duplicate of this bug. ***
There is a workaround for this problem: use only one dolphin window (tabs are your friends!) to copy/move files to/from your phone. Everything else won't work: - you cannot copy MTP files from dolphin to the desktop. - you cannot open e.g. a PDF file from the MTP folder; copy it somewhere else first. - you cannot open Amarok and dolphin at the same time. - etc. etc.
*** Bug 379680 has been marked as a duplicate of this bug. ***
*** Bug 375840 has been marked as a duplicate of this bug. ***
*** Bug 356084 has been marked as a duplicate of this bug. ***
*** Bug 336399 has been marked as a duplicate of this bug. ***
*** Bug 350384 has been marked as a duplicate of this bug. ***
*** Bug 331682 has been marked as a duplicate of this bug. ***
*** Bug 325629 has been marked as a duplicate of this bug. ***
*** Bug 396271 has been marked as a duplicate of this bug. ***
*** Bug 359112 has been marked as a duplicate of this bug. ***
*** Bug 398989 has been marked as a duplicate of this bug. ***
(In reply to Elvis Angelaccio from comment #19) > *** Bug 398989 has been marked as a duplicate of this bug. *** To me as a user I don't think that this is a duplicate of bug 398989. In my case neither dolphin nor amarok is running. The workaround doesn't work for me (comment 9).
(In reply to Attila from comment #20) > The workaround doesn't work for me (comment 9). Please make sure you have only *one* mtp.so process in ksysguard.
(In reply to Elvis Angelaccio from comment #21) > (In reply to Attila from comment #20) > > The workaround doesn't work for me (comment 9). > > Please make sure you have only *one* mtp.so process in ksysguard. The "mtp" process is not running. Neither before I plug in the phone nor when the phone is conneted.
Git commit aaa1edbb74c4fb01affbde7b79bb45d3a9b61f83 by Andreas Krutzler. Committed on 08/10/2018 at 17:39. Pushed by akrutzler into branch 'master'. [mtp] Move MTP device handling from kioslave to kiod-module Summary: Consult T9390 for more information. Related: bug 319880, bug 325924, bug 336456, bug 372860, bug 382046, bug 383314 Closes T9390 Reviewers: elvisangelaccio, ltoscano, hetzenecker, dfaure, mlaurent Reviewed By: elvisangelaccio, dfaure, mlaurent Subscribers: mlaurent, kde-frameworks-devel, kfm-devel Tags: #dolphin, #frameworks Maniphest Tasks: T9390 Differential Revision: https://phabricator.kde.org/D15277 M +5 -5 mtp/CMakeLists.txt D +0 -229 mtp/devicecache.cpp D +0 -86 mtp/devicecache.h D +0 -73 mtp/filecache.cpp D +0 -81 mtp/filecache.h M +483 -576 mtp/kio_mtp.cpp M +14 -8 mtp/kio_mtp.h D +0 -358 mtp/kio_mtp_helpers.cpp D +0 -46 mtp/kio_mtp_helpers.h A +19 -0 mtp/kiod_module/CMakeLists.txt A +171 -0 mtp/kiod_module/kmtpd.cpp [License: GPL (v2+)] A +63 -0 mtp/kiod_module/kmtpd.h [License: GPL (v2+)] A +12 -0 mtp/kiod_module/kmtpd.json A +127 -0 mtp/kiod_module/mtpdevice.cpp [License: GPL (v2+)] A +78 -0 mtp/kiod_module/mtpdevice.h [License: GPL (v2+)] A +635 -0 mtp/kiod_module/mtpstorage.cpp [License: GPL (v2+)] A +142 -0 mtp/kiod_module/mtpstorage.h [License: GPL (v2+)] A +21 -0 mtp/shared/CMakeLists.txt A +70 -0 mtp/shared/kmtpdeviceinterface.cpp [License: LGPL] A +64 -0 mtp/shared/kmtpdeviceinterface.h [License: LGPL] A +85 -0 mtp/shared/kmtpdinterface.cpp [License: LGPL] A +70 -0 mtp/shared/kmtpdinterface.h [License: LGPL] A +147 -0 mtp/shared/kmtpfile.cpp [License: LGPL] A +90 -0 mtp/shared/kmtpfile.h [License: LGPL] A +98 -0 mtp/shared/kmtpstorageinterface.cpp [License: LGPL] A +77 -0 mtp/shared/kmtpstorageinterface.h [License: LGPL] A +50 -0 mtp/shared/org.kde.kmtp.daemon.xml A +62 -0 mtp/shared/org.kde.kmtp.device.xml A +154 -0 mtp/shared/org.kde.kmtp.storage.xml https://commits.kde.org/kio-extras/aaa1edbb74c4fb01affbde7b79bb45d3a9b61f83
*** Bug 363593 has been marked as a duplicate of this bug. ***
*** Bug 401235 has been marked as a duplicate of this bug. ***
*** Bug 403198 has been marked as a duplicate of this bug. ***
*** Bug 404087 has been marked as a duplicate of this bug. ***