mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-08-19 07:36:16 +00:00
226453fd45
Reported as "Receiving end does not exist" with targetReady true and no activation errors: the election named a frame the player had already torn down. Three defects were stacked, each hidden by the one in front of it. The election was never released. getReadyTabVideoState() recovered through the guarded refresh, which reports "unchanged" when no video is reachable, so the stale frameId/documentId survived; adoption compounded it by setting hasVideo, after which the target only moves on a frame change. An unreachable content script — as opposed to a page that simply has no video yet — now releases the frame election back to the top frame. The tab selection is never touched. Switching frames destroyed the top frame's scripts. Promoting the target out of frame 0 called deactivateTargetTab() on the previous target, which sent TARGET_DEACTIVATE to frame 0 and tore down its content script and the chat overlay with it. That is why chat delivery failed after promotion, and why releasing the election pointed at an empty frame. An in-tab frame switch now leaves the top frame alone. Discovery could deadlock. Monitors announce new players, but a rebuilt frame is a new document with no monitor, so the video created in it was never reported — and nothing then triggered the upkeep that would have installed one. Monitors are reinstalled on every lifecycle notification with a trailing-edge debounce, and a bounded discovery poll breaks the cycle when no notification arrives at all: 2s, capped, only while a tab is selected with no video found, stopping the moment one is. The new browser test adopts a nested player, destroys its document the way the real player does, and asserts both the release and that the rebuilt player is picked up again without touching the popup. It was flaky until the deadlock was closed, and now passes repeatedly at a stable 8.3s. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>