From 19ef8f2e15e3732a2f97aac7b9969e01a807345d Mon Sep 17 00:00:00 2001 From: Knotty Wyvern Date: Sat, 31 Oct 2026 19:06:45 -0700 Subject: [PATCH] Keep the display scale when a page replaces itself during its load The engine applied device emulation at did-finish-load. Each new document gets a renderer widget without emulation. Google replaces its first document with ?zx=... before that document finishes. Thus the first document kept a scale of 1, and the page grew by the display scale when the second document finished. The engine now also applies emulation when a main-frame document commits. In the real app at 125%, Google keeps the same size before and after its second document. Card 40a8db13. --- browser-runtime/src/engine.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/browser-runtime/src/engine.mjs b/browser-runtime/src/engine.mjs index 5a0401d..3aaa910 100644 --- a/browser-runtime/src/engine.mjs +++ b/browser-runtime/src/engine.mjs @@ -166,7 +166,9 @@ export async function createEngine({ directory, emit = () => {}, canEmitFrame = changed(); } }); - wc.on('did-navigate', (_event, url) => { store.visit(profileId, url, item.title); changed(); }); + // Each new document gets a renderer widget without device emulation. A page that replaces itself before it finishes + // loading, as Google does, otherwise keeps a scale of 1 and grows when the next document finishes. + wc.on('did-navigate', (_event, url) => { emulateViewport(item); store.visit(profileId, url, item.title); changed(); }); wc.on('did-navigate-in-page', (_event, _url, main) => { if (main) { item.epoch++; agent.revokeAll(); } changed(); }); wc.on('page-title-updated', (_event, title) => { item.title = title.slice(0, 200); changed(); }); wc.on('page-favicon-updated', (_event, urls) => {