Skip to content

fix(config): stop passing --disable-features twice, and disable OptimizationHints - #274

Open
alkaz-nodemaven wants to merge 1 commit into
cdpdriver:mainfrom
alkaz-nodemaven:disable-optimization-hints
Open

fix(config): stop passing --disable-features twice, and disable OptimizationHints#274
alkaz-nodemaven wants to merge 1 commit into
cdpdriver:mainfrom
alkaz-nodemaven:disable-optimization-hints

Conversation

@alkaz-nodemaven

Copy link
Copy Markdown

What changed

Two lines in zendriver/core/config.py:

  • Config.__call__ appended --disable-features=IsolateOrigins,site-per-process
    on top of the longer list already in _default_browser_args. Chrome stores
    switches in a map, so the last occurrence of a switch wins and the earlier one
    is dropped whole. The declared list, including
    DisableLoadExtensionCommandLineSwitch, never reached the browser.
  • OptimizationHints is added to the surviving list, which stops the
    Optimization Guide from downloading an on-device model on every fresh profile.

The duplicate switch

config.py:134 declares:

--disable-features=IsolateOrigins,DisableLoadExtensionCommandLineSwitch,site-per-process

and config.py:205 then appended:

--disable-features=IsolateOrigins,site-per-process

Both are on the command line today; Config()() returns two of them. Which one
Chrome honours is not something I wanted to take from reading Chromium, so I
measured it, using a feature whose effect is visible in network traffic:

order on the command line Optimization Guide fetch
OptimizationHints first, IsolateOrigins second happens, 39.18 MB
IsolateOrigins first, OptimizationHints second does not happen

So the last switch wins and the first is discarded entirely, which is why adding
OptimizationHints to line 134 alone changed nothing until line 205 was removed.

The bandwidth

Measured 2026-08-25, Windows 10, Chrome 149.0.7827.201, headless=True, 60 s
parked on about:blank with nothing navigated. Bytes are counted at a loopback
CONNECT proxy and attributed per authority, so this is what the socket saw rather
than what any framework-level hook reported.

total optimizationguide-pa.googleapis.com
main at 2c6d9c7, run 1 39.46 MB 39.37 MB
main at 2c6d9c7, run 2 39.37 MB 39.28 MB
this branch, run 1 0.09 MB absent
this branch, run 2 0.07 MB absent

OptimizationHints is the master switch for the service. Disabling the narrower
OptimizationHintsFetching, OptimizationTargetPrediction and
OptimizationGuideModelDownloading does not help, because the service is still
constructed; I checked that separately against a library that ships all three and
fetches anyway.

One caveat on the numbers, because it cost me an hour: the fetch does not fire on
every start. Seven of eight runs without the flag fetched and one was quiet, so a
single quiet run is not evidence a flag worked. Every row above is one of two
runs, and the flagged runs are quiet in all of them.

Fingerprint

OptimizationHints is not page-visible. 31 probes sampled from the same engine
with and without the flag - the full navigator prototype property list (83
names), all 1232 window own-property names, plugins, mimeTypes, WebGL
vendor/renderer/extension list, userAgentData, Intl.resolvedOptions, screen
metrics, PerformanceObserver.supportedEntryTypes - are identical. Patchright
also ships OptimizationHints in its default --disable-features list.

One thing I could not confirm

Removing the duplicate makes DisableLoadExtensionCommandLineSwitch effective
for the first time, and I expected that to restore --load-extension, which
browser.py:355 still passes. It does not, at least here: a minimal MV3
extension with a document_start content script fails to load both before and
after this change on Chrome 149, headful. So the dead switch is real but it is
not the whole story for extensions, and I am deliberately not claiming this
patch fixes them. Happy to open that separately if it is news to you.

config.py:206 also duplicates --disable-session-crashed-bubble from line 135.
That one is a valueless switch, so the duplicate is harmless, and I left it alone
to keep this diff to the lines that change behaviour.

…izationHints

Config.__call__ appended a second --disable-features switch on top of the one
in _default_browser_args. Chrome keeps switches in a map, so the last occurrence
wins and the first list was silently discarded, taking
DisableLoadExtensionCommandLineSwitch with it.

Removing the duplicate makes the declared list effective again. Adding
OptimizationHints to it stops the Optimization Guide from downloading an
on-device model on every fresh profile: measured over a 60 s idle window on
about:blank, 39.4 MB before and under 0.1 MB after.
@alkaz-nodemaven
alkaz-nodemaven requested a review from a team as a code owner August 25, 2026 20:41
@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:

  • The duplicate --disable-features fix stands entirely on its own. Today
    Config()() returns two of them, Chrome honours only the last, and the
    declared list at config.py:134 - including
    DisableLoadExtensionCommandLineSwitch - never reaches the browser. That is a
    bug regardless of what goes in the surviving list, and it is worth merging with
    OptimizationHints dropped from the 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