Bug 393274

Summary: Android app crashes when multimedia player plugin is enabled
Product: [Applications] kdeconnect Reporter: Kishore Gopalakrishnan <kishore96>
Component: android-applicationAssignee: Albert Vaca Cintora <albertvaka>
Status: RESOLVED FIXED    
Severity: normal CC: matthijstijink
Priority: NOR    
Version: 1.8   
Target Milestone: ---   
Platform: Android   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Output of 'abd logcat' during such a crash

Description Kishore Gopalakrishnan 2018-04-19 02:09:55 UTC
The android application crashes regularly if the 'multimedia player' plugin is enabled. When this happens, I get an option to 'send feedback' (I tried this once), but I don't know how to access those crash logs directly. On my Android device, I am using the latest version on the Play Store (1.8.2); my laptop's version of kdeconnect is 1.3 

After kdeconnect crashes, the persistent notification it sends gets stuck in the notification area. This is on a Moto G4 running Android 7.0. I couldn't find any errrors in the logs on my laptop too. I'm not sure what other information might be relevant, so feel free to ask for more.
Comment 1 Kishore Gopalakrishnan 2018-04-19 02:11:15 UTC
I forgot to mention in my previous comment that, as far as I can tell, there are no issues when I disable the 'multimedia control' plugin.
Comment 2 Albert Vaca Cintora 2018-04-29 21:47:50 UTC
Checking the crash reports on the Play Store, I found a ClassCastException on the following cast in AlbumArtCache.java:

connection = (HttpURLConnection) currentUrl.openConnection();

This crash is actually quite common, with 300 crashes in the past 7 days.

I'm not sure what's the cause though. The only other subclass of URLConnection that can come from openConnection() is JarUrlConnection:

https://developer.android.com/reference/java/net/URLConnection

But I don't think we can get a JarUrlConnection there. I was trying to reproduce the crash to see what kind of URLConnection we are getting there, but it doesn't seem to crash on me.

What media player are you using?
Comment 3 Kishore Gopalakrishnan 2018-04-30 00:57:54 UTC
(In reply to Albert Vaca from comment #2)
> What media player are you using?

I'm using the qt5 branch of Clementine (https://aur.archlinux.org/packages/clementine-qt5-git/). I'll try to reproduce it with some other player, soon.
Comment 4 Kishore Gopalakrishnan 2018-04-30 01:09:59 UTC
Okay, this is really weird. I can't reproduce it any more. Tested with Clementine and Rhythmbox. I haven't changed the versions of kdeconnect (on my phone and laptop) or Clementine.
Comment 5 Kishore Gopalakrishnan 2018-04-30 06:17:48 UTC
I've been able to reproduce it again. It seems to crash only if the song I'm playing has album art associated with it. This is with Clementine.
Comment 6 Matthijs Tijink 2018-04-30 18:11:42 UTC
I looked into it and couldn't find a definite answer. Maybe you could test my suggested change?

You can download an Android apk at https://phabricator.kde.org/D12618
Can you try to install this and see if the app still crashes? You might get prompted to first remove the currently installed KDE Connect app.

In case it doesn't work, it would be great if you could upload a log (connect your phone by usb and run "adb logcat" on the command line, then wait for the app to crash).
Comment 7 Kishore Gopalakrishnan 2018-05-01 01:12:46 UTC
Created attachment 112335 [details]
Output of 'abd logcat' during such a crash

(In reply to Matthijs Tijink from comment #6)
> I looked into it and couldn't find a definite answer. Maybe you could test
> my suggested change?
> 
> You can download an Android apk at https://phabricator.kde.org/D12618
> Can you try to install this and see if the app still crashes? You might get
> prompted to first remove the currently installed KDE Connect app.
> 
> In case it doesn't work, it would be great if you could upload a log
> (connect your phone by usb and run "adb logcat" on the command line, then
> wait for the app to crash).

The new apk you linked at that Phabricator page works. 

I have also attached the output of 'adb logcat' during a crash, while using the version in the Play Store. I paired the devices with kdeconnect, enabled USB debugging, opened kdeconnect, and then started the command. I immediately went to my music player on my computer and played a music file with album art. After that, I got a message that kdeconnect crashed (on my phone), and I ended the 'adb logcat' command.
Comment 8 Matthijs Tijink 2018-05-11 13:16:17 UTC
Fixed on master, needs a release.

@Albert: could you create a release including this fix?