Skip to content

Download RequirementWatcher misses network transition #6733

@szaboa

Description

@szaboa

[REQUIRED] Issue description

The RequirementWatcher of downloads sometimes misses to detect that a network is available and because of this the download will go back to queue incorrectly.

[REQUIRED] Reproduction steps

The issue can be reproduced with ExoPlayer's demo app. The default requirement of downloads in the demo app is com.google.android.exoplayer2.scheduler.Requirements#NETWORK, which should allow to download on Wifi and cellular network.

  1. Be connected to Wifi and also enable LTE.
  2. Start to download any content in the demo app.
  3. Wait until it starts and the progress can be seen in the notification.
  4. Disable WiFi.

Expected result:
The phone switches to mobile data and the download continues.

Actual result:
The phone switches to mobile data but the download stops (goes into queue and reporting that the network requirement is not met).

Note: this behavior can be seen only approx. 7/10 times, sometimes works as expected.

[REQUIRED] Link to test content

Any content in the demo app.

[REQUIRED] A full bug report captured from the device

N/A

[REQUIRED] Version of ExoPlayer being used

Version 2.10.2, but also branch dev-v2.

[REQUIRED] Device(s) and version(s) of Android being used

  • Pixel 1 - physical device
  • Pixel 3xl - emulator

Additional info:

The root cause seems to be that after turning off the Wifi RequirementsWatcher.CapabilityValidatedCallback#onLost is called correctly but RequirementsWatcher.CapabilityValidatedCallback#onAvailable is not called when goes over to mobile network.

Using connectivityManager.registerDefaultNetworkCallback(networkCallback) instead of connectivityManager.registerNetworkCallback(request, networkCallback) solves the problem (at least in my tests it worked 10/10) but then we will miss the internet connectivity validation (same when API < 23).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions