Improve cast load reliability with multiple fallback strategies#839
Improve cast load reliability with multiple fallback strategies#839theovilardo wants to merge 26 commits intobckp/refactor-cast-featurefrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3eaa7c12e3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| val attempts = listOf(::attemptQueueLoad, ::attemptLoadRequest, ::attemptLegacyLoad) | ||
|
|
||
| fun runAttempt(index: Int) { | ||
| if (index >= attempts.size) { | ||
| Timber.tag(CAST_TAG).e("All cast load attempts failed") |
There was a problem hiding this comment.
Reset timeout when chaining multiple load attempts
With the new sequential queueLoad → load(MediaLoadRequestData) → legacy load chain, the existing 20s safety timeout (started before any attempts) can now expire while a later attempt is still in flight. If the first attempt fails slowly and the second/third succeeds after ~20s total, the timeout will fire onComplete(false) first and the eventual success is ignored by safeOnComplete, causing a false “Failed to load media” and disconnect even though the cast device actually loaded. Consider resetting/extending the timeout per-attempt or only starting it once per attempt to avoid premature failure in slower networks/devices.
Useful? React with 👍 / 👎.
Motivation
client.load(MediaInfo)call, causing the app to show "Failed to load media on cast device.".Description
queueLoad, aMediaLoadRequestData-basedclient.load(...), and a legacyclient.load(MediaInfo, ...)fallback in sequence until one succeeds.MediaQueueItemlist fromsongsand validatestartIndex, with improved media URL/mime handling performed inSong.toMediaQueueItem.safeOnCompletewrapper to avoid double invocation and a 20s coroutine-based safety timeout that forces failure if no callback arrives.Timberlogging for each attempt and result to aid debugging and receiver-specific analysis.Testing
Codex Task