Skip to content

fix(adblock): harden isInlinePlaybackNoAd against property locker#458

Open
marceldenzer wants to merge 1 commit into
webosbrew:mainfrom
marceldenzer:fix/inline-playback-noad-locker
Open

fix(adblock): harden isInlinePlaybackNoAd against property locker#458
marceldenzer wants to merge 1 commit into
webosbrew:mainfrom
marceldenzer:fix/inline-playback-noad-locker

Conversation

@marceldenzer

Copy link
Copy Markdown

Problem

Playback aborts after a few seconds with a YouTube error screen when ads are stripped (e.g. #457). This is YouTube's server-side SABR "backoff": when the client receives no ads, the server instructs it to wait instead of sending media data, which surfaces as fake buffering and then an error.

The existing mitigation (added in #332) sets playbackContext.contentPlaybackContext.isInlinePlaybackNoAd = true in player requests so InnerTube serves no ads — and therefore no backoff.

Root cause

YouTube ships a "locker" script that defines isInlinePlaybackNoAd as non-writable / non-configurable via Object.defineProperty. The previous code set the flag with a direct in-place assignment (ctx.isInlinePlaybackNoAd = true), which silently fails against a locked descriptor (no throw in non-strict mode). The flag never makes it into the request, the backoff returns, and playback stalls.

Fix

Instead of mutating YouTube's object in place, rebuild the holder chain (holder → playbackContext → contentPlaybackContext) with fresh plain objects via spread. JSON.stringify only serializes own enumerable properties, so the spread reproduces exactly what would be serialized while dropping any locked property descriptors — so our flag sticks.

The clone is only built when a contentPlaybackContext is present and the flag isn't already set, so the hot path of JSON.stringify is unaffected.

Testing

  • pnpm run lint:tsc, pnpm run lint:prettier, pnpm run lint:eslint and pnpm run build all pass.
  • Manually verified on hardware (LG webOS 6.5.3): a video that previously aborted after ~30 s now plays through, and the console logs [JSON.stringify] Set isInlinePlaybackNoAd.

Fixes #457

🤖 Generated with Claude Code

YouTube's server-side SABR "backoff" stalls playback after a few seconds
when ads are stripped. The mitigation sets
`playbackContext.contentPlaybackContext.isInlinePlaybackNoAd = true` so
InnerTube serves no ads (and thus no backoff).

YouTube ships a "locker" script that defines this property as
non-writable/non-configurable via Object.defineProperty, so the previous
in-place assignment silently failed and playback aborted with an error.

Instead of mutating YouTube's object, rebuild the holder chain with fresh
plain objects. JSON.stringify only serializes own enumerable properties,
so spreading reproduces what would be serialized while dropping the locked
descriptors, letting the flag stick.

Fixes webosbrew#457

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Zagitta

Zagitta commented Jun 22, 2026

Copy link
Copy Markdown

I just built and installed your branch and it didn't work, even after uninstalling the app and installing the ipk

@marceldenzer

Copy link
Copy Markdown
Author

So you still have the same error?

@KampfGurke20

Copy link
Copy Markdown

Can you upload the pre build ipk so I can test?
Unfortunately, I don't have time to set up the environment to build it myself.

@marceldenzer

Copy link
Copy Markdown
Author

youtube.leanback.v4_0.5.3_all.ipk.zip

@KampfGurke20

Copy link
Copy Markdown

Thanks, it's working here 👍
LG nano756pr @ 03.52.55

@bnegron

bnegron commented Jun 23, 2026

Copy link
Copy Markdown

youtube.leanback.v4_0.5.3_all.ipk.zip

Tried this just now - casting from phone causes the app to crash irrecoverably. I had to uninstall it to get functionality back. Not rooted; managed via dev mode / dev manager.

LG oled65g3pua @ 10.3.1-3001

@MrBoydee

Copy link
Copy Markdown

Tested on LG C1 issue persists.

@Iamelmah

Copy link
Copy Markdown

Didn't work for me.
LG 50UP77006LB 03.53.45

@kevin0carter

Copy link
Copy Markdown

having the same issue restarted the tv uninstalled reinstalled didnt work also the zip earlier didnt work either

@MustaphaAgouzal

Copy link
Copy Markdown

Just tested your file youtube.leanback.v4_0.5.3_all.ipk.zip and the issue still persists

@Zagitta

Zagitta commented Jun 24, 2026

Copy link
Copy Markdown

I'm fairly certain this is gonna be a lot harder to solve than this patch.

At least on my tv that's rooted and on webos 6.2.0-31 with firmware 03.21.00 even removing all custom code in the IPK and leaving only an index.html with <!doctype html><html><head><script>window.location.href = "https://www.youtube.com/tv";</script></head></html> brings back all the usual ad infestation etc but still triggers the error.

I suspect this is either because something has marked my YT account as more suspicious and thus has a lower threshold for other flags to trigger it.
Or because whatever bot detection / SARB / POToken stuff google does now freaks out due to the age of the builtin webview.

So I think there's a good chance we'll need to mimic the official app which uses cobalt as the webview instead.

@KampfGurke20

Copy link
Copy Markdown

That's weird why is it working here but not somewhere else 😅
IMG_20260624_172247

@Steefzar

Copy link
Copy Markdown

Can confirm that it did not work with the IPK for me

@malip2

malip2 commented Jun 25, 2026

Copy link
Copy Markdown

+1 not working

@Never-Asked

Never-Asked commented Jun 26, 2026

Copy link
Copy Markdown

The problem persists for several days, updating from the main branch also did not help

@marceldenzer

Copy link
Copy Markdown
Author

Well, I guess it has something to do with the account or anything else. I tested it for several days, and it still works a charm for me. Probably some geographical problem? I guess Kampfgurke is from Germany, just like me. Probably that’s why it works for us.

@Nephilimator

Copy link
Copy Markdown

Just tested your file youtube.leanback.v4_0.5.3_all.ipk.zip and the issue still persists

I have also tested the IPK and the issue still persists.

image

@halexh

halexh commented Jun 27, 2026

Copy link
Copy Markdown

Definitely seems account related. If you login as a guest on the app, it works fine, at least for a few videos before prompting you to sign in to verify you aren't a bot. The fact that the app works fine as a guest but not while signed in seems to indicate it's account related

@kevin0carter

Copy link
Copy Markdown

Yes, I just tested it also its definitely account based I changed accounts from the one I used daily to another and it works fine. Maybe youtube has done a new update that causes this not sure for now the work around is just use another google login.

@KampfGurke20

Copy link
Copy Markdown

I don't think so, I use the same account on 2 different TV's the nano756pr and a ur73006la, on the 73006 the original yt adfree works all the time and on the nano756pr it works with the fix above 🤔

tigercraft4 added a commit to tigercraft4/youtube-webos that referenced this pull request Jul 7, 2026
…ive catch-up) + hide merch QR

- PR webosbrew#458: harden isInlinePlaybackNoAd against YouTube SABR property locker
  Fixes videos stopping after a few minutes (webosbrew#457)
- PR webosbrew#463: live stream catch-up (skip to live edge when delay accumulates)
  New option in settings: 'Reduce live stream delay'
- feat: hide merch/product QR codes during video playback (webosbrew#385)
  New option in settings: 'Hide merch/product QR codes' (enabled by default)
@jmorrison100

jmorrison100 commented Jul 7, 2026

Copy link
Copy Markdown

It is account specific. Me and my partner both have YT accounts logged in on the same LG C2 TV. Hers stopped working a week or so ago as she watches a lot more YT on the TV, now my account is doing the same thing today after watching some YT on my PC last night with Ublock on. My guess is Google is flagging accounts that it sees have low or no add watches.

If you use the guest account it works fine for me, this might be a temporary workaround for now.

@kksilas

kksilas commented Jul 8, 2026

Copy link
Copy Markdown

it does work when anonymous but unfortunately youtube asks for login after a couple of videos, as soon as you login the error is back

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.

Video stops playing after some minutes