engine-test: WebKit tuning runs (base, cache-viewer, mem500, no-page-cache, related, hw-never, gsk-gl partial); refshot.py (S029 WIP); S039 R5-14 caret box
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
10bb7f04fb
commit
aabbd00a5e
1 changed files with 1353 additions and 4 deletions
|
|
@ -6,7 +6,10 @@ Usage:
|
|||
webkit_shell.py --plan sites.txt --out DIR open the plan's sites one by one (driver mode, see run.sh)
|
||||
|
||||
Window 1556x815 (a maximized niri column on the 1600x900 monitor, the size the Nacre windows get), ephemeral
|
||||
network session (no profile on disk), default hardware acceleration policy. In driver mode, for each line of
|
||||
network session (no profile on disk), default hardware acceleration policy. Tuning flags (each off by default):
|
||||
--related (tabs share the first tab's web process), --mem-limit MB (memory pressure settings on the web context and
|
||||
the network session), --cache-model viewer|browser|docbrowser, --no-page-cache, --hw always|never, --ua chrome
|
||||
(a Chrome 140 Linux user agent); GSK_RENDERER in the environment picks GTK's renderer. In driver mode, for each line of
|
||||
the plan (`label url settle_seconds`) it writes the label to DIR/mark, opens the URL in a new tab, waits the settle
|
||||
time (with `play`: 10 s in, saves check-<label>-pre.json and starts the first video if it is paused), saves a check (title, readiness, video state) to DIR/check-<label>.json, pauses any video and takes a screenshot
|
||||
of the screen output with grim (DIR/<label>.png); after the last site it writes `idle`, waits IDLE seconds
|
||||
|
|
@ -29,6 +32,10 @@ CHECK_JS = """JSON.stringify({title: document.title, ready: document.readyState,
|
|||
videos: [...document.querySelectorAll('video')].map(v => ({t: v.currentTime, paused: v.paused,
|
||||
rs: v.readyState, err: v.error && v.error.code, w: v.videoWidth}))})"""
|
||||
PLAY_JS = "var v = document.querySelector('video'); if (v && v.paused) { v.muted = true; v.play(); } 0"
|
||||
CACHE_MODELS = {"viewer": WebKit.CacheModel.DOCUMENT_VIEWER, "browser": WebKit.CacheModel.WEB_BROWSER,
|
||||
"docbrowser": WebKit.CacheModel.DOCUMENT_BROWSER}
|
||||
CHROME_UA = ("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 "
|
||||
"Safari/537.36")
|
||||
PAUSE_JS = "document.querySelectorAll('video').forEach(v => v.pause()); 0"
|
||||
|
||||
|
||||
|
|
@ -39,15 +46,38 @@ def main():
|
|||
ap.add_argument("--out")
|
||||
ap.add_argument("--idle", type=int, default=60)
|
||||
ap.add_argument("--output", default="DP-1", help="monitor grim captures")
|
||||
ap.add_argument("--related", action="store_true")
|
||||
ap.add_argument("--mem-limit", type=int)
|
||||
ap.add_argument("--cache-model", choices=list(CACHE_MODELS))
|
||||
ap.add_argument("--no-page-cache", action="store_true")
|
||||
ap.add_argument("--hw", choices=["always", "never"])
|
||||
ap.add_argument("--ua", choices=["chrome"])
|
||||
a = ap.parse_args()
|
||||
|
||||
app = Gtk.Application(application_id=None)
|
||||
pressure = None
|
||||
if a.mem_limit:
|
||||
pressure = WebKit.MemoryPressureSettings.new()
|
||||
pressure.set_memory_limit(a.mem_limit)
|
||||
WebKit.NetworkSession.set_memory_pressure_settings(pressure) # before the session is made
|
||||
session = WebKit.NetworkSession.new_ephemeral()
|
||||
context = WebKit.WebContext(memory_pressure_settings=pressure) if pressure else WebKit.WebContext.get_default()
|
||||
if a.cache_model:
|
||||
context.set_cache_model(CACHE_MODELS[a.cache_model])
|
||||
settings = WebKit.Settings(enable_developer_extras=True)
|
||||
if a.no_page_cache:
|
||||
settings.set_enable_page_cache(False)
|
||||
if a.hw:
|
||||
settings.set_hardware_acceleration_policy(getattr(WebKit.HardwareAccelerationPolicy, a.hw.upper()))
|
||||
if a.ua:
|
||||
settings.set_user_agent(CHROME_UA)
|
||||
views = []
|
||||
|
||||
def new_tab(notebook, url):
|
||||
view = WebKit.WebView(network_session=session)
|
||||
view.get_settings().set_enable_developer_extras(True)
|
||||
if a.related and views:
|
||||
view = WebKit.WebView(related_view=views[0], settings=settings)
|
||||
else:
|
||||
view = WebKit.WebView(network_session=session, web_context=context, settings=settings)
|
||||
label = Gtk.Label(label=url[:30])
|
||||
view.connect("notify::title", lambda v, _p: label.set_label((v.get_title() or url)[:30]))
|
||||
i = notebook.append_page(view, label)
|
||||
|
|
|
|||
Loading…
Reference in a new issue