← Commit history

v2.0.283: Render LEASE (John's pick): a window keeps its render surface (thumbnail/reveal show content) for a lease after each interaction, then throttles to blank to save battery - mirrors the highFps lease. Reconciled by a watchdog. [shipped with 90s TEST lease to prove the cycle; 5min to follow]

John Lauer ·28cfd99b31 ·2mo ago ·parent 7d471c4
4 files changed +48−8
adom-bridge-puppeteer-manifest.json+5−5
@@ -1,10 +1,10 @@ {   "manifest_version": 1,   "name": "puppeteer",-  "version": "2.0.282",-  "url": "https://wiki.adom.inc/download/adom/pup-bridge/2.0.282/adom-bridge-puppeteer-v2.0.282.zip",-  "sha256": "f5f5935df9f91ba5ebbed962cda5398607910be644d61e7c28c77ffbe07c497d",-  "size": 968557,+  "version": "2.0.283",+  "url": "https://wiki.adom.inc/download/adom/pup-bridge/2.0.283/adom-bridge-puppeteer-v2.0.283.zip",+  "sha256": "0526b4e10486ddcd5bb0f50a7f24de6c11e0c5de8aa661b62f114dc325d7cf61",+  "size": 969626,   "verbPrefixes": [     "browser_",     "desktop_recorder_",@@ -12,5 +12,5 @@   ],   "healthEndpoint": "/status",   "statusVerb": "browser_readiness",-  "released_at": "2026-08-22T20:04:02.403396Z"+  "released_at": "2026-08-22T20:32:38.771808Z" }
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-2.0.282\ No newline at end of file+2.0.283\ No newline at end of file
src/bridge.json+1−1
@@ -2,7 +2,7 @@   "manifest_version": 1,   "name": "puppeteer",   "displayName": "Puppeteer (Chrome for Testing + Native)",-  "version": "2.0.282",+  "version": "2.0.283",   "description": "Drives a browser ALREADY on the machine \u2014 installed Chrome, else Microsoft Edge (every Windows PC ships with Edge) \u2014 launched with a FRESH isolated profile, so the common case has NO ~150 MB Chrome-for-Testing download and it never touches the user's real tabs/logins. Binds its local server to LOOPBACK (127.0.0.1) only, so no Windows Firewall 'allow Node through the firewall' prompt ever pops. Chrome for Testing is fetched only as a LAST RESORT if the machine has no Chromium browser at all. SPAWN-VERIFIED fallback: pup tries each detected browser (Chrome \u2192 Edge \u2192 CfT) and actually launches it, falling through to the next if one won't start (and handling browsers like Edge that relaunch onto another PID), so a corrupt/partial install never hard-fails an open. The browser that launches is cached as the default (persisted across restarts) so it isn't re-probed each time. On spawn the bridge SELF-WARMS: detects browsers + disk, and only if the box has no Chrome/Edge and no cached CfT does it background-fetch CfT so the first open is instant. pup_use pins a specific browser (chrome | edge | cft | auto); {browser:'chrome',install:true} downloads & installs REAL Google Chrome (user-scoped, no admin) on an Edge-only box. pup_readiness (READ-ONLY) reports which browser will be used + the full candidate list + the default + free disk. Every failure returns a specific errorCode + _hint (chrome_install_no_disk, chrome_download_network, chrome_install_permission, chrome_stable_not_detected, \u2026). Launches with FULL browser permissions by default for full debug (strictPermissions:true opts out). Headful automation: open/close windows+tabs, navigate, screenshot, eval JS, record. pup is a GENERIC, non-profile browser only \u2014 every session is a fresh isolated Chrome/Edge process, never the user's real signed-in browser; profile defaults to sessionId. To drive the user's REAL Chrome/Edge (their profile, cookies, SSO), use the Adom browser EXTENSION's nbrowser_* verbs \u2014 a separate bridge, not pup's job. macOS (v1.9.74+): full parity with mac-native mechanics \u2014 background-by-default is the app-level hide (windows stay drivable/screenshottable while hidden), raise/lower map to unhide+activate/hide, pup_alert_window posts a native toast whose click focuses the window, pup_use {browser:'chrome',install:true} installs Chrome from the official dmg, and taskbar identity/badging remains Windows-only.",   "homepage": "https://wiki.adom.inc/adom/adom-bridge",   "author": "Adom Inc.",
src/server.js+41−1
@@ -9258,6 +9258,42 @@ setInterval(() => {   } }, 30000); +// v2.0.283 RENDER LEASE (John's pick over always-on / never). Chrome drops a background window's+// page-render surface when it is occluded, so its taskbar thumbnail and an instant reveal go BLANK+// (MEASURED via the DWM thumbnail: toolbar persists, page area blank; foregrounding renders it+// fully). Keeping Emulation.setFocusEmulationEnabled ON retains that surface so the thumbnail/reveal+// shows content — but an ACTIVE page then renders continuously in the background (battery, the+// issue-#14 risk). The lease is the balance, mirroring the highFps lease: a window that was just+// opened or interacted with keeps its render surface for RENDER_LEASE_MS; once it has been idle that+// long it downgrades to throttled/blank (zero cost). Re-touched by every interactive verb; a watchdog+// reconciles the emulation state to the lease declaratively, so timing races cannot leak it on.+const _renderLease = new Map();               // sessionId -> expiresAt (ms since epoch)+const RENDER_LEASE_MS = 90 * 1000; // TEST VALUE - bump to 5min after proving the cycle        // render for 5 min after the last interaction, then throttle+function renderLeaseTouch(sessionId) { if (sessionId) _renderLease.set(sessionId, Date.now() + RENDER_LEASE_MS); }+async function applyRenderEmu(session, on) {+  if (!session || session._renderEmuOn === on) return;+  session._renderEmuOn = on;+  for (const t of (session.tabs || [])) {+    const pg = t && t.page; if (!pg) continue;+    try { const cl = typeof pg._client === 'function' ? pg._client() : pg._client; if (cl) await cl.send('Emulation.setFocusEmulationEnabled', { enabled: on }); }+    catch (e) { session._renderEmuOn = !on; }   // failed — let the next reconcile retry+  }+}+setInterval(() => {+  if (process.platform !== 'win32') return;+  const now = Date.now();+  for (const [sid, s] of sessions) {+    const shouldRender = (_renderLease.get(sid) || 0) > now;+    if (s && s._renderEmuOn !== shouldRender) {+      const wasOn = s._renderEmuOn;+      applyRenderEmu(s, shouldRender).then(() => {+        if (!shouldRender && wasOn) console.log(`[render] "${sid}" render lease lapsed (idle ${RENDER_LEASE_MS / 60000} min) — focus-emulation OFF, window throttles to save battery (re-renders on next interaction)`);+      }).catch(() => {});+    }+  }+  for (const sid of [..._renderLease.keys()]) if (!sessions.has(sid)) _renderLease.delete(sid);+}, 15000);+ async function parkSessionWindowDirect(page, sessionId) {   // ── macOS park ── the whole background contract is one primitive: (re-)hide the   // session's browser process. The window was born hidden (pre-window hide in@@ -10541,7 +10577,7 @@ async function createPageInNewWindow(browser, profileName) {           // (verified separately) — unlike the highFps anti-throttle LAUNCH flags that also unthrottle           // every timer fleet-wide (the issue-#14 drain).           await _cl.send('Emulation.setFocusEmulationEnabled', { enabled: true });-          console.log(`[render] focus-emulation ON (retained) for the new window — its page-render surface is kept while occluded, so the taskbar thumbnail / reveal shows content, not blank`);+          console.log(`[render] focus-emulation ON for the new window (initial paint) — its render surface is kept while occluded so the thumbnail/reveal shows content; the RENDER LEASE (v2.0.283) downgrades it to throttled after ${RENDER_LEASE_MS / 60000} min idle to save battery`);         }       } catch (e) { console.log(`[render] could not enable focus-emulation on the new window: ${e && e.message}`); }     }@@ -13733,6 +13769,10 @@ const server = http.createServer(async (req, res) => {       // (see PASSIVE_VERBS) or every window would read as permanently busy.       if (command && command.startsWith('pup_') && !PASSIVE_VERBS.has(command)) {         try { markSessionBusy(args.sessionId || activeSessionId); } catch (e) {}+        // v2.0.283: an interactive verb renews the RENDER LEASE, so a window the user is actively+        // using keeps its render surface (thumbnail/reveal show content); an idle one lapses and+        // throttles to save battery. Same "the agent is working this window" signal as markSessionBusy.+        try { renderLeaseTouch(args.sessionId || activeSessionId); } catch (e) {}       }        switch (command) {