f87a8eac0deb

keepalive interval in renderLocked prevents SW wakeup penalty; popupWidth frozen at open time and re-asserted in updatePosition

time
2026-05-15 05:23 UTC · 5 months ago
machine
koh2
parent
2b147d91d1cf
1 file src/content/inject.ts+15 −1
src/content/inject.ts+15 −1
@@ -1252,7 +1252,10 @@12521252   host.style.left = `${rect.left + window.scrollX}px`;12531253   // Spec §1.1: 320px width. The Math.max() floor preserves usability on12541254   // wide single-input fields (e.g. centered email input on signup pages).1255-  host.style.width = `${Math.min(Math.max(rect.width, 320), 400)}px`;1255+  // Frozen at open time — updatePosition re-asserts this so page CSS cannot1256+  // expand the host after the initial measurement.1257+  const popupWidth = Math.min(Math.max(rect.width, 320), 400);1258+  host.style.width = `${popupWidth}px`;12561259 12571260   const container = shadow.appendChild(document.createElement("div"));12581261   container.className = "peach-inline-popup";@@ -2470,6 +2473,16 @@24702473     wrap.append(head, pwInp, errEl, unlockBtn);24712474     container.appendChild(wrap);24722475 2476+    // Keep the MV3 service worker alive while the locked popup is visible.2477+    // Without this, the SW goes idle (~30 s) while the user types their2478+    // password, and the UNLOCK message pays a 100-300 ms wakeup penalty2479+    // before the crypto even starts — perceptible as a delay vs the always-2480+    // live extension popup page.2481+    const keepaliveId = setInterval(() => {2482+      chrome.runtime.sendMessage({ type: "TOUCH_AUTO_LOCK" }).catch(() => {});2483+    }, 20_000);2484+    cleanupHooks.push(() => clearInterval(keepaliveId));2485+24732486     // On pages with aggressive focus traps (Etsy modal, Google sign-in, etc.)24742487     // the page reclaims focus from our Shadow DOM input before the user can24752488     // type. Fighting over focus with a focusout→refocus loop hangs the tab.@@ -2546,6 +2559,7 @@25462559     const r = anchorEl.getBoundingClientRect();25472560     host.style.top = `${r.bottom + window.scrollY + 5}px`;25482561     host.style.left = `${r.left + window.scrollX}px`;2562+    host.style.width = `${popupWidth}px`;25492563   }25502564   // These bindings are referenced from renderLocked()/dismiss() — they MUST25512565   // be initialized before renderLocked() runs, or the synchronous assignment

view file