Skip to content

Fix SABR backoff stalling playback & improve error logging - #2

Merged
henrycity merged 3 commits into
mainfrom
copilot/fix-inline-playback-no-ad
Jul 2, 2026
Merged

Fix SABR backoff stalling playback & improve error logging#2
henrycity merged 3 commits into
mainfrom
copilot/fix-inline-playback-no-ad

Conversation

Copilot AI commented Jul 2, 2026

Copy link
Copy Markdown

YouTube's "locker" script defines isInlinePlaybackNoAd as non-writable/non-configurable, so direct assignment silently fails — the flag never reaches the request, triggering server-side SABR backoff that stalls playback after ~30 seconds. Error logs were also emitting [object Object] instead of readable output.

Changes

src/hooks/json-stringify.ts — bypass property locker

Instead of mutating YouTube's object in place, rebuild the holder → playbackContext → contentPlaybackContext chain with fresh plain objects via spread. JSON.stringify only serializes own enumerable properties, so the spread drops locked descriptors and lets the flag stick.

// Before — silently fails against locked descriptor
(ctx as Record<string, unknown>).isInlinePlaybackNoAd = true;

// After — fresh objects, no locked descriptors
value = {
  ...holder,
  playbackContext: {
    ...pbCtx,
    contentPlaybackContext: { ...ctx, isInlinePlaybackNoAd: true }
  }
};

src/playback-error-handler.ts — readable error logs

Use JSON.stringify on logged objects so the output is inspectable JSON rather than [object Object]. handlePlaybackError now includes videoId, title, full playerState, and videoError in one structured line.

src/player_api/yt-api.ts

Added title to the VideoData interface to surface it in error logs.

Copilot AI added 2 commits July 2, 2026 12:40
- src/hooks/json-stringify.ts: rebuild holder chain with spread to
  bypass YouTube's property locker for isInlinePlaybackNoAd. Direct
  assignment silently failed against non-writable/non-configurable
  descriptors, causing the flag to never reach the request and
  triggering the server-side SABR backoff that stalled playback.

- src/playback-error-handler.ts: replace [object Object] log with a
  formatted string including video ID/title, active player state flags,
  and human-readable video element error code names.

- src/player_api/yt-api.ts: expose title field on VideoData interface.
Copilot AI changed the title [WIP] Fix inline playback no ad flag to prevent silent failures Fix SABR backoff stalling playback & improve error logging Jul 2, 2026
Copilot AI requested a review from henrycity July 2, 2026 12:41
@henrycity
henrycity marked this pull request as ready for review July 2, 2026 12:43
@henrycity
henrycity merged commit b8a6167 into main Jul 2, 2026
Copilot stopped work on behalf of henrycity due to an error July 2, 2026 12:48
Copilot stopped work on behalf of henrycity due to an error July 2, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants