Skip to content

fix: don't crash when to-be-prefetched track uri is empty#98

Closed
aykevl wants to merge 1 commit intodevgianlu:masterfrom
aykevl:fix-prefetch-empty-uri
Closed

fix: don't crash when to-be-prefetched track uri is empty#98
aykevl wants to merge 1 commit intodevgianlu:masterfrom
aykevl:fix-prefetch-empty-uri

Conversation

@aykevl
Copy link
Copy Markdown
Contributor

@aykevl aykevl commented Sep 19, 2024

I'm not sure how to trigger this exactly. It happens when playing albums, and maybe has something to do with the web player and/or switching between players. But it does happen sometimes and just crashing isn't great.

I'm sure I've seen this working as intended (fetching the next track from the Gid field) but because it's hard to reproduce I'm not sure how to test this further. I will keep my debug code in place to see whether the new code path indeed works as expected and will report back if it does.

This fixes #97

I'm not sure how to trigger this exactly. It happens when playing
albums, and maybe has something to do with the web player and/or
switching between players. But it does happen sometimes and just
crashing isn't great.
Comment thread cmd/daemon/controls.go
if next.Uri != "" {
nextId = librespot.SpotifyIdFromUri(next.Uri)
} else {
nextId = librespot.SpotifyIdFromGid(librespot.SpotifyIdTypeTrack, next.Gid)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure SpotifyIdTypeTrack is always the correct type? Episode might end up here too. A call to InferSpotifyIdTypeFromContextUri might be needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not. I'll investigate this a bit more and hope to find some reliable reproducer so I can test this with some podcasts. Until then, I'm not fully convinced yet this is a correct fix.
Thanks for the pointer towards InferSpotifyIdTypeFromContextUri!

@devgianlu
Copy link
Copy Markdown
Owner

This looks reasonable to me. Unlucikly it is always very unpredicatable whether the uri or gid fields will be used.

Feel free to refactor the code in a function if you want to.

aykevl added a commit to aykevl/go-librespot that referenced this pull request Oct 1, 2024
This should be implemented some day, but until it is this at least keeps
the player from crashing.

This is a more conservative alternative to
devgianlu#98.
aykevl added a commit to aykevl/go-librespot that referenced this pull request Oct 1, 2024
This should be implemented some day, but until it is this at least keeps
the player from crashing.

This is a more conservative alternative to
devgianlu#98.
@aykevl
Copy link
Copy Markdown
Contributor Author

aykevl commented Oct 1, 2024

Closing for now in favor of #110. Once I figure out what's going on here, I might make a new PR that actually implements this stuff.

@aykevl aykevl closed this Oct 1, 2024
devgianlu pushed a commit that referenced this pull request Oct 1, 2024
This should be implemented some day, but until it is this at least keeps
the player from crashing.

This is a more conservative alternative to
#98.
thilojaeggi pushed a commit to thilojaeggi/go-librespot that referenced this pull request Oct 13, 2024
This should be implemented some day, but until it is this at least keeps
the player from crashing.

This is a more conservative alternative to
devgianlu#98.
mcMineyC pushed a commit to mcMineyC/go-librespot_embedded that referenced this pull request Mar 27, 2026
This should be implemented some day, but until it is this at least keeps
the player from crashing.

This is a more conservative alternative to
devgianlu#98.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic: invalid uri: when prefetching a track

2 participants