← Commit history

v2.0.287: Concurrency fix: birth-time hwnd capture uses a UNIQUE transient title per window (set on about:blank pre-navigation) instead of the set-diff that refused when >1 window materialized at once. Fixes random per-window failures on multi-open (no handle -> window foregrounds + gets wrong/no icon; which window lost was nondeterministic).

John Lauer ·de6b0fb2ef ·2mo ago ·parent 20d0024
4 files changed +27−29
adom-bridge-puppeteer-manifest.json+5−5
@@ -1,10 +1,10 @@ {   "manifest_version": 1,   "name": "puppeteer",-  "version": "2.0.286",-  "url": "https://wiki.adom.inc/download/adom/pup-bridge/2.0.286/adom-bridge-puppeteer-v2.0.286.zip",-  "sha256": "5960a489f059eb555a063542ecd6de288d489c9038c198488d8f30650dbe51fa",-  "size": 968711,+  "version": "2.0.287",+  "url": "https://wiki.adom.inc/download/adom/pup-bridge/2.0.287/adom-bridge-puppeteer-v2.0.287.zip",+  "sha256": "5e41338b6effbd30b3e5dd6654def84fed5d15af5b4601ce01dfeaaf6c08f15a",+  "size": 968761,   "verbPrefixes": [     "browser_",     "desktop_recorder_",@@ -12,5 +12,5 @@   ],   "healthEndpoint": "/status",   "statusVerb": "browser_readiness",-  "released_at": "2026-08-22T21:34:00.365224Z"+  "released_at": "2026-08-22T22:04:55.304322Z" }
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-2.0.286\ No newline at end of file+2.0.287\ 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.286",+  "version": "2.0.287",   "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+20−22
@@ -10482,31 +10482,29 @@ async function createPageInNewWindow(browser, profileName) {         fresh = (await browser.pages()).find(p => !before.has(p));         if (!fresh) await new Promise(r => setTimeout(r, 100));       }-      if (process.platform === 'win32') {-        // v2.0.185 (John: another thread's "pup window" opened branded IN HIS NATIVE BROWSER): the-        // candidate filter never checked the OWNING PROCESS, and native Chrome top-level windows use-        // the SAME Chrome_WidgetWin_1 class — so a real-browser window appearing during the poll-        // became "the new pup window", got AUMID-stamped and repositioned. Enum rows carry the owner-        // pid and pup knows its own browser's pid: a candidate that is not OUR process is now-        // structurally impossible to capture, no matter what else opens in the same second.+      if (process.platform === 'win32' && fresh) {+        // The owner PID: native Chrome uses the SAME Chrome_WidgetWin_1 class, so only OUR process's+        // windows are candidates (v2.0.185 — another thread's pup window once branded native Chrome).         const _bpid = Number(browser._detachedPid || (browser.process() && browser.process().pid) || 0) || null;-        for (let i = 0; i < 7 && !capturedHwnd; i++) {+        // v2.0.287 CONCURRENCY FIX (John: "why are you so insanely inconsistent?"). The old set-diff+        // ("the one NEW window under the lock") could not disambiguate windows that materialise at the+        // same instant when several open at once — it saw ">1 new window" and REFUSED, so that window+        // got NO handle, could not be parked (it FOREGROUNDED) nor stamped (wrong/no icon), and WHICH+        // window lost the race was random (the inconsistency). Fix: set a UNIQUE transient title on+        // THIS exact page — it is on about:blank pre-navigation, so the title is ours to set and no+        // other window, pup or native, can carry it — then capture the OS window whose title contains+        // it. Unique per birth => deterministic even when 3 windows open in the same millisecond. The+        // caller's navigation overwrites the title right after, by which point the hwnd is captured.+        const _birthTitle = `PUPBIRTH-${_birthSeq}-${Math.floor(Date.now() % 1000000)}`;+        try { await fresh.evaluate((t) => { document.title = t; }, _birthTitle); } catch (e) {}+        for (let i = 0; i < 14 && !capturedHwnd; i++) {           const rows = await enumChromeWidgetWindows({ fresh: true });-          const fresh2 = rows.filter(r => !beforeHwnds.has(Number(r.h)) && !hwndOwnedByOtherSession(r.h, null)-            && (!_bpid || Number(r.pid) === _bpid));-          if (fresh2.length === 1) { capturedHwnd = fresh2[0].h; break; }-          if (fresh2.length > 1) {-            // v2.0.259: more than one appeared despite the lock. The old tie-break matched against the-            // unique off-screen birth coordinate; every window is now born at the SAME on-screen rect,-            // so coordinates cannot break this tie and pretending otherwise would silently mis-assign-            // a handle. R4 says identity must be EXACT, and a wrong hwnd is far worse than a late one-            // (it paints another window's badge and parks the wrong window), so: take none, log loudly,-            // and let the normal resolver settle it once the windows differentiate.-            console.log(`[hwnd] birth capture on "${profileName}" saw ${fresh2.length} new windows under the birth lock (${fresh2.map(r => r.h).join(', ')}) — REFUSING to guess which is mine; the resolver will settle it. If this recurs, the birth lock is not holding.`);-            break;-          }-          await new Promise(r => setTimeout(r, 600));+          const mine = rows.filter(r => (!_bpid || Number(r.pid) === _bpid) && !hwndOwnedByOtherSession(r.h, null) && String(r.title || '').includes(_birthTitle));+          if (mine.length === 1) { capturedHwnd = mine[0].h; break; }+          if (mine.length > 1) { console.log(`[hwnd] birth: ${mine.length} windows carry the unique birth title "${_birthTitle}" — impossible; not guessing`); break; }+          await new Promise(r => setTimeout(r, 150));         }+        if (!capturedHwnd) console.log(`[hwnd] birth on "${profileName}": no window matched the unique birth title "${_birthTitle}" yet — resolver will settle it`);       }     });     // R4: the handle is resolved in the SAME LOCKED MOMENT the window was created — the one new