HEL-795: import visual director keyboard and text motion fixes
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
param([string]$html = "$PSScriptRoot\..\index.html", [string]$out = "$PSScriptRoot\..\evidence\motion-probe.json", [int]$port = 9341)
|
||||
# HEL-795 motion probe: what is still animating 80ms after a keyboard action, vs. the same action by mouse / auto-flow,
|
||||
# and how much layout work each transition costs (CDP Performance metrics, headless Edge, software compositing).
|
||||
. "$PSScriptRoot\cdp.ps1"
|
||||
$url = 'file:///' + ((Resolve-Path $html).Path -replace '\\', '/')
|
||||
$results = New-Object System.Collections.ArrayList
|
||||
function Rec([string]$name, $data) { [void]$results.Add([ordered]@{ probe = $name; data = $data }); "{0} {1}" -f $name, ($data | ConvertTo-Json -Compress -Depth 6) }
|
||||
function J($e) { Invoke-Js $e | ConvertFrom-Json }
|
||||
function JA($e) { Invoke-Js $e -await | ConvertFrom-Json }
|
||||
function Key([string]$key, [int]$vk) {
|
||||
[void](Send-Cdp 'Input.dispatchKeyEvent' @{ type = 'rawKeyDown'; key = $key; code = $key; windowsVirtualKeyCode = $vk })
|
||||
[void](Send-Cdp 'Input.dispatchKeyEvent' @{ type = 'keyUp'; key = $key; code = $key; windowsVirtualKeyCode = $vk })
|
||||
}
|
||||
# Finite animations still running, grouped; ambient loops (infinite) are excluded on purpose.
|
||||
$lib = @'
|
||||
window.__anims = () => { const g = {}; for (const a of document.getAnimations()) { if (a.playState !== 'running') continue; const t = a.effect.getTiming(); if (t.iterations === Infinity) continue;
|
||||
const ct = a.effect.getComputedTiming(); const left = Math.round(ct.endTime - (a.currentTime || 0)); if (left <= 0) continue; const el = a.effect.target;
|
||||
const k = (el.id || String(el.className).split(' ')[0] || el.tagName) + ' | ' + (a.transitionProperty || a.animationName || 'script') + ' | ' + Math.round(t.duration) + 'ms';
|
||||
g[k] = (g[k] || 0) + 1; } return g; };
|
||||
window.__after = ms => new Promise(r => setTimeout(() => r(JSON.stringify(__anims())), ms));
|
||||
window.__props = () => { const s = new Set(); for (const a of document.getAnimations()) if (a.transitionProperty) s.add(a.transitionProperty); return [...s]; };
|
||||
'@
|
||||
$null = Start-Browser $port
|
||||
try {
|
||||
Set-View 1440 900
|
||||
[void](Send-Cdp 'Performance.enable' @{ timeDomain = 'timeTicks' })
|
||||
function Metrics { $m = @{}; foreach ($x in (Send-Cdp 'Performance.getMetrics').metrics) { $m[$x.name] = $x.value }; $m }
|
||||
function Cost([scriptblock]$act, [int]$ms) {
|
||||
$a = Metrics; & $act; Wait-Ms $ms; $b = Metrics
|
||||
[ordered]@{ layouts = $b.LayoutCount - $a.LayoutCount; layoutMs = [math]::Round(($b.LayoutDuration - $a.LayoutDuration) * 1000, 2); styleRecalcs = $b.RecalcStyleCount - $a.RecalcStyleCount; styleMs = [math]::Round(($b.RecalcStyleDuration - $a.RecalcStyleDuration) * 1000, 2); windowMs = $ms }
|
||||
}
|
||||
Open-Page "${url}?theme=moon"; [void](Invoke-Js $lib); Wait-Ms 1200
|
||||
|
||||
# 1. Mouse/click open + close keeps the natural geometry expansion (must stay animated).
|
||||
[void](Invoke-Js "document.querySelector('#start-talk').click()")
|
||||
Rec 'click-open-talk +80ms' (JA '__after(80)')
|
||||
Wait-Ms 1500
|
||||
Rec 'keyboard Escape +80ms' $(Key 'Escape' 27; JA '__after(80)')
|
||||
Rec 'keyboard Escape: mode/portal' (J 'JSON.stringify({mode:document.body.dataset.mode,z:__proto.atmos().z,portalW:Math.round(document.querySelector("#portal").getBoundingClientRect().width)})')
|
||||
Wait-Ms 1200
|
||||
[void](Invoke-Js "document.querySelector('#start-talk').click()"); Wait-Ms 1500
|
||||
[void](Invoke-Js "document.querySelector('#close-talk').click()")
|
||||
Rec 'click close-talk +80ms' (JA '__after(80)')
|
||||
Wait-Ms 1500
|
||||
|
||||
# 2. Reading: keyboard review vs. auto flow.
|
||||
[void](Invoke-Js "__proto.runScenario('long')"); Wait-Ms 9000
|
||||
Rec 'keyboard ArrowRight +80ms' $(Key 'ArrowRight' 39; JA '__after(80)')
|
||||
Rec 'keyboard ArrowRight: ink spans' (J 'JSON.stringify({ink:document.querySelectorAll("#stage .is-current .ink span").length,lines:document.querySelectorAll("#stage .line:not(.leaving)").length,cursor:__proto.state.cursor})')
|
||||
Wait-Ms 300
|
||||
Rec 'keyboard ArrowLeft +80ms' $(Key 'ArrowLeft' 37; JA '__after(80)')
|
||||
Rec 'keyboard ArrowLeft: state' (J 'JSON.stringify({flow:__proto.state.flow,cursor:__proto.state.cursor,latestHidden:document.querySelector("#latest").hidden})')
|
||||
Wait-Ms 200
|
||||
Rec 'keyboard ArrowLeft x3 rapid +80ms' $(Key 'ArrowLeft' 37; Key 'ArrowLeft' 37; Key 'ArrowLeft' 37; JA '__after(80)')
|
||||
[void](Invoke-Js "document.querySelector('#next').click()")
|
||||
Rec 'click next +80ms' (JA '__after(80)')
|
||||
Wait-Ms 900
|
||||
[void](Invoke-Js "document.querySelector('#latest').click()"); Wait-Ms 600
|
||||
# Catch the moment auto-flow advances on its own, then look 80ms later.
|
||||
$auto = JA "new Promise(r=>{const c=__proto.state.cursor;const t=setInterval(()=>{if(__proto.state.cursor!==c){clearInterval(t);setTimeout(()=>r(JSON.stringify({anims:__anims(),props:__props()})),80)}},5)})"
|
||||
Rec 'auto advance +80ms' $auto
|
||||
# Transitions on layout properties seen across an auto advance (font-size / width must be absent).
|
||||
$seen = JA "new Promise(r=>{const s=new Set();const t=setInterval(()=>{for(const a of document.getAnimations())if(a.transitionProperty)s.add(a.transitionProperty)},16);setTimeout(()=>{clearInterval(t);r(JSON.stringify([...s]))},9000)})"
|
||||
Rec 'css transitions seen over 9s of auto flow' $seen
|
||||
Rec 'layout cost: auto flow 9s' (Cost {} 9000)
|
||||
|
||||
# 3. Nav glow: move between items by click; width must not be a transition.
|
||||
[void](Invoke-Js "__proto.setMode('home')"); Wait-Ms 900
|
||||
[void](Invoke-Js "document.querySelector('[data-nav=talk]').click()")
|
||||
Rec 'nav click +80ms transitions' (JA "new Promise(r=>setTimeout(()=>r(JSON.stringify(document.getAnimations().filter(a=>a.effect.target.classList&&a.effect.target.classList.contains('nav-glow')).map(a=>a.transitionProperty))),80))")
|
||||
Wait-Ms 1200
|
||||
|
||||
# 4. Portal geometry cost: click open/close (720ms) vs. keyboard Escape.
|
||||
[void](Invoke-Js "__proto.setMode('home')"); Wait-Ms 1500
|
||||
Rec 'layout cost: idle 1s (baseline)' (Cost {} 1000)
|
||||
Rec 'layout cost: click open talk 1s' (Cost { [void](Invoke-Js "document.querySelector('#start-talk').click()") } 1000)
|
||||
Rec 'layout cost: keyboard Escape 1s' (Cost { Key 'Escape' 27 } 1000)
|
||||
Rec 'layout cost: click open + close-talk 2s' (Cost { [void](Invoke-Js "document.querySelector('#start-talk').click()"); Wait-Ms 1000; [void](Invoke-Js "document.querySelector('#close-talk').click()") } 1000)
|
||||
# 5. Frame pacing during the 720ms geometry move (main-thread rAF intervals; headless = software raster, not a GPU number).
|
||||
$fp = "new Promise(r=>{const ts=[];let s=performance.now();(function f(t){ts.push(t);if(t-s<900)requestAnimationFrame(f);else{const d=ts.slice(1).map((x,i)=>x-ts[i]).sort((a,b)=>a-b);r(JSON.stringify({frames:d.length,p50:+d[Math.floor(d.length*.5)].toFixed(1),p95:+d[Math.floor(d.length*.95)].toFixed(1),max:+d[d.length-1].toFixed(1)}))}})(s)})"
|
||||
Wait-Ms 1500
|
||||
Rec 'frames: idle home 900ms' (JA $fp)
|
||||
[void](Invoke-Js "document.querySelector('#start-talk').click()"); Rec 'frames: click open talk 900ms' (JA $fp); Wait-Ms 600
|
||||
[void](Invoke-Js "document.querySelector('#close-talk').click()"); Rec 'frames: click close talk 900ms' (JA $fp); Wait-Ms 600
|
||||
|
||||
# 6. Escape inside the history sheet returns to talk at once.
|
||||
[void](Invoke-Js "document.querySelector('#start-talk').click()"); Wait-Ms 1200
|
||||
[void](Invoke-Js "document.querySelector('#history').click()"); Wait-Ms 1200
|
||||
Rec 'keyboard Escape in sheet +80ms' $(Key 'Escape' 27; JA '__after(80)')
|
||||
Rec 'keyboard Escape in sheet: state' (J 'JSON.stringify({open:document.querySelector("#sheet").open,mode:document.body.dataset.mode})')
|
||||
|
||||
# 7. Forced slow tier: geometry is replaced by a short fade.
|
||||
Open-Page "${url}?theme=moon&tier=2"; [void](Invoke-Js $lib); Wait-Ms 1200
|
||||
[void](Invoke-Js "document.querySelector('#start-talk').click()")
|
||||
Rec 'tier2 click open talk +80ms' (JA '__after(80)')
|
||||
Rec 'atmos' (J 'JSON.stringify(__proto.atmos())')
|
||||
} finally { Stop-Browser }
|
||||
$results | ConvertTo-Json -Depth 8 | Set-Content $out -Encoding utf8
|
||||
@@ -0,0 +1,27 @@
|
||||
param([string]$html = "$PSScriptRoot\..\index.html", [string]$out = "$PSScriptRoot\..\evidence\portal-ab.json", [int]$port = 9343, [int]$runs = 6)
|
||||
# HEL-795 A/B: frame pacing of the click open/close transition with the real portal geometry vs. the same
|
||||
# transition with the geometry tween removed (everything else identical). Headless Edge, software raster - relative only.
|
||||
. "$PSScriptRoot\cdp.ps1"
|
||||
$url = 'file:///' + ((Resolve-Path $html).Path -replace '\\', '/')
|
||||
$fp = "new Promise(r=>{const ts=[];let s=performance.now();(function f(t){ts.push(t);if(t-s<900)requestAnimationFrame(f);else{const d=ts.slice(1).map((x,i)=>x-ts[i]);r(JSON.stringify({frames:d.length,long:d.filter(x=>x>25).length,max:+Math.max(...d).toFixed(1)}))}})(s)})"
|
||||
$noGeo = "(()=>{const p=document.querySelector('#portal'),a=Element.prototype.animate;p.animate=function(k,o){return a.call(this,[{opacity:getComputedStyle(this).opacity},{opacity:getComputedStyle(this).opacity}],o)};return 1})()"
|
||||
$res = [ordered]@{}
|
||||
$null = Start-Browser $port
|
||||
try {
|
||||
foreach ($size in @(@(1440, 900, $false), @(390, 844, $true))) {
|
||||
Set-View $size[0] $size[1] -mobile:$size[2]
|
||||
foreach ($variant in @('geometry', 'no-geometry')) {
|
||||
Open-Page "${url}?theme=moon"; Wait-Ms 1500
|
||||
if ($variant -eq 'no-geometry') { [void](Invoke-Js $noGeo) }
|
||||
$rows = @()
|
||||
for ($i = 0; $i -lt $runs; $i++) {
|
||||
[void](Invoke-Js "document.querySelector('#start-talk').click()"); $rows += (Invoke-Js $fp -await | ConvertFrom-Json); Wait-Ms 500
|
||||
[void](Invoke-Js "document.querySelector('#close-talk').click()"); $rows += (Invoke-Js $fp -await | ConvertFrom-Json); Wait-Ms 500
|
||||
}
|
||||
$k = "$($size[0])x$($size[1]) $variant"
|
||||
$res[$k] = [ordered]@{ transitions = $rows.Count; avgFrames = [math]::Round(($rows | Measure-Object frames -Average).Average, 1); avgLongFrames = [math]::Round(($rows | Measure-Object long -Average).Average, 2); worstFrameMs = ($rows | Measure-Object max -Maximum).Maximum }
|
||||
"$k $($res[$k] | ConvertTo-Json -Compress)"
|
||||
}
|
||||
}
|
||||
} finally { Stop-Browser }
|
||||
$res | ConvertTo-Json -Depth 5 | Set-Content $out -Encoding utf8
|
||||
Reference in New Issue
Block a user