Skip to content
This repository was archived by the owner on Sep 8, 2021. It is now read-only.

Conversation

tari
Copy link
Contributor

@tari tari commented Apr 24, 2019

Significant refactoring of the stream controller, to correctly handle Range requests by including a header as to the support for ranges in a given request (supported iff not transcoding) if a range is requested, and use chunked encoding when transcoding.

I believe this fixes #685 (it appears to on my system).

@tari tari force-pushed the test-flushing branch from af93a8a to 701227f Compare May 22, 2019 03:51
@tari tari changed the title WIP: Fighting with #685 Handle ranges more correctly when streaming May 22, 2019
@tari tari marked this pull request as ready for review May 22, 2019 05:41
@tari
Copy link
Contributor Author

tari commented May 22, 2019

Cleaned up the logging and experimental things I added, I think it's good now.

@muff1nman
Copy link
Contributor

Also looks like you'll need to add an explicit depdency for the following:

[WARNING] Used undeclared dependencies found:
[WARNING]    com.google.code.findbugs:jsr305:jar:3.0.2:compile

Should just be able to put it in the airsonic-main/pom.xml.

@fxthomas
Copy link
Contributor

I'll pull that and leave it running on my server for a while, I'll let you guys know if I see something going bad!

@muff1nman
Copy link
Contributor

Wrote some tests for this in #1026. With this PR the responses now actually line up with ffmpeg's generated output. Well done!

Besides getting travis to be happy, I'd like to see this PR reduced to the minimum amount of changes possible. I.e. no line changes, no refactoring, etc. Those can be done separately if really needed. The reason for this is two fold:

  1. This is a critical part of code and the smaller amount of changes we can make the easier it is to understand the impacts.
  2. A smaller changeset is easier to revert if necessary.

@tari let me know your thoughts on simplifying. I'd also be more than happy to send a PR against your PR to help.

@fxthomas
Copy link
Contributor

fxthomas commented May 22, 2019

I mentioned I had been getting this issue lately in #685 (comment), but the current PR unfortunately doesn't appear to fix it, it just makes it appear 100% of the time on one specific album/song.

  1. Go to Airsonic and click on "Play Album". The first song plays.
  2. Wait till the end.
  3. The play queue appears to go to the second song, but the playback stops.

The player looks like this when this happens (note the "Live Broadcast"):

Screenshot from 2019-05-23 01-26-04

The Firefox logs contain this message (and the stream request appears incomplete in the Network panel):

AbortError: The fetching process for the media resource was aborted by the user agent at the user's request.

Here are file sizes and durations (as reported by ffprobe):

  • FLAC: 00:03:08.03
  • Manual transcode using the same command as the logs: 7521175 bytes, 00:03:08.03
  • Manual stream with curl (using Firefox' handy 'Copy as cURL', so this should be exactly the same request): 7520000 bytes, 00:03:08.00 (mp3check reports "130 bytes missing from last frame")
  • After your PR, manual stream with curl: 7521175 bytes, 00:03:08.03

@muff1nman
Copy link
Contributor

@fxthomas can you send me your example file?

@fxthomas
Copy link
Contributor

Sure, in your mailbox!

In the mean time, it seems that I'm just a poor dumb human making mistakes. I restarted Firefox, which made the issue go away with your PR. I also happened to take the wrong notes for the stream size/duration after PR, edited my earlier comment to reflect that. All I can say is... great job on the PR! 😄

@tari
Copy link
Contributor Author

tari commented May 23, 2019

As for reducing the impact of these changes overall, I think the refactoring is necessary for everything to make sense (without it, it's very difficult to follow what should happen) but much of the reformatting and other changes could be split up. I'll do some rebasing so refactoring and reformatting are more separate, but if you have further opinions on simplification I'm happy to see them.

tari added 7 commits May 23, 2019 10:34
There's no reason to wrap a stream in an output that will do nothing, as
when the requested range is 0-; eg the entire stream.
Making it easier to tell where API contracts allow nulls, where it's
otherwise unclear without reading the implementation.
Mostly just whitespace changes, shortening lines for readability. Adds a
few comments that outline what's supposed to happen.
The core loop was put together confusingly; this encapsulates the
process of constructing an OutputStream and reformats some.
When transcoding, always use chunked transfers and report that ranges
are not supported. When not transcoding, support returning ranges but
only if requested.
This workaround is obsolete with correct handling of ranges when
requested.
@tari tari force-pushed the test-flushing branch from f8bfc12 to 3efa2d3 Compare May 23, 2019 01:14
@tari
Copy link
Contributor Author

tari commented May 23, 2019

..and now it's been split into a number of smaller commits.

@muff1nman muff1nman added this to the 10.4.0 milestone May 23, 2019
@muff1nman muff1nman merged commit 3efa2d3 into airsonic:master May 23, 2019
@bschaefer99
Copy link

How exciting! Thanks team!

@Lightsockie
Copy link

Most excellent 👌

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Playback occasionally stops with "upstream prematurely closed connection..." errors on server
7 participants