CappielloAntonio / tempo

An open source and lightweight music client for Subsonic, designed and built natively for Android.
GNU General Public License v3.0
871 stars 39 forks source link

Replay gain crash #74

Closed C9Glax closed 9 months ago

C9Glax commented 9 months ago

Replay gain on auto

type: crash
osVersion: google/oriole/oriole:13/TQ3A.230805.001/2023090600:user/release-keys
package: com.cappielloantonio.tempo:20
process: com.cappielloantonio.tempo
processUptime: 87039 + 58 ms
installer: com.android.packageinstaller

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.get(ArrayList.java:437)
    at com.cappielloantonio.tempo.util.ReplayGainUtil.setTrackReplayGain(ReplayGainUtil.java:146)
    at com.cappielloantonio.tempo.util.ReplayGainUtil.applyReplayGain(ReplayGainUtil.java:117)
    at com.cappielloantonio.tempo.util.ReplayGainUtil.setReplayGain(ReplayGainUtil.java:28)
    at com.cappielloantonio.tempo.service.MediaService$initializePlayerListener$1.onTracksChanged(MediaService.kt:252)
    at androidx.media3.exoplayer.ExoPlayerImpl.lambda$updatePlaybackInfo$17(ExoPlayerImpl.java:2062)
    at androidx.media3.exoplayer.ExoPlayerImpl$$ExternalSyntheticLambda3.invoke(Unknown Source:4)
    at androidx.media3.common.util.ListenerSet$ListenerHolder.invoke(ListenerSet.java:339)
    at androidx.media3.common.util.ListenerSet.lambda$queueEvent$0(ListenerSet.java:223)
    at androidx.media3.common.util.ListenerSet$$ExternalSyntheticLambda1.run(Unknown Source:6)
    at androidx.media3.common.util.ListenerSet.flushEvents(ListenerSet.java:245)
    at androidx.media3.exoplayer.ExoPlayerImpl.updatePlaybackInfo(ExoPlayerImpl.java:2116)
    at androidx.media3.exoplayer.ExoPlayerImpl.removeMediaItems(ExoPlayerImpl.java:686)
    at androidx.media3.common.BasePlayer.clearMediaItems(BasePlayer.java:94)
    at androidx.media3.common.ForwardingPlayer.clearMediaItems(ForwardingPlayer.java:176)
    at androidx.media3.session.PlayerWrapper.clearMediaItems(PlayerWrapper.java:460)
    at androidx.media3.session.MediaSessionStub$$ExternalSyntheticLambda3.accept(Unknown Source:2)
    at androidx.media3.session.MediaSessionStub.lambda$sendSessionResultSuccess$0(MediaSessionStub.java:152)
    at androidx.media3.session.MediaSessionStub$$ExternalSyntheticLambda24.run(Unknown Source:2)
    at androidx.media3.session.MediaSessionStub.lambda$sendSessionResultSuccess$1(MediaSessionStub.java:161)
    at androidx.media3.session.MediaSessionStub$$ExternalSyntheticLambda17.run(Unknown Source:2)
    at androidx.media3.session.MediaSessionStub.lambda$queueSessionTaskWithPlayerCommand$13(MediaSessionStub.java:323)
    at androidx.media3.session.MediaSessionStub$$ExternalSyntheticLambda46.run(Unknown Source:8)
    at androidx.media3.session.ConnectedControllersManager.lambda$flushCommandQueue$2$androidx-media3-session-ConnectedControllersManager(ConnectedControllersManager.java:277)
    at androidx.media3.session.ConnectedControllersManager$$ExternalSyntheticLambda1.run(Unknown Source:10)
    at androidx.media3.session.MediaSessionImpl.lambda$callWithControllerForCurrentRequestSet$3$androidx-media3-session-MediaSessionImpl(MediaSessionImpl.java:273)
    at androidx.media3.session.MediaSessionImpl$$ExternalSyntheticLambda12.run(Unknown Source:6)
    at androidx.media3.common.util.Util.postOrRun(Util.java:662)
    at androidx.media3.session.ConnectedControllersManager.flushCommandQueue(ConnectedControllersManager.java:271)
    at androidx.media3.session.ConnectedControllersManager.flushCommandQueue(ConnectedControllersManager.java:252)
    at androidx.media3.session.MediaSessionStub.lambda$flushCommandQueue$64$androidx-media3-session-MediaSessionStub(MediaSessionStub.java:1572)
    at androidx.media3.session.MediaSessionStub$$ExternalSyntheticLambda39.run(Unknown Source:4)
    at androidx.media3.common.util.Util.postOrRun(Util.java:662)
    at androidx.media3.session.MediaSessionStub.flushCommandQueue(MediaSessionStub.java:1570)
    at androidx.media3.session.MediaControllerImplBase$FlushCommandQueueHandler.flushCommandQueue(MediaControllerImplBase.java:3286)
    at androidx.media3.session.MediaControllerImplBase$FlushCommandQueueHandler.handleMessage(MediaControllerImplBase.java:3279)
    at androidx.media3.session.MediaControllerImplBase$FlushCommandQueueHandler.$r8$lambda$NOnasKvWwPWqpbhPrsEnWR2iDWA(Unknown Source:0)
    at androidx.media3.session.MediaControllerImplBase$FlushCommandQueueHandler$$ExternalSyntheticLambda0.handleMessage(Unknown Source:2)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7940)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:952)
CappielloAntonio commented 9 months ago

Hi @C9Glax, would you try this .apk? The crash should have been fixed with one of the latest commits, but I don't remember if I fixed it before or after the apk I sent you last time.

app-tempo-debug.zip

C9Glax commented 9 months ago

Sadly not fixed.

type: crash
osVersion: google/oriole/oriole:13/TQ3A.230805.001/2023090600:user/release-keys
package: com.cappielloantonio.tempo:20
process: com.cappielloantonio.tempo
processUptime: 2591 + 161 ms
installer: com.android.packageinstaller

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.get(ArrayList.java:437)
    at com.cappielloantonio.tempo.util.ReplayGainUtil.setTrackReplayGain(ReplayGainUtil.java:146)
    at com.cappielloantonio.tempo.util.ReplayGainUtil.applyReplayGain(ReplayGainUtil.java:117)
    at com.cappielloantonio.tempo.util.ReplayGainUtil.setReplayGain(ReplayGainUtil.java:28)
    at com.cappielloantonio.tempo.service.MediaService$initializePlayerListener$1.onTracksChanged(MediaService.kt:252)
    at androidx.media3.exoplayer.ExoPlayerImpl.lambda$updatePlaybackInfo$17(ExoPlayerImpl.java:2062)
    at androidx.media3.exoplayer.ExoPlayerImpl$$ExternalSyntheticLambda3.invoke(Unknown Source:4)
    at androidx.media3.common.util.ListenerSet$ListenerHolder.invoke(ListenerSet.java:339)
    at androidx.media3.common.util.ListenerSet.lambda$queueEvent$0(ListenerSet.java:223)
    at androidx.media3.common.util.ListenerSet$$ExternalSyntheticLambda1.run(Unknown Source:6)
    at androidx.media3.common.util.ListenerSet.flushEvents(ListenerSet.java:245)
    at androidx.media3.exoplayer.ExoPlayerImpl.updatePlaybackInfo(ExoPlayerImpl.java:2116)
    at androidx.media3.exoplayer.ExoPlayerImpl.handlePlaybackInfo(ExoPlayerImpl.java:1949)
    at androidx.media3.exoplayer.ExoPlayerImpl.lambda$new$1$androidx-media3-exoplayer-ExoPlayerImpl(ExoPlayerImpl.java:331)
    at androidx.media3.exoplayer.ExoPlayerImpl$$ExternalSyntheticLambda15.run(Unknown Source:4)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7940)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:952)
C9Glax commented 9 months ago

Okay some basic code-review leads me to believe the problem to be some odd beavhiour of java-lists? https://github.com/CappielloAntonio/tempo/blob/main/app/src/main/java/com/cappielloantonio/tempo/util/ReplayGainUtil.java#L50 List<ReplayGain> gains = new ArrayList<>();

Don't you need to add ReplayGain to the call for ArrayList as well? List<ReplayGain> gains = new ArrayList<ReplayGain>();

Because other than that I have no logical explanation why the exception would say that the List-size is 0, when clearly you are adding two elements if that would be the case.

GallowsDove commented 9 months ago

Okay some basic code-review leads me to believe the problem to be some odd beavhiour of java-lists? https://github.com/CappielloAntonio/tempo/blob/main/app/src/main/java/com/cappielloantonio/tempo/util/ReplayGainUtil.java#L50 List<ReplayGain> gains = new ArrayList<>();

Don't you need to add ReplayGain to the call for ArrayList as well? List<ReplayGain> gains = new ArrayList<ReplayGain>();

Because other than that I have no logical explanation why the exception would say that the List-size is 0, when clearly you are adding two elements if that would be the case.

That is definitely not the case.

I've tried to replicate this issue with the latest commit, but I were unsuccessful. Could you please provide more information when this happens? How many songs are you playing? Do they have album/track gain?

C9Glax commented 9 months ago

So no easy fix :(

I am playing my playlist (should be 30-40 songs). Most of my files are flac or wav, and as far as I know the ones that cause the crash do not have gain. Is there any way to check?

CappielloAntonio commented 9 months ago

Would you try this .apk again please? I don't understand how it can raise an IndexOutOfBoundsException if it's already been a few days since I force the gains array to always have the elements I need.

Alternatively I would ask you to temporarily send me the file that crashes the app or, at most, grant me access to your server with a demo user in order to debug more deeply.

app-tempo-debug.zip

C9Glax commented 9 months ago

since I force the gains array to always have the elements I need

Because other than that I have no logical explanation why the exception would say that the List-size is 0, when clearly you are adding two elements if that would be the case.

My point exactly 🤔

Would you try this .apk again please?

Seems to be fixed. At least it doesn't crash on that playlist anymore.

C9Glax commented 9 months ago

Closing, I will ping you should it happen again.