-
-
Notifications
You must be signed in to change notification settings - Fork 99
Description
Describe the bug
I'm using librespot-java on my Android app, https://github.com/vhaudiquet/BladePlayer
Maybe i'm doing something wrong, but i tried to stay as close as possible to the librespot-android implementation.
Anyway, sometimes (it happened only 3 times in ~10 hours of development/testing this day), my app randomly crashes with this stack trace :
2022-01-07 00:09:13.980 21511-21558/v.blade W/x.g.l.c.Session: Socket timed out. Reconnecting...
2022-01-07 00:09:14.007 21511-21558/v.blade E/x.g.l.c.Session: Failed reconnecting, retrying in 10 seconds...
java.io.InterruptedIOException: thread interrupted
at com.android.okhttp.okio.Timeout.throwIfReached(Timeout.java:147)
at com.android.okhttp.okio.Okio$1.write(Okio.java:75)
at com.android.okhttp.okio.AsyncTimeout$1.write(AsyncTimeout.java:157)
at com.android.okhttp.okio.RealBufferedSink.flush(RealBufferedSink.java:222)
at com.android.okhttp.internal.http.Http1xStream.finishRequest(Http1xStream.java:163)
at com.android.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:748)
at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:622)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:475)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:411)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:248)
at xyz.gianlu.librespot.core.ApResolver.request(ApResolver.java:78)
at xyz.gianlu.librespot.core.ApResolver.refreshPool(ApResolver.java:54)
at xyz.gianlu.librespot.core.Session.reconnect(Session.java:713)
at xyz.gianlu.librespot.core.Session.access$1200(Session.java:77)
at xyz.gianlu.librespot.core.Session$Receiver.lambda$run$0$xyz-gianlu-librespot-core-Session$Receiver(Session.java:1361)
at xyz.gianlu.librespot.core.Session$Receiver$$ExternalSyntheticLambda0.run(Unknown Source:2)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
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:920)
2022-01-07 00:09:14.023 21511-21557/v.blade E/AndroidRuntime: FATAL EXCEPTION: session-packet-receiver
Process: v.blade, PID: 21511
java.lang.NullPointerException: Attempt to read from field 'java.io.DataInputStream xyz.gianlu.librespot.core.Session$ConnectionHolder.in' on a null object reference
at xyz.gianlu.librespot.core.Session$Receiver.run(Session.java:1339)
at java.lang.Thread.run(Thread.java:920)
2022-01-07 00:09:14.185 21511-21557/v.blade I/Process: Sending signal. PID: 21511 SIG: 9
There seems to be nothing from me in this stack trace, but maybe i misconfigured something in the library ? Or maybe there is a bug (race condition ? something like that ?) in librespot-java...
It always happens after a 'Socket Timed Out, reconnecting...' event, but when i try to reproduce by enabling/disabling internet connection, i can't. I don't really understand why, but again if it is a race condition there might be an explanation.
Do you have an idea of what could be causing this ?
I tried to reproduce on librespot-android but i did not really have time to reproduce it (i only left it in the background playing music for 1 hour and it did not happen, but that does not mean anything...)
Maybe i'm doing something wrong, did i forget something in the configuration that could be causing this ?
I did not really understand the use of WeakReference in your librespot-android implementation ; maybe this issue comes from that ? I tried with and without WeakReference but it seems to happen in both cases...
I'm really sorry if i'm wasting your time and the bug is on my end, and in that case if you could provide me any information that would help me fix it, i would be grateful :))
To Reproduce
I don't really know how you can reproduce that, given the 'rarity' of the event...
Version/Commit
I'm using librespot-player:1.6.2
I configure the player in here : https://github.com/vhaudiquet/BladePlayer/blob/master/app/src/main/java/v/blade/sources/spotify/SpotifyPlayer.java