After I suspend and wake my PC, the bluetooth tray icon vanishes and I'm unable to browse devices/send files over bluetooth. Programs that use BT directly, like smartcam and obexfs are not affected. Reproducible: Always * package version(s) bluedevil 1.3-1 libbluedevil 1.9.2-1 bluez 4.101-1 KDE 4.9.5-1 $ lsusb Bus 003 Device 002: ID 0a5c:2121 Broadcom Corp. BCM2210 Bluetooth
please help
does it help restarting bluetooth service? Can you give me the output of qdbus --system org.bluez ? Thanks and sorry for the delay on answering
> does it help restarting bluetooth service? Yes > Can you give me the output of qdbus --system org.bluez ? $ qdbus --system org.bluez / /org /org/bluez /org/bluez/404 /org/bluez/404/any /org/bluez/404/hci0 /org/bluez/404/hci0/dev_A8_7E_33_D7_29_DB /org/bluez/test
In Archlinux I can reproduce this, will investigate and fix. thanks for the report !
Can you reproduce this all the time? I have been trying to reproduce this today and so far no luck.
Yes.
Can you attach the following information? Go into a termnial and do: killall -9 kded4; sleep 5; kded4 --nofork > /tmp/kded4.txt Then wait a few seconds, suspend, resume (to reproduce the problem) and attach the kded4.txt Thanks !
Created attachment 77916 [details] x actually, it prints to stderr
Oh indeed, can you add stderr too please?
it is stderr ^
Oh then, open "debugdialog", enable everything with the word "KDED" on it, and try again. You are missing a lot of debug info, for example KDED saying "loading module bluedevil".
What debugdialog ? Don't find this command in $PATH or in Desktop search
Created attachment 77917 [details] kded4-5.txt never mind, found it. See the attached file
Created attachment 77921 [details] Usa usableAdapter instead of default Sometimes BlueZ won't emit "defaultAdapterChange", it never worked 100% perfect and it has been removed in BlueZ5... So instead of it use "usableAdapter", which do not relay on BlueZ and should work just fine.
Haven't test the patch, but should fix the issue, can you test it please?
The bluetooth icon now reappears after suspend, but "browse files" doesn't work as before, until I restart the bluetooth service or relogin.
Created attachment 77922 [details] kded4-9.txt: browse files, suspend, then try browse again
Same patch could be almost applied to browse files, will do some testing and push the patch.
Git commit 61e35f00d7f571166ff9a5139a74b510af279c5e by Àlex Fiestas. Committed on 10/03/2013 at 23:07. Pushed by afiestas into branch 'master'. Added missing emit defaultChanged M +1 -0 bluedevil/bluedevilmanager.cpp http://commits.kde.org/libbluedevil/61e35f00d7f571166ff9a5139a74b510af279c5e
That should fix this, anyway I will switch to usableAdapter in most of the places.
Git commit 52bd6afb50e70171d99f792f70dd4542ac0a056f by Àlex Fiestas. Committed on 10/03/2013 at 23:36. Pushed by afiestas into branch 'master'. Use usableAdapter instead of defaultAdapter defaultAdapter has been removed from BlueZ5 because it was problematic, we had our share of problems with it so we implemented usableAdapter which basically does what defaultAdapter does but additionally checks isPowered. M +2 -2 src/actionplugins/audio/helper/audiohelper.cpp M +2 -2 src/actionplugins/input/helper/inputhelper.cpp M +2 -2 src/actionplugins/networkdun/helper/networkdunhelper.cpp M +2 -2 src/actionplugins/networkpanu/helper/networkpanuhelper.cpp M +7 -7 src/actionplugins/sendfile/helper/discoverwidget.cpp M +1 -1 src/actionplugins/sendfile/helper/pages/connectingpage.cpp M +3 -3 src/actionplugins/sendfile/helper/sendfilewizard.cpp M +1 -1 src/daemon/helpers/authorize/authorize.cpp M +1 -1 src/daemon/helpers/filereceiver/openobex/serversession.cpp M +3 -3 src/daemon/helpers/filereceiver/service.cpp M +10 -10 src/daemon/kded/BlueDevilDaemon.cpp M +1 -1 src/daemon/kded/BlueDevilDaemon.h M +4 -4 src/daemon/kded/bluezagent.cpp M +4 -4 src/daemon/obexftpkded/ObexFtpDaemon.cpp M +1 -1 src/daemon/obexftpkded/ObexFtpDaemon.h M +2 -2 src/fileitemactionplugin/sendfileitemaction.cpp M +8 -8 src/kcmodule/bluedeviladapters.cpp M +1 -1 src/kcmodule/bluedeviladapters.h M +14 -14 src/kcmodule/bluedevildevices.cpp M +1 -1 src/kcmodule/bluedevildevices.h M +6 -6 src/kcmodule/bluedeviltransfer.cpp M +1 -1 src/kcmodule/bluedeviltransfer.h M +5 -5 src/kcmodule/systemcheck.cpp M +2 -2 src/kio/bluetooth/kiobluetooth.cpp M +0 -2 src/kio/bluetooth/kiobluetooth.h M +16 -16 src/monolithic/monolithic.cpp M +1 -1 src/wizard/bluewizard.cpp M +7 -7 src/wizard/pages/discoverpage.cpp M +1 -1 src/wizard/pages/fail.cpp M +1 -1 src/wizard/pages/keyboardpairing.cpp M +1 -1 src/wizard/pages/legacypairing.cpp M +1 -1 src/wizard/pages/legacypairingdatabase.cpp M +2 -2 src/wizard/pages/nopairing.cpp M +1 -1 src/wizard/pages/servicespage.cpp M +3 -3 src/wizard/pages/ssppairing.cpp http://commits.kde.org/bluedevil/52bd6afb50e70171d99f792f70dd4542ac0a056f
Created attachment 77937 [details] kded4-12.txt: suspend multiple times Applied your patches. The icon now vanishes after ~3 suspends. See attached file.
Same problem with git head
Damn it... I can see another problem in your log, I kind of know how to fix it, working on it.
Created attachment 77940 [details] Clean the object on unregistered, emit changed on initialize and added some debug
This patch cleans the object and emits defaultChanged and usableChanged when initialize is called again, we where missing both things though the later I suspect is the one causing the problems. Please, test again and let's see if we fixed it for good this time !
Created attachment 77945 [details] kded4-17.txt Applied your patch to libbluetooth. It didn't help. I don't see the new messages in kded4 output. See the attached file.
Ok, so at least the Daemon seems to be working fine and the double "Added" or "Removed" events we were getting before are gone (the patch works). Now the problem seems to be only in monolithic (the thing that appears in the systray), you can check in the log "it probably crashed". Going to try to reproduce and cook a patch.
Git commit 8559a0d2436da9792611a6bf9446b8a58fe55917 by Àlex Fiestas. Committed on 11/03/2013 at 12:03. Pushed by afiestas into branch 'master'. Emit defaultAdapterChanged and usableAdapterChanged on initialize After all this is the first time they change, from 0 to * M +3 -0 bluedevil/bluedevilmanager.cpp http://commits.kde.org/libbluedevil/8559a0d2436da9792611a6bf9446b8a58fe55917
Git commit 19792c0085ed11c877e34d268b51c576b80215ef by Àlex Fiestas. Committed on 11/03/2013 at 12:02. Pushed by afiestas into branch 'master'. Properly clean the object when the service is unregistered M +21 -17 bluedevil/bluedevilmanager.cpp http://commits.kde.org/libbluedevil/19792c0085ed11c877e34d268b51c576b80215ef
should I try yet?
Try updating both, bluedevil and libbluedevil.
Created attachment 77947 [details] kded4-21.txt > bluedevilmonolithic(19846): Communication problem with "bluedevilmonolithic" , it probably crashed. It's still there
Created attachment 77955 [details] output process info
Same deal, compile (bluedevil this time) with the applied patch, restart kded, reproduce add info. This time the patch only adds some more debug. I have an idea of how to fix this, but provide the info just to be sure.
Additionally you can try to reproduce this with the branch: betterMonolithicHandling let's se if we are lucky :p
Created attachment 77960 [details] kded4-25.txt: with the process.txt patch
Should kded4 now print anything if I kill bluedevil-monolithic ? Well it doesn't.
Ups, forgot to push some debugs, can you try again? Thanks for all the testing btw.
Created attachment 77964 [details] kded4-29.txt Switched to betterMonolithicHandling. No problem with the icon after 7 suspends.
Created attachment 77965 [details] kded4-30.txt icon vanish again Nope, the problem's still there
Update libbluedevil and try again (314c139e701d5619d8990638202f9593cbe9a6fb). Thanks for all the feedback.
Created attachment 78053 [details] kded4-32.txt
It could be a bug in or misuse of KUniqueApplication. What do you think?
Is bluedevil-monolithic supposed to restart on resume?
> Is bluedevil-monolithic supposed to restart on resume? OK, I see where it's killed. Now, although bluedevil-monolithic is started, BlueDevilDaemon::monolithicStarted() is not called. I added kDebug() there and also set breakpoints with gdb. The flag m_monolithicStarted is never set.
I'm not a QT fan, but my tests show that: - the started() and finished(int) events only work with QProcess::start(), not startDetached() - For in-stack QProcess variables the finished(int) event is called on function return, not when the subprocess really dies
Hehe you are completely right, gonna push the change.
Git commit af6b207ab400c713d5b33ce3a35d9684f7c98d64 by Àlex Fiestas. Committed on 15/03/2013 at 01:52. Pushed by afiestas into branch 'betterMonolithicHandling'. Proper usage of QProcess if we intend to use the signals Use QProcess:start instead of detached, also move to QProcess instead of KProcess since we do not need any of the things provided by the later M +9 -6 src/daemon/kded/BlueDevilDaemon.cpp M +1 -1 src/daemon/kded/BlueDevilDaemon.h http://commits.kde.org/bluedevil/af6b207ab400c713d5b33ce3a35d9684f7c98d64
Because bluedevil-monolithic goes to background, BlueDevilDaemon::finished triggers immediately. Both BlueDevilDaemon::finished() and BlueDevilDaemon::monolithicQuit() were added in the same commit. monolithicQuit() is triggered on d-bus reply. I suspect that after processing the "quit" message bluedevil-monolithic is still registered in dbus for some time and will prevent another instance. So this watcher is probably not needed. If it's true, bluedevil-monolithic needs a flag to run in foreground.
Wait for my patch
Created attachment 78090 [details] 0001-more-fixes-in-BlueDevilDaemon-monolithic.patch This is for branch betterMonolithicHandling. But don't push it yet: I got an advice to use QDBusServiceWatcher. This way we can wait for the monolithic process launched elsewhere and probably the implementation will be simpler
Oks, if not probably next week I will have time to look into this and fix it for once, as you can see in the timestamps I'm doing it late at night before sleep so I'm not putting any thought on it :p Thanks for all the feedback, really appreciated.
Created attachment 78093 [details] 0001-BlueDevilDaemon-monolithic-fix-race-condition-use-QD.patch This patch applies to master. It uses QDBusServiceWatcher to launch monolithik when the service is unregistered. It's simpler than using QProcess signals, I reverted to startDetached(). The new branch called betterMonolithicHandling2. Compare: $ git diff --stat master betterMonolithicHandling src/daemon/kded/BlueDevilDaemon.cpp | 94 src/daemon/kded/BlueDevilDaemon.h | 9 2 files changed, 92 insertions(+), 11 deletions(-) $ git diff --stat master betterMonolithicHandling2 src/daemon/kded/BlueDevilDaemon.cpp | 64 src/daemon/kded/BlueDevilDaemon.h | 5 2 files changed, 58 insertions(+), 11 deletions(-)
Created attachment 78094 [details] kded4-41-QDBusServiceWatcher.txt The "it probably crashed" message is there, but now it's not fatal. We could avoid it with some flag variables, but it would make it complex.
Created attachment 78124 [details] kded4-50.txt Today BlueDevilDaemon didn't return to online mode after suspend, see the attached log. I guess bluedevilmanager found it not usable
Git commit 8d771c35f2b4f0e0f3ee7ebcf156d461a2dd5eb3 by Àlex Fiestas, on behalf of Ilya Basin. Committed on 15/03/2013 at 10:51. Pushed by afiestas into branch 'master'. BlueDevilDaemon/monolithic fix race condition, use QDBusServiceWatcher M +53 -11 src/daemon/kded/BlueDevilDaemon.cpp M +5 -0 src/daemon/kded/BlueDevilDaemon.h http://commits.kde.org/bluedevil/8d771c35f2b4f0e0f3ee7ebcf156d461a2dd5eb3
Last mode change in the log is to online, can't it be again monolithic not getting executed ? This week I will have time to deep test this and try to fix it once for all. Thanks for everything, really appreciated !
Created attachment 78213 [details] kded4-52.txt > can't it be again monolithic not getting executed ? It's bluedevilmanager. I added more logging there. Today it happened again. According to the log, after wake _k_adapterRemoved() was called twice with "/org/bluez/426/hci0", then _k_adapterAdded() was called with the parameter "/org/bluez/426/hci0", then it called findUsableAdapter() and it returned NULL, so the server remained in offline mode. grep -i "monolith\|bluedevil\|powerdevil" /tmp/kded4-51.txt > /tmp/kded4-52.txt
m_adaptersHash could not be empty. So the only reason is it wasn't powered. But plain obex programs work now, so it is powered.
Created attachment 78220 [details] adding some debug
The other explanation will be that the service is still detected as offline so Manager::Adapters will return an empty list. Add the debug in the last attached patch, if this is confirmed and our logic is correct then we'll have to workaround this in deviceAdded.
Created attachment 78254 [details] bluedevil-monolithic-20130321-095003.kcrash Today monolithic crashed in Monolithic::onlineMode(), because Manager::self()->usableAdapter() returned NULL
service.patch> "qDebug()" It's hard to grep for it. Do you know how to workaround the lack of kDebug ? I added this: #define myDebug() qDebug() << Q_FUNC_INFO << ": " but I don't know how to add the process name and pid, like "kded(586) ..."
I got the proof. At first _k_adapterAdded() called, only then the property "Powered" is set to true: void BlueDevil::Manager::Private::_k_adapterAdded(const QDBusObjectPath&) : Added: "/org/bluez/412/hci0" void BlueDevil::Manager::Private::_k_adapterAdded(const QDBusObjectPath&) : !m_usableAdapter BlueDevil::Adapter* BlueDevil::Manager::Private::findUsableAdapter() : BlueDevil::Adapter* BlueDevil::Manager::Private::findUsableAdapter() : defAdapter = 0x2724110 void BlueDevil::Adapter::Private::fetchProperties() : this = 0x2839bf0 m_powered = false BlueDevil::Adapter* BlueDevil::Manager::Private::findUsableAdapter() : defAdapter->isPowered = false QList<BlueDevil::Adapter*> BlueDevil::Manager::adapters() const : QList<BlueDevil::Adapter*> BlueDevil::Manager::adapters() const : return d->m_adaptersHash.values() BlueDevil::Adapter* BlueDevil::Manager::Private::findUsableAdapter() : adapter = 0x2724110 BlueDevil::Adapter* BlueDevil::Manager::Private::findUsableAdapter() : adapter->isPowered() = false BlueDevil::Adapter* BlueDevil::Manager::Private::findUsableAdapter() : return 0 void BlueDevil::Manager::Private::_k_adapterAdded(const QDBusObjectPath&) : m_usableAdapter = 0x0 void BlueDevil::Manager::Private::_k_adapterAdded(const QDBusObjectPath&) : m_oldUsableAdapter = 0x0 void BlueDevil::Adapter::Private::_k_propertyChanged(const QString&, const QDBusVariant&) : this = 0x2839bf0 "UUIDs" = "" void BlueDevil::Adapter::Private::_k_propertyChanged(const QString&, const QDBusVariant&) : this = 0x2839bf0 "Pairable" = "true" void BlueDevil::Adapter::Private::_k_propertyChanged(const QString&, const QDBusVariant&) : this = 0x2839bf0 "Powered" = "true" void BlueDevil::Adapter::Private::_k_propertyChanged(const QString&, const QDBusVariant&) : this = 0x2839bf0 m_powered = true void BlueDevil::Adapter::Private::_k_propertyChanged(const QString&, const QDBusVariant&) : this = 0x2839bf0 "Pairable" = "true" void BlueDevil::Adapter::Private::_k_propertyChanged(const QString&, const QDBusVariant&) : this = 0x2839bf0 "Discoverable" = "true"
Git commit 0fa1e2bebe56c0409e8911537da0502b671b6ff2 by Àlex Fiestas. Committed on 24/03/2013 at 18:12. Pushed by afiestas into branch 'master'. On Adapter::poweredChanged, check if we need to modify usableAdapter One of the things we do in usableAdapter is check if the adapter is powered, if it is not then we consider the adapter not usable. It happens that an adaptor is added but it is not powered so we discaard it as an usableAdapter. When that happens we have to make sure that we are listening to "poweredChanged" and check if usableAdapter should be changed when that happens (an adapter has become powered, use it in case we do not have any usableAdapter). this whole usableAdapter thing is a mess we have to revise for 2.0 M +30 -0 bluedevil/bluedevilmanager.cpp M +1 -0 bluedevil/bluedevilmanager.h http://commits.kde.org/libbluedevil/0fa1e2bebe56c0409e8911537da0502b671b6ff2
Git commit 014cc0b890a8232f44fc6f231bb01b86cbaafb62 by Àlex Fiestas. Committed on 24/03/2013 at 17:32. Pushed by afiestas into branch 'master'. Check if there is an usable adapter before going to onlineMode An adapter can be added but it might no be usable (not powered) so we have to be certain that there is an usableAdapter before going into onlineMode. In the future We should connect only to usableAdapterChanged to make the code waay simpler, but since we are close to release let's not modify too much code. M +1 -1 src/monolithic/monolithic.cpp http://commits.kde.org/bluedevil/014cc0b890a8232f44fc6f231bb01b86cbaafb62
I think there's a leak of Adapter objects. I put qDebug into its constructor and destructor and after several suspends the constructor was called 10 times and the destructor only 4 times. Of course, some objects wasn't destroyed at monolithic termination; it's normal. But according to logs there was this case inside one monolithic instance: Adapter 1 is created in Manager::Private::initialize(). It has powered = true Later is called _k_adapterPoweredChanged(false) and sets m_defaultAdapter = 0 Later findUsableAdapter() calls defaultAdapter() that creates Adapter 2, because m_defaultAdapter == 0; Adapter 1 still exists, but not in the list anymore _k_adapterRemoved() is called and destroys Adapter 2 Then findUsableAdapter() calls defaultAdapter() that creates Adapter 3 Then _k_adapterAdded() is called and creates Adapter 4 Then Adapter 1 _k_propertyChanged() is called with "Powered" = "true" In the end we have Adapter 4 in the list and Adaper 1 and 3 lost. One question: why set m_defaultAdapter = 0 in _k_adapterPoweredChanged?
Git commit 47bc8b9bce111e901aae6aba23a32d9828a4988e by Àlex Fiestas. Committed on 05/04/2013 at 18:39. Pushed by afiestas into branch 'master'. Avoid creating Adapter objects for dbusPath that we already have M +6 -1 bluedevil/bluedevilmanager.cpp http://commits.kde.org/libbluedevil/47bc8b9bce111e901aae6aba23a32d9828a4988e
Indeed we were not checking if we already had an adapter for that dbusPath. is the bug gone with the latest patch (014cc0b890a82) ?
I think m_bluezManagerInterface->DefaultAdapter() should be used only during init and after that manager should rely only on events. This way after _k_adapterRemoved() the call to Manager::defaultAdapter() will return NULL which is correct.
Created attachment 78671 [details] 0001-don-t-touch-m_defaultAdapter-on-adapterPoweredChange.patch
Sorry for the huge delay replying to the bug :/ Going to check if the patch make sense and if it should be applied in 2.0 branch as well. Will release new point releases if needed, thanks !
Can you check this patch as well? http://bugsfiles.kde.org/attachment.cgi?id=84736
Please give me some time to remember. I haven't used that PC for a while.
Bluetooth on KDE 4.14.2 is always on after suspend, even though I set it to off beforehand.
Git commit 38f78cae2e67562bb40640a87d9f34f8e1a4f200 by David Rosca. Committed on 15/11/2014 at 09:58. Pushed by drosca into branch 'master'. Restore adapter powered state after wakeup from suspend M +45 -1 src/daemon/kded/BlueDevilDaemon.cpp M +2 -0 src/daemon/kded/BlueDevilDaemon.h http://commits.kde.org/bluedevil/38f78cae2e67562bb40640a87d9f34f8e1a4f200