Bug 392594 - KDE Connect crashes after establishing connection
Summary: KDE Connect crashes after establishing connection
Status: RESOLVED WORKSFORME
Alias: None
Product: kdeconnect
Classification: Applications
Component: android-application (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Albert Vaca Cintora
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-01 06:57 UTC by Mykola Krachkovsky
Modified: 2020-01-18 11:45 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
adb logcat (487.46 KB, text/plain)
2018-04-08 17:50 UTC, Mykola Krachkovsky
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mykola Krachkovsky 2018-04-01 06:57:28 UTC
Several latest Android versions (including current) can't connect properly to PC with KDE Plasma. When android app connected to pc, its icon is shown in Plasma, but android app crashes and icon in Plasma hidden. I've tried to reinstall application (both stable and beta versions), query for connection made fine, but again after approving from Plasma it begins to crash again every time on connecting.

Firewall has allowing rules for KDE Connect and switching off doesn't change the behaviour.

Android device: ASUS Fonepad Note 6, Android 4.4.2 (no option to upgrade), Intel Atom Z2580 CPU.

I've also tried to cancel link on both sides and make new connection, but that has no noticeable effect.
Comment 1 Matthijs Tijink 2018-04-07 08:54:00 UTC
Can you post a log of the crash? You can do this by running "adb logcat > log.txt" from the command line, while your device is plugged in your desktop.
Comment 2 Aleix Pol 2018-04-08 14:30:33 UTC
Please provide the information Matthijs requested.
Comment 3 Mykola Krachkovsky 2018-04-08 17:50:53 UTC
Created attachment 111904 [details]
adb logcat

Sure, here it is.
Comment 4 Mykola Krachkovsky 2018-04-08 19:52:41 UTC
I should've changed status to reopened, right?
Comment 5 Matthijs Tijink 2018-04-09 16:55:01 UTC
Unfortunately, I can't reproduce the issue myself.

If you open https://phabricator.kde.org/D12073 however, I tried to create a fix. Could you download and install the APK and report back if that fixes the issue? You may be prompted to first remove the old app.
Comment 6 Mykola Krachkovsky 2018-04-10 10:18:23 UTC
Hmm. Crashes anyway, I'll try to see logcat later.
Comment 7 Mykola Krachkovsky 2018-04-10 17:34:50 UTC
Exception looks similar:

E/AndroidRuntime(12161): FATAL EXCEPTION: Thread-22405
E/AndroidRuntime(12161): Process: org.kde.kdeconnect_tp, PID: 12161
E/AndroidRuntime(12161): java.lang.ExceptionInInitializerError
E/AndroidRuntime(12161):        at org.kde.kdeconnect.Plugins.RemoteKeyboardPlugin.RemoteKeyboardPlugin.onCreate(RemoteKeyboardPlugin.java:123)
E/AndroidRuntime(12161):        at org.kde.kdeconnect.Device.addPlugin(Device.java:741)
E/AndroidRuntime(12161):        at org.kde.kdeconnect.Device.reloadPluginsFromSettings(Device.java:830)
E/AndroidRuntime(12161):        at org.kde.kdeconnect.Device.addLink(Device.java:516)
E/AndroidRuntime(12161):        at org.kde.kdeconnect.BackgroundService$5.onConnectionReceived(BackgroundService.java:192)
E/AndroidRuntime(12161):        at org.kde.kdeconnect.Backends.BaseLinkProvider.connectionAccepted(BaseLinkProvider.java:48)
E/AndroidRuntime(12161):        at org.kde.kdeconnect.Backends.LanBackend.LanLinkProvider.addLink(LanLinkProvider.java:315)
E/AndroidRuntime(12161):        at org.kde.kdeconnect.Backends.LanBackend.LanLinkProvider.access$100(LanLinkProvider.java:70)
E/AndroidRuntime(12161):        at org.kde.kdeconnect.Backends.LanBackend.LanLinkProvider$3.handshakeCompleted(LanLinkProvider.java:247)
E/AndroidRuntime(12161):        at com.android.org.conscrypt.OpenSSLSocketImpl.notifyHandshakeCompletedListeners(OpenSSLSocketImpl.java:582)
E/AndroidRuntime(12161):        at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:444)
E/AndroidRuntime(12161):        at org.kde.kdeconnect.Backends.LanBackend.LanLinkProvider$4.run(LanLinkProvider.java:267)
E/AndroidRuntime(12161):        at java.lang.Thread.run(Thread.java:841)
E/AndroidRuntime(12161): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
E/AndroidRuntime(12161):        at android.os.Handler.<init>(Handler.java:200)
E/AndroidRuntime(12161):        at android.os.Handler.<init>(Handler.java:114)
E/AndroidRuntime(12161):        at android.inputmethodservice.InputMethodService.<clinit>(InputMethodService.java:315)
E/AndroidRuntime(12161):        ... 13 more


As you can't reproduce, I'll try to debug it on my side. Are sources [1] and Android Studio are enough for build/debug?

[1] https://cgit.kde.org/kdeconnect-android.git/
Comment 8 Matthijs Tijink 2018-04-10 17:50:17 UTC
Yeah, looks identical. It'd be great if you could debug this, or at least provide the full backtrace!

Android Studio and the code should indeed be enough (it'll prompt you to install SDK components, but those should be clear enough).
Comment 9 Mykola Krachkovsky 2018-04-10 18:55:07 UTC
Ok, so what I've found, problem seems is in calling of some of static initializers of RemoteKeyboardService or its super classes (InputMethodService?). This static initializer works fine if first access to class is made from gui thread (and fails when from non-gui). Adding nothing doing log to MainActivity:

Log.d("MainActivity", "Current RemoteKeyboardPlugin instance: " + RemoteKeyboardService.instance);

Fixes future call and everything seems works fine after that.
Sounds crazy. It looks like some bug of Android 4.4 to me. I'm not sure how to fix it properly, calling log looks too hacky.

I've tried to access InputMethodService.BACK_DISPOSITION_DEFAULT but that hadn't effect.

I'm not sure about static initializers, but couldn't find anything else.
Comment 10 Mykola Krachkovsky 2018-04-10 19:08:15 UTC
Opps, missed this from my logs, static initializer, clinit:
E/AndroidRuntime(12161):        at android.inputmethodservice.InputMethodService.<clinit>(InputMethodService.java:315)

And call to InputMethodService.BACK_DISPOSITION_DEFAULT (I suppose) was just optimized out, as that's a final static field.
Comment 11 Mykola Krachkovsky 2018-04-12 08:30:30 UTC
And still, that's not a full solution. When KDE Connect GUI isn't started and connection made from background thread it still crashes until GUI is opened.
Comment 12 Mykola Krachkovsky 2020-01-18 11:45:16 UTC
So, my old phone is broken and I don't use it anymore. Closing as not actual, as KDE Connect works fine on newer Androids.