这是indexloc提供的服务,不要输入任何密码
Skip to content

Close DataSource after some idle time (to avoid long-running connections for progressive media loads) #188

@yschimke

Description

@yschimke

HttpDataSource remains open even after buffering the first 50 seconds, so it can be reused.

This works for mobile, but on Wear OS 3 devices the network connection might be requested from Wifi or Cell, and keeping the connection open drains battery. Instead the connection should be used for 5-10 seconds and then released.

From chat conversation

Yuri:

What is the expected behaviour between the Loader and the OkHttpDataSource? I see it prefetching content, presumably up to the 50 second buffer. But it seems like the Response isn't consumed fully and hangs around. Does ExoPlayer keep the request open and resume reading later? In my case, we might have made the request over a specifically requested high bandwidth network, say requesting LTE. So I'd like to ensure it's only open while we are actively loading.

Toni:

If we are talking about progressive streams that are not loaded in chunks, then this sounds like WAI. The connection is opened once and then kept open so that the player can read the data whenever needed. As pointed out above, keeping the connection open without reading is relatively cheap in general. The alternative would be to implement something like the custom DataSource Mitchell described above. What kind of timeout would you use for this case? If it's too small you may cause too many additional delays when reopening the source. If it's too big, you won't save much. If your class is general purpose and can work with any underlying HTTP source, it may be worth sending a PR for it.

A second problem, is on HTTP/2 it's possible that this unread data ends up blocking the entire connection (either on server or client end) and other requests (for example concurrent prefetching) may see timeouts.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions