(android) [Intermittent] NO_DEVICES_AVAILABLE after restarting app after leaving shared session
Lindsay-Needs-Sleep opened this issue · 1 comments
Given this situation:
- Device 1 and 2 both join the same sesssion
- Device 1 does
session.leave
orsession.stop
- Restart the app on Device 1, and call
chrome.cast.initialize
again - (the bug) receiverListener never gets called with availability == true
This is tested in the manual tests on the primary device. The end of tests_manual_primary_1 and
the beginning of tests_manual_primary 2 tests this.
NOTE: The bug lasts longer when doing session.leave
. The bug seems to last until one of 2 things happen:
- The session has been killed AND some time has passed. (since
session.leave
does not kill the session the bug lasts longer) - The app is completely wiped from memory eg. re-install or settings > Apps > > "Force Stop"
This bug is extra strange because if you don't restart the app, it is happy to signal that receivers are available during chrome.cast.initialize
.
The source of the bug is here:
ChromecastConnection.java
>
initialize() {
>
startRouteScan
/ScanCallback
/onRouteUpdate
>
if (getContext().getCastState() != CastState.NO_DEVICES_AVAILABLE) {
(line 107)
Never evaluates to true
This is very strange because onRouteUpdate
is called with the actual valid route. Meaning there are indeed routes available. Not sure why getContext().getCastState()
thinks there isn't.
This also only happens on one device that I have tested.
(Samsung tablet, SM-T350, Galaxy Tab A, Android 7.0)
The other device I test on is fine. (LG Phone, LG-M151, LG K4, Android 6.0.1)
Changing:
if (getContext().getCastState() != CastState.NO_DEVICES_AVAILABLE) {
to this:
if (routes.size() > 0) {
Seems like the obvious solution, but it appears that as long as getContext().getCastState() == CastState.NO_DEVICES_AVAILABLE
it is impossible to join/rejoin the route (which leads to other bugs).