Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OkHttpDataSource: onTransferEnd called twice #1476

Closed
pantos27 opened this issue Apr 27, 2016 · 7 comments
Closed

OkHttpDataSource: onTransferEnd called twice #1476

pantos27 opened this issue Apr 27, 2016 · 7 comments

Comments

@pantos27
Copy link

seems like listener.onTransferEnd is called twice on OkHttpDataSource

once in close() which later calls closeConnectionQuietly() which calls close() again.

@ojw28
Copy link
Contributor

ojw28 commented Apr 27, 2016

I'm confused by this statement. There's only one call to onTransferEnd in OkHttpDataSource, and it's here. Furthermore, closeConnectionQuietly does not call close on the instance. Please clarify?

@pantos27
Copy link
Author

ok, further investigation shows indeed that closeConnectionQuietly does not call close of the same instance, but the fact remains that onTransferEnd is still called twice in the same instance. once when getBufferedPercentage returns 0 and another time where getBufferedPercentage>90

@ojw28
Copy link
Contributor

ojw28 commented Apr 27, 2016

  • closeConnectionQuietly doesn't do anything that would be externally visible outside of the class/instance. I'm unclear why you're suspicious of that method really. It only contains two lines of code. Two of them just null variables, and the other is calling close on an internal object?
  • The same TransferListener can be shared by multiple DataSource instances. Depending on what media you're playing, it may be that there are multiple requests being made. I'm really not sure what the issue is that you're reporting here.

@pantos27
Copy link
Author

The issue is that onTransferEnd is called more than once from the same instance of exoplayer and the same DataSource.
Is it not defined as "Invoked when a transfer ends"?

@ojw28
Copy link
Contributor

ojw28 commented Apr 27, 2016

DataSource instances are not single use. It's valid for a DataSource to be used for more than one request.

@pantos27
Copy link
Author

That's great.
Still, in a single used DataSource, it is called twice, every time.
Once right after prepare was called and getBufferedPercentage was at 0 and another time where some actual data was transferred and getBufferedPercentage was close to 100.

What's the logic in onTransferEnd anyway?
should it not fire, if no network issues happen and the request completes at one go, when getBufferedPercentage is actually at 100?

@ojw28
Copy link
Contributor

ojw28 commented Apr 28, 2016

Your assumption that playing a piece of media maps onto a single network request is incorrect. Some media playbacks will require many (typically bounded) network requests. Each one of them counts as a transfer. Hence this is working as intended.

Depending on exactly what you're playing, it's either necessary to make two requests due to the nature of the media, or it's an inefficiency in ExoPlayer (note: it's not "broken" as such and neither is it doing anything that the player is not legitimately allowed to do; it's just not as efficient as it could be). The main cause of the latter is tracked by #1041.

@ojw28 ojw28 closed this as completed Apr 28, 2016
@google google locked and limited conversation to collaborators Jun 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants