icefields / Power-Ampache-2

Android Music Streaming App suite in Material You style.
 Connects to Ampache, Nextcloud Music and compatible backends (Ampache API 4 and above).
https://power.ampache.dev
GNU General Public License v3.0
73 stars 5 forks source link

On Download, serialized data passed to the Worker exceedes the max size allowed (Solution: only pass songId instead of full object) #24

Closed lachlan-00 closed 6 months ago

lachlan-00 commented 8 months ago

I think this one would be limiting the length of the url. Which is good because 3300 song ids would definitely be too long to send

Screenshot_20240131_171322_ConnectBot.jpg

icefields commented 8 months ago

what caused this issue exactly? Would be great if I could reproduce it.

icefields commented 8 months ago

Beside the steps, I also need to know what happens next. Does the app crash? Does it skip one download and finished the others or the download process is completely stopped? I created a playlist of 41k songs and started downloading, I didn't experience this bug (so far, still downloading), any help fixing this issue is appreciated.

lachlan-00 commented 8 months ago

Looks fixed from 0.08 onwards

icefields commented 8 months ago

I'm going to reopen this, from the crash trace I received yesterday night looks like it's still happening silently and that's what causing issues with downloads, at least from what I see in the logs. Anyway, the bug is not with the url, it's with the serialized "Song" object I pass from the download-worker to the main thread, apparently some times that object exceeds the max size allowed for passing object between threads. I will implement a fix today, I'm going to pass the songId only instead of the full object, the worker can then retrieve the song object by itself instead of passing big serialized objects around.

"java.lang.IllegalStateException: Data cannot occupy more than 10240 bytes when serialized\n\tat androidx.work.Data.toByteArrayInternal(Data.java:404)\n\tat androidx.work.Data$Builder.build(Data.java:941)\n\tat androidx.work.OverwritingInputMerger.merge(OverwritingInputMerger.kt:32)\n\tat androidx.work.impl.WorkerWrapper.runWorker(WorkerWrapper.java:224)\n\tat androidx.work.impl.WorkerWrapper.run(WorkerWrapper.java:144)\n\tat androidx.work.impl.utils.SerialExecutorImpl$Task.run(SerialExecutorImpl.java:96)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)\n\tat java.lang.Thread.run(Thread.java:1012)\n"



lachlan-00 commented 8 months ago

I see downloads are not crashing the app but some songs will not download and stop the process.

I've tested a few times on my lists. 4-8 songs usually and then a stop. Could that error be a cause too?

Will this error show up on Android studio if i load in there?

icefields commented 8 months ago

That issue should have been fixed on 0.10-beta. If you're on that version then the problem doesn't seem to be solved, and I'll look into it again. Make sure you're on 0.10-beta , the other day I released 3 versions in a day, very easy lo lose track.

The log won't who show if you connect to android studio because the exception is caught without outputting any log on production releases. But you could go to Settings and enable remote logging and I will get a log of the exception.

lachlan-00 commented 8 months ago

cool, i've done that, that will save me having to ask a lot more questions

for the download it actually looks like its working as i get a log for it each attempts to download image

the url shows up in access logs and will download in a browser. maybe the anon logs will show more.

Refreshed the list to get a new list of songs and the download restarts. so it seems to stick on random songs for some reason