Cast: return a no-op ReconnectionService instead of null#3577
Open
peterhel wants to merge 1 commit into
Open
Conversation
CastDynamiteModuleImpl.newReconnectionServiceImpl returned null, but the Cast SDK's ReconnectionService calls onCreate() on the returned delegate without a null check. So any client that starts the ReconnectionService (common on the connectionless Cast.API_CXLESS path used by Prime/YouTube/etc.) crashes with an NPE in ReconnectionService.onCreate, which destabilises the whole cast session. Return a minimal no-op IReconnectionService (no-op onCreate/onDestroy, onStartCommand=START_NOT_STICKY, onBind=null). microG doesn't drive reconnection itself, so the no-op is sufficient and keeps connectionless sessions stable. Tested on-device (Pixel 2 + Chromecast): with this in place, casting a clip via the connectionless path no longer crash-loops the sender and plays cleanly; without it the sender NPE-loops and the cast callbacks throw RemoteException. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cast: return a no-op ReconnectionService instead of null
Summary
CastDynamiteModuleImpl.newReconnectionServiceImplcurrently returnsnull. But theCast SDK's
ReconnectionServicecallsonCreate()on the returned delegate without anull check, so any client that starts the
ReconnectionServicecrashes with:The
ReconnectionServiceis started on the connectionless (Cast.API_CXLESS) path thatmodern first-party apps (Prime Video, YouTube, …) use, so in practice this crash-loops the
sender process during a cast session. The churn also surfaces downstream as a stream of
RemoteExceptions on the device-controller callbacks (onSendMessageSuccess/onTextMessageReceived) — those are just callbacks landing on the listener of a processthat's being killed and restarted.
Fix
Return a minimal no-op
IReconnectionServiceinstead ofnull:microG doesn't implement Cast reconnection itself, so a no-op delegate is sufficient: it
satisfies the SDK's unconditional
onCreate()/onStartCommand()calls without doinganything, which keeps the session stable. (
START_NOT_STICKYso the empty service isn'tre-created after being killed.)
Testing
On a Pixel 2 + a real Chromecast, casting a clip through the connectionless path:
ReconnectionService.onCreate; the device-controllercallbacks throw
RemoteException(dead listener); the session is unstable.RemoteExceptions, the cast plays cleanly and the sender staysalive.
Notes
This is a microG-level gap independent of any single Cast PR — it affects every
connectionless Cast flow that wires up the
ReconnectionService. Surfaced whilehardware-testing the open Cast PRs (#3377 in particular); with this fix in place those
connectionless implementations cast cleanly rather than crash-looping.