Skip to content

fix: stop Chrome downloading an on-device model on every browser start - #29

Open
alkaz-nodemaven wants to merge 1 commit into
omkarcloud:masterfrom
alkaz-nodemaven:disable-optimization-hints
Open

fix: stop Chrome downloading an on-device model on every browser start#29
alkaz-nodemaven wants to merge 1 commit into
omkarcloud:masterfrom
alkaz-nodemaven:disable-optimization-hints

Conversation

@alkaz-nodemaven

Copy link
Copy Markdown

What changed

Two entries in default_arguments in botasaurus_driver/core/config.py:

  • OptimizationHints added to the existing --disable-features list;
  • --disable-background-networking added.

A fresh Chrome profile spends an idle window downloading the Optimization
Guide's on-device model from optimizationguide-pa.googleapis.com. Nothing in a
scrape reads it, and a driver that opens a new profile per task pays for it on
every start - which for anyone running through a metered residential proxy is
billed traffic for a file no target ever sees.

Measurement

2026-08-25, Windows 10, Chrome 149.0.7827.201, Driver(headless=True), 60 s
parked on about:blank with nothing navigated. Bytes counted at a loopback
CONNECT proxy and attributed per authority, so these are socket bytes rather
than anything a page-level hook reported.

total optimizationguide-pa.googleapis.com clients2.googleusercontent.com
master at db1d291, run 1 45.17 MB 39.19 MB 5.52 MB
master at db1d291, run 2 45.17 MB 39.19 MB 5.52 MB
this branch, run 1 0.10 MB absent absent
this branch, run 2 0.09 MB absent absent

Each flag was isolated before either was proposed, on the same setup:

flags total model fetch component updater
none 45.17 MB 39.19 MB 5.52 MB
--disable-background-networking 39.28 MB 39.19 MB gone
--disable-component-update 45.17 MB 39.19 MB 5.52 MB
--disable-features=OptimizationHints 5.93 MB gone 5.54 MB
both of the two that work 0.09 MB gone gone

--disable-component-update is the one that looks like it should help and does
nothing measurable, which is why it is not in this diff.

OptimizationHints is the master switch for the service. The narrower
OptimizationHintsFetching, OptimizationTargetPrediction and
OptimizationGuideModelDownloading do not work - I measured a library that
ships all three on its command line and fetches 24-30 MB anyway.

A caveat on reading these numbers: the fetch does not fire on every start. Seven
of eight unflagged runs fetched and one was quiet, so one quiet run proves
nothing. Every row above is one of two runs and the flagged ones are quiet in
both.

Fingerprint

Neither flag is visible to a page. 31 probes sampled from Driver with and
without them - the full navigator prototype property list (83 names), all 1232
window own-property names, plugins, mimeTypes, WebGL vendor, renderer and
extension list, userAgentData, Intl.resolvedOptions, screen metrics,
PerformanceObserver.supportedEntryTypes - come back identical.
--disable-background-networking is already shipped by default in zendriver,
SeleniumBase and Playwright, and patchright ships OptimizationHints.

Note on a related sharp edge

Config.browser_args returns sorted(self.default_arguments + self.arguments).
Because Chrome honours only the last occurrence of a repeated switch, a user who
passes their own --disable-features=... through arguments either wins or is
silently ignored depending on where their string sorts against
--disable-features=IsolateOrigins,.... Merging into the existing list, as this
diff does, avoids adding a second copy. Fixing the general case is a bigger
change and is not attempted here.

A fresh profile spends most of an idle window talking to
optimizationguide-pa.googleapis.com, which serves the Optimization Guide's
on-device model. Nothing in a scrape ever reads it, and a driver that opens a
new profile per task pays for it every time.

Measured over a 60 s window parked on about:blank, with a counting proxy
attributing bytes per CONNECT authority: 45.2 MB before, 0.09 MB after.
OptimizationHints is the master switch for the service; --disable-background-
networking removes the component updater that accounts for the remaining 5.8 MB.

Neither flag is visible to a page: 31 fingerprint probes covering navigator,
window, WebGL, plugins and userAgentData are byte-identical with and without.
@alkaz-nodemaven

Copy link
Copy Markdown
Author

Flagging something against my own PR before anyone spends time merging it.

After I opened this, SeleniumBase's maintainer pointed out that he had already
shipped OptimizationHints and then removed it, in
cb03afab,
"Fix issue that caused Chromium 151 to crash at startup". His report is
here:
--disable-features=OptimizationHints crashed Chromium 151 at startup for him on
2026-06-15. I measured on Chrome 149 and never tested 151, and I did not check
whether anyone had tried the flag before. That is my mistake and you should have
it before this is merged rather than after.

What I have measured since, on Chrome 151.0.7922.137, Ubuntu 24.04.4, headful
under xvfb-run, every flagged arm paired with its own unflagged control in the
same process:

engine headless headful
zendriver 0.16.0 control ok, flag ok control ok, flag ok
botasaurus-driver 4.0.101 control ok, flag ok control ok, flag ok
SeleniumBase 4.51.12 UC Mode control ok, flag ok control ok, flag ok

12 of 12 started and reached a page, and bare google-chrome --headless=new --disable-features=OptimizationHints --dump-dom about:blank exits 0. So I cannot
reproduce it.

But one platform and one build is not a refutation. His report is from when 151
was new; a patch release having fixed it, or the crash being Windows-only, would
both look identical from here. I have asked him for the build and OS and will
report back either way.

Until that is settled, please treat the OptimizationHints part of this PR as
unproven on Chromium 151.
The good news is that this PR splits cleanly and the
other half does not depend on it:

  • --disable-background-networking is independent of this and carries no such
    report. It removed 5.5 MB of component-updater download per browser start on
    its own in my isolation table, and zendriver, SeleniumBase and Playwright all
    ship it by default already. It is worth taking with OptimizationHints dropped
    from the --disable-features value if you would rather wait.

Happy to push either version, or to close this and re-open once the 151 question
has a real answer. Your call - just say which.

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.

1 participant