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

Change back to allow transcodes to allow seeking #1123

Merged
merged 6 commits into from
Dec 27, 2019

Conversation

eharris
Copy link
Contributor

@eharris eharris commented Jun 12, 2019

This switches back to allowing range rather than chunked requests so that
seeking works in the web player, but does so by safer means than previous
solutions, by slightly over-estimating the transcoded size, then sending
dummy bytes to the client to fill any gap. Fixes #1117. Addresses #685.

@jvoisin
Copy link
Contributor

jvoisin commented Jun 18, 2019

@tari @muff1nman any opinion on this, since you were the ones discussing it in #1117

@tari
Copy link
Contributor

tari commented Jun 19, 2019

As I said there, because this estimate can still be wrong I'm not comfortable making it the only option. Reintroducing the "allow seeking" user-facing option and changing transcode-with-seek behavior (when enabled by the user) to do this seems okay, though I'm not sure how player in general would handle having garbage inserted at the end of a file.

@eharris
Copy link
Contributor Author

eharris commented Jun 19, 2019

I'm kind of holding off on making more changes to this until #1124 gets merged, because they touch some common parts of the code. And I have further changes planned that will make this much safer even without a configuration option to enable it.

As to how players handle extra data tacked on to pad out the transfer to the proper length, I kind of disagree with the term "garbage", and would point out that the code already did that in some circumstances for streaming sources, so appears to be at least somewhat of a time-tested mechanism.

I should also point out that the change that broke seeking for transcodes is a very recent change that probably hasn't seen that much exposure to the user community at large. I suspect that there might be a decent amount of fallout from the loss of that capability and its other side effects.

@tari
Copy link
Contributor

tari commented Jun 19, 2019

The existing practice of inserting garbage into streams has also made me nervous when looking at the code, but I haven't touched it because it appears to work and I haven't been interested in that use case.

I agree that people will probably miss seeking, but I know people will also miss having streams that work correctly. Not all users will care about both though, so an option seems to make sense. Ultimately I'd hope there is a more correct and integrated solution, but the existing change was done this way because it's not possible to fix known problems to a high degree of reliability without making this tradeoff.

@eharris eharris force-pushed the seekable-transcodes branch from 02de6d9 to 05825f4 Compare June 19, 2019 08:41
@eharris
Copy link
Contributor Author

eharris commented Jun 19, 2019

@tari will you check if my isRangeAllowed() commit is acceptable to you as far as attempting to ensure safety when allowing seeking in transcodes, without the need for a user configurable option?

@tari
Copy link
Contributor

tari commented Jun 20, 2019

That's an interesting heuristic. I'm still not really happy with this solution, but it seems okay enough to work around what is mostly an unfortunate set of assumptions in the original API design that we're going to be stuck with (since we don't control all the clients). Maybe eventually we can adopt DASH as a backwards-incompatible streaming solution, and support the existing API by spooling transcoded files in their entirety to temporary storage so we can always know the exact size- trading latency (presumably less important at that point) for accuracy.

The real test will be running this for a while and seeing if it does things wrong, but I'm okay with giving it a try.

@eharris eharris force-pushed the seekable-transcodes branch 3 times, most recently from bfe9706 to c42d432 Compare June 20, 2019 03:05
@eharris
Copy link
Contributor Author

eharris commented Jun 20, 2019

@tari Thanks for being willing to try this solution. I also just added a commit to add a warning if the stream output exceeds the expected length, so we can have some indicator when that happens in case it causes problems for players.

I think this PR is ready to be merged.

@eharris
Copy link
Contributor Author

eharris commented Jun 20, 2019

@tari Also, after this gets merged I would be willing to take a stab at addressing your stream padding concerns by working on a method to append actual valid silence frames (in the appropriate format for the output stream) rather than the current method. I'm not sure how that will work when the last silence frame may be truncated at the end of the stream, but hopefully players will see a truncated frame as invalid and will ignore it.

Copy link
Contributor

@jvoisin jvoisin left a comment

Choose a reason for hiding this comment

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

The padding solution is super-gross, but I'm ok-ish with it if it's working :/

@stale
Copy link

stale bot commented Sep 28, 2019

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@stale stale bot added the stale This label will be removed soon label Sep 28, 2019
@fxthomas
Copy link
Contributor

fxthomas commented Sep 30, 2019

Didn't Airsonic previously truncate the duration up to the second, assume CBR and discard extra bytes in the output? It was working reasonably well, on both the web player and mobile clients (DSub). Padding with zeros shouldn't be an issue either.

Another thing : I personally don't care much about this, but how does overestimating the length work with players offering gapless playback (DSub does as far as I know)?

@stale stale bot removed the stale This label will be removed soon label Sep 30, 2019
@fxthomas
Copy link
Contributor

So far so good, I've been testing this over the last few weeks and everything appears to be working well.

@fxthomas
Copy link
Contributor

Have my tentative approval, I saw no issues running this on my server.

I'll try to give it a full review of the code itself, but might not be able to do that before next week, so if somebody else can review and approve you can go ahead and merge.

@tari
Copy link
Contributor

tari commented Oct 31, 2019

It's been a while now, but IIRC this seemed to work okay for me too.

@fxthomas
Copy link
Contributor

fxthomas commented Nov 2, 2019

Ready to merge as soon as the test failures are handled 😄

@almet
Copy link

almet commented Nov 6, 2019

Integration tests are failing, and from my understanding, it's only due to the fact that they should be updated : they are currently checking that the sent bytes are equal to the actual ones, but as this very pull request is made against this idea… Integration tests should be updated.

I believe that a new Then response bytes are larger test should be added in /integration-test/src/test/java/org/airsonic/test/cucumber/steps/api/StreamStepDef.java.

@fxthomas fxthomas added this to the 10.6.0 milestone Dec 4, 2019
@fxthomas
Copy link
Contributor

fxthomas commented Dec 4, 2019

I'd really like to merge that in the next release, so I added the 10.6.0 milestone. I'll update that if we decide to go to 11.0 instead!

@fxthomas fxthomas mentioned this pull request Dec 15, 2019
13 tasks
This switches back to allowing range rather than chunked requests so that
seeking works in the web player, but does so by safer means than previous
solutions, by slightly over-estimating the transcoded size, then sending
dummy bytes to the client to fill any gap.  Fixes airsonic#1117.  Addresses airsonic#685.
This isn't a perfect solution, but it should help increase confidence
that the transcoder in use is likely to produce an approximately
correct-sized stream.
Renamed the transcoding stream tests to have more specific names.
@eharris eharris force-pushed the seekable-transcodes branch from 210a77c to 72e758b Compare December 17, 2019 05:06
@eharris
Copy link
Contributor Author

eharris commented Dec 17, 2019

I fixed the checkstyle issues and the transcoding tests by updating the compared byte sequences and adding back the check that the length headers match. I decided not to try to change the tests to allow a non-specified amount of "additional padding" bytes since that just makes things more convoluted (and probably also overly permissive) when the comparison byte sequences would most likely need to be generated by the transcoding output code path anyway.

As mentioned previously, an even better solution would be to have the range requests only be allowed by configuration for the specific players that need them. That probably should have been done as part of the original change rather than just removing the range capability for transcodes completely, but this PR at least gets us back to the expected prior behavior in a somewhat safer manner and avoids most of the undesired side-effects caused by that change. Making those improvements is left for a later PR.

@eharris eharris requested review from fxthomas and jvoisin December 17, 2019 05:51
Copy link
Contributor

@fxthomas fxthomas left a comment

Choose a reason for hiding this comment

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

Awesome, looks good to me at first glance! I think this should be good for merging?

@fxthomas fxthomas merged commit 70de4c8 into airsonic:master Dec 27, 2019
@fxthomas
Copy link
Contributor

Merged, thank you for the help!

@eharris eharris deleted the seekable-transcodes branch March 16, 2020 09:13
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.

Reverting patch broke ability for web player to seek within transcoded streams
5 participants