finamp icon indicating copy to clipboard operation
finamp copied to clipboard

[0.9.3-beta] Wont play any media without cover art

Open wioo opened this issue 11 months ago • 29 comments

When try to play any song without cover art playback jumps to first song with a cover picture. If none such song is found nothing happens.

os: ios 16.7.5, same on android

wioo avatar Feb 28 '24 18:02 wioo

I've already implemented a fix for this, it will drop with the next beta update (maybe tomorrow?). Hang tight!

Chaphasilor avatar Feb 29 '24 01:02 Chaphasilor

Good to hear. Thank you.

wioo avatar Feb 29 '24 05:02 wioo

Just wanted to add that Android <= 11 there's a bug in the Android System UI that causes the whole finamp app to crash when trying to play a song wihout cover art, not only to do nothing. It's caused by trying to use a cover art that is too small (probably also the empty cover art).

It's also documented in the google issue tracker here: https://issuetracker.google.com/issues/278918062

nebomuk avatar Mar 15 '24 21:03 nebomuk

@nebomuk is that also happening with the stable version of Finamp?

Chaphasilor avatar Mar 15 '24 21:03 Chaphasilor

It happens both with the stable version and the latest beta release from github. I assume your changes are not merged yet, right?

The beta release I tested is this: Redesign Beta - Download Migration Fix 0.9.3-beta e1cc1887b9a34c48c4f8040369655304157a0731

nebomuk avatar Mar 16 '24 09:03 nebomuk

Yeah the beta fix isn't released yet, but I believed there was no such issue on the stable version 😅
I'll try to take a look later...

Chaphasilor avatar Mar 16 '24 10:03 Chaphasilor

@nebomuk just to confirm: this issue occurs with both versions, on Android 10 and less, when playing tracks without cover art. You're not casting (as described in the bug tracker you linked) or doing anything special.

And as far as I can tell the beta currently doesn't play songs without cover art at all, while the stable version does (it simply doesn't show a cover). But both versions crash for you when trying to play something without a cover? 🤔

Chaphasilor avatar Mar 16 '24 11:03 Chaphasilor

I tested it on stock Android 10 for both the Finamp Google Play version (stable) and the latest beta release from github. Both versions crashing when cover art is missing. I saw this stacktrace using adb when the crash happens:

java.lang.IllegalArgumentException: The given region must intersect with the Bitmap's dimensions. at androidx.palette.graphics.Palette$Builder.setRegion(Palette.java:733) at com.android.systemui.statusbar.notification.MediaNotificationProcessor.generateArtworkPaletteBuilder(MediaNotificationProcessor.java:332) ... I then found the google issue above. I'm not "casting" anything. According to the stacktrace and the google engineer's comment in the bug tracker, it seems it's not necessarily related to "casting".

nebomuk avatar Mar 16 '24 18:03 nebomuk

Okay, thanks for the info. I'll try to wire up a fallback image and will send you an APK for testing soon, since I don't have an older Android device around to test with...

Chaphasilor avatar Mar 16 '24 19:03 Chaphasilor

@nebomuk please download my build from https://gofile.io/d/n2uMbL and give it a test. It uses a modified application ID, so it will install alongside the regular version :)

Chaphasilor avatar Mar 16 '24 21:03 Chaphasilor

thanks for the test build. Unfortunately I still get the same crash with the same stack trace when trying to play something without a cover. Edit: It seems to happen only with some combination of album/file etc. with missing cover. Lots of missing cover songs seem to play just fine.

2024-03-16 22:43:38.215  8038-8229  Avrcp_ext               com.android.bluetooth                V  updateCurrentMediaState: mMediaController: MediaController (com.unicornsonlsd.finamp.test@a69e753) Red Flag, Billy Talent, Billy Talent II
2024-03-16 22:43:38.227  8038-8229  Avrcp_ext               com.android.bluetooth                V  ActiveSession: MediaController (com.unicornsonlsd.finamp.test@c4f890) Red Flag, Billy Talent, Billy Talent II
2024-03-16 22:43:38.228  8038-8229  Avrcp_ext               com.android.bluetooth                V  isBrowseSupported for com.unicornsonlsd.finamp.test: true
2024-03-16 22:43:38.229  8038-8229  Avrcp_ext               com.android.bluetooth                D  update #22:MediaPlayerInfo com.unicornsonlsd.finamp.test (as 'Finamp') Type = 1, SubType = 0, Status = 1 Feature Bits [40 41 42 44 45 47 48 58 59 62 65 67 68] Controller: MediaController (com.unicornsonlsd.finamp.test@c4f890) Red Flag, Billy Talent, Billy Talent II
2024-03-16 22:43:38.230  8038-8229  Avrcp_ext               com.android.bluetooth                D  updateCurrentController: MediaController (com.unicornsonlsd.finamp.test@a69e753) Red Flag, Billy Talent, Billy Talent II to MediaController (com.unicornsonlsd.finamp.test@c4f890) Red Flag, Billy Talent, Billy Talent II
2024-03-16 22:43:38.231  8038-8229  Avrcp_ext               com.android.bluetooth                V  updateCurrentMediaState: mMediaController: MediaController (com.unicornsonlsd.finamp.test@c4f890) Red Flag, Billy Talent, Billy Talent II
2024-03-16 22:43:38.246  8038-8229  Avrcp_ext               com.android.bluetooth                V  updateCurrentMediaState: mMediaController: MediaController (com.unicornsonlsd.finamp.test@c4f890) Red Flag, Billy Talent, Billy Talent II
2024-03-16 22:43:38.311  7562-7562  StatusBar               com.android.systemui                 E  couldn't inflate view for notification com.unicornsonlsd.finamp.test/0x464
                                                                                                    java.lang.IllegalArgumentException: The given region must intersect with the Bitmap's dimensions.
                                                                                                    	at androidx.palette.graphics.Palette$Builder.setRegion(Palette.java:734)
                                                                                                    	at com.android.systemui.statusbar.notification.MediaNotificationProcessor.generateArtworkPaletteBuilder(MediaNotificationProcessor.java:308)
                                                                                                    	at com.android.systemui.statusbar.notification.MediaNotificationProcessor.processNotification(MediaNotificationProcessor.java:123)
                                                                                                    	at com.android.systemui.statusbar.notification.row.NotificationContentInflater$AsyncInflationTask.doInBackground(NotificationContentInflater.java:903)
                                                                                                    	at com.android.systemui.statusbar.notification.row.NotificationContentInflater$AsyncInflationTask.doInBackground(NotificationContentInflater.java:836)
                                                                                                    	at android.os.AsyncTask$3.call(AsyncTask.java:378)
                                                                                                    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                                                                                                    	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
                                                                                                    	at java.lang.Thread.run(Thread.java:919)
2024-03-16 22:43:38.319 18684-18684 AndroidRuntime          com.unicornsonlsd.finamp.test        E  FATAL EXCEPTION: main
                                                                                                    Process: com.unicornsonlsd.finamp.test, PID: 18684
                                                                                                    android.app.RemoteServiceException: Bad notification(tag=null, id=1124) posted from package com.unicornsonlsd.finamp.test, crashing app(uid=10532, pid=18684): Couldn't inflate contentViewsjava.lang.IllegalArgumentException: The given region must intersect with the Bitmap's dimensions.
                                                                                                    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1946)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:107)
                                                                                                    	at android.os.Looper.loop(Looper.java:214)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:7403)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
2024-03-16 22:43:38.323  1522-4467  ActivityTaskManager     system_server                        W    Force finishing activity com.unicornsonlsd.finamp.test/com.ryanheise.audioservice.AudioServiceActivity
2024-03-16 22:43:38.337  1522-1618  ActivityManager         system_server                        I  Showing crash dialog for package com.unicornsonlsd.finamp.test u0
2024-03-16 22:43:38.824  1522-1620  ActivityTaskManager     system_server                        W  Activity top resumed state loss timeout for ActivityRecord{56bfa3 u0 com.unicornsonlsd.finamp.test/com.ryanheise.audioservice.AudioServiceActivity t59362 f}
2024-03-16 22:43:38.832  1522-1620  ActivityTaskManager     system_server                        W  Activity pause timeout for ActivityRecord{56bfa3 u0 com.unicornsonlsd.finamp.test/com.ryanheise.audioservice.AudioServiceActivity t59362 f}
2024-03-16 22:43:43.314  1522-1634  ActivityManager         system_server                        W  Process com.unicornsonlsd.finamp.test has crashed too many times: killing!
2024-03-16 22:43:43.322  1522-1634  ActivityTaskManager     system_server                        W    Force finishing activity com.unicornsonlsd.finamp.test/com.ryanheise.audioservice.AudioServiceActivity
2024-03-16 22:43:43.370  1522-1634  ActivityManager         system_server                        I  Killing 18684:com.unicornsonlsd.finamp.test/u0a532 (adj 50): crash
2024-03-16 22:43:43.384  1522-1634  ActivityManager         system_server                        V  Disconnecting binding IntentBindRecord{fde9cdf CR com.unicornsonlsd.finamp.test/com.ryanheise.audioservice.AudioService:act=android.media.browse.MediaBrowserService}: shouldUnbind=true
2024-03-16 22:43:43.385  1522-1634  ActivityManager         system_server                        V  Killing binding IntentBindRecord{fde9cdf CR com.unicornsonlsd.finamp.test/com.ryanheise.audioservice.AudioService:act=android.media.browse.MediaBrowserService}: shouldUnbind=true
2024-03-16 22:43:43.385  1522-1634  ActivityManager         system_server                        W  Scheduling restart of crashed service com.unicornsonlsd.finamp.test/com.ryanheise.audioservice.AudioService in 1000ms
2024-03-16 22:43:43.386  1522-1634  ActivityManager         system_server                        V  Bringing down ServiceRecord{afec100 u0 com.unicornsonlsd.finamp.test/com.ryanheise.audioser

nebomuk avatar Mar 16 '24 21:03 nebomuk

That's a bummer. Is that also happening with other media apps, like Symfonium or the regular Jellyfin app?

Chaphasilor avatar Mar 16 '24 21:03 Chaphasilor

image Ok here's the result. About 10% of the "missing album cover items" don't receive the correct "album cover missing placeholder icon" (green arrow) and instead are displayed with icon completely absent (red arrow). Since the placeholder icon is not there, this then apparently still triggers the Android 10 "notification without album cover crash" bug.

These file start to play fine for a few seconds even though the app then immediately crashes with an ANR dialog.

nebomuk avatar Mar 16 '24 21:03 nebomuk

That's a bummer. Is that also happening with other media apps, like Symfonium or the regular Jellyfin app?

No, in the regular Jellyfin app these albums and files play just fine.

nebomuk avatar Mar 16 '24 22:03 nebomuk

Interesting. So the files that have the disc icon shown work with the version I sent you, just the others do not?

I believe the one without the icon next to them actually are supposed to have a cover, but it can't be loaded from the server, which would also explain the delay.

Chaphasilor avatar Mar 16 '24 22:03 Chaphasilor

Interesting. So the files that have the disc icon shown work with the version I sent you, just the others do not?

I believe the one without the icon next to them actually are supposed to have a cover, but it can't be loaded from the server, which would also explain the delay.

Exactly. The apk you sent me can now at now play the files with the disc icon. I compared it to the previous version and the previous one was still crashing on the disc icon items. I didn't look at the implementation, but as a last resort fallback to work around the crash on Android 10, maybe it's better to set a transparent mini drawable on the list item when the cover art received from the server is "null".

nebomuk avatar Mar 16 '24 22:03 nebomuk

Okay, here's a new version: https://gofile.io/d/RycCxN
This one probably won't solve the problem, but has some additional logging. So please do the following:

  1. Create a playlist with one or two tracks that work, followed by some tracks with the placeholder CD image, and some with just the blank space
  2. Start playing the playlist
  3. Export the logs and send them to me

Hopefully this tells me a bit more about what's going on. If you can figure out anything that's different about the tracks with the blank space in the Jellyfin web UI, that would also be very helpful! Right now I cannot recreate the issue locally, which makes testing cumbersome...

Chaphasilor avatar Mar 17 '24 22:03 Chaphasilor

logfile.txt

Thanks. I created a playlist like described above. Like expected, the first 2 songs played fine, the third song with the blank space then caused the crash with ANR with the same exception like before.

Since you cannot recreate the issue locally and the log doesn't seem to helpfull, I have a better idea. Maybe you could just give me the git branch name you're currently working on and I run finamp locally in Android Studio. That way we'll get the complete stack-trace including where it originated in the app code, not only the part that happens in the android SDK code.

nebomuk avatar Mar 18 '24 10:03 nebomuk

Thanks, but the logs I was looking for were the ones from within Finamp ^^
You can find them by going to the sidebar, Logs, and then clicking the share icon at the top. Please do that after starting the playlist, but before the app crashes.

Additionally, I've pushed the redesign-fallback-cover branch to the repo, so you can give it a try yourself.

Chaphasilor avatar Mar 18 '24 10:03 Chaphasilor

finamp-logs.txt

Here's the log from finamp after starting the playlist and before the app crashed. Note that I deleted the app data before starting the app so that the log looks clean like a "fresh install"

nebomuk avatar Mar 18 '24 12:03 nebomuk

Okay, that is helpful. As I've already suspected, there is supposed to be an image on the server, but for some reason it can't be loaded. How does the playlist look in the Jellyfin Web UI?

It won't be easy to handle this case. All Finamp does is generate a URL and pass that to Android, and Android then fetches the cover and should handle errors accordingly. The only way to get around this that I see would be to cache all images locally and then pass those to Android, but that would mean thousands of downloads for long queues, so it's not really an option.
Another option might be to proxy the requests through Finamp, but that's also pretty advanced and I can't believe it would work well.

Could you maybe try and see if Symfonium is also experiencing this crash with the playlist you created?

Chaphasilor avatar Mar 18 '24 12:03 Chaphasilor

No Symphonium does not experience any crashes when playing any of the blank songs. But it looks quite similar to finamp with all 3 types of items, with album cover, with placeholder and blank. Im the webui, the playlist now also includes one album image, one placeholder and one blank.

Ok I get it, the album cover download and the generation of list items are handled by multiple layers of libraries, so it's quite possble that the unhandled exception leading to the crash occurs in some library layer that is between finamp and the android OS. I'll try to find out if there's something different about the files displayed with blanks.

nebomuk avatar Mar 18 '24 13:03 nebomuk

What is the official Jellyfin app showing as the cover for the third song? If there's no crash, then there seems to be some kind of placeholder?
I believe Symfonium cashes cover images locally, so that might be why it's working.

I'd love to figure this out, but I really don't know how this could be done in a reasonable way.

Oh, one other thing you could try: does the app crash if you download the song first? It should make no difference if you're in offline mode or not, as long as you downloaded the song.

Chaphasilor avatar Mar 18 '24 21:03 Chaphasilor

I think the official Jellyfin app is just a webview, so everything looks and behaves identical to running it in a Android webbrowser or even on a desktop computer. In the jellyfin app, the songs with the blank space in any browser (android or desktop) are also shown with a blank space in the app. I haven't tried everything you mentioned yet.

  • I just found out that by disabling notifications for finamp on the Android OS level, even the problematic songs play just fine. This confirms that the bug is most likely related to the media notification.

  • I couldn't find any difference between the mp3 files that display a cover and those with a blank space at least by looking at the id3 tags.

  • After some googling, it seems the bug might be caused by images with 0 size but not null images.

  • I was also digging through the source code and was wondering if there's a simple way to only disable the album art on the notification while keeping the rest of the foreground notification unchanged.

nebomuk avatar Mar 19 '24 08:03 nebomuk

Sorry for not responding, I was a bit stressed. What I was interested in with the Jellyfin app was how the cover looked in the media notification. Is it just blank, or is there some kind of placeholder?
The difference between the songs with missing and with broken cover is also most likely not to be found in the id3 tags, but in Jellyfin itself. It might be worth taking a look at your browser's dev tools, and in the network tab take a look at what fields are included in the BaseItemDtos returned by Jellyfin when you load the playlist. Let me know if you need specific instructions.

We could definitely disable the covers completely, but I'm not sure if that's a valid solution. Since there should be a cover, but it fails to load, we cannot tell which covers will work and which won't, so we really would need to disable all covers. That could be a setting, but honestly would be pretty whack.

Chaphasilor avatar Mar 23 '24 15:03 Chaphasilor

I tested the official Jellyfin app again, and the behaviour is actually a bit more complex:

  • When playing the "blank space" or the "disc placeholder" items from the playlist, no notification appears, but the audio continues to play.
  • When playing the "album working" item from the playlist, the notification appears. When playing the "disc placeholder"-item afterwards, the previous album drawable keeps stuck in the notification.
  • when playing the "blank space"-item when the notification is there, the Android System UI process crashes, restarts, and then it's possible to continue to play the "blank space" item, although without notification.

TL;DR; official app also causes a crash on "blank space" songs, but differently

I looked at the REST request's responses that are received on the playlist page in the official jellyfin webui on a desktop machine's browser. image Actually I couldn't find the BaseItemDtos. But I noticed that the "disc placeholder"-item got an empty "ImageTags": {}, field, but the "blank space" item got a "ImageTags" field with ID, similar to the item where the image loaded successfully.

nebomuk avatar Mar 23 '24 21:03 nebomuk

@wioo this has been fixed with beta 0.9.5, please give it a try :)

@nebomuk how many of these items to you have? It seems like the cover image somehow got corrupted or deleted from the file system, that's why it isn't working. I think you should fix up your media files to work around this issue.
Items should either have a cover that loads correctly, or no cover at all...

Chaphasilor avatar Apr 08 '24 19:04 Chaphasilor

I can confirm that all songs play without a problem. Thank you.

wioo avatar Apr 08 '24 19:04 wioo

how many of these items to you have? It seems like the cover image somehow got corrupted or deleted from the file system, that's why it isn't working. I think you should fix up your media files to work around this issue. Items should either have a cover that loads correctly, or no cover at all...

About every tenth album. I think i found the cause. The affected albums contain album art placeholder .jpg files that are quite small, e.g. 75x75 and 200x200 and are completely black. These files are not corrupted but jellyfin somehow seems to choke on them. I'll try to find out what music management app creates these kind of placeholders.

nebomuk avatar Apr 08 '24 20:04 nebomuk

Since this seems to be a Jellyfin issue, I'll close this now. Feel free to share any insights though!

Chaphasilor avatar May 17 '24 22:05 Chaphasilor