@@ -90,10 +90,6 @@ const RENDER_SCALE = 2; |
90 | 90 | // Chromium allows three unacked frames, so 100 ms pacing caps viewers near 30 fps. |
91 | 91 | const SCREENCAST_ACK_PACE_MS = 100; |
92 | 92 | const SCREENCAST_SETTLE_MS = 200; |
93 | | -// Only scrolling triggers reduced-quality motion frames; animations stay sharp. |
94 | | -const SCREENCAST_MOTION_FRAMES = 4; |
95 | | -const SCREENCAST_MOTION_WINDOW_MS = 300; |
96 | | -const SCREENCAST_MOTION_QUALITY = 50; |
97 | 93 | const HOST_RECONNECT_DELAY = "1 second"; |
98 | 94 | /** How long a new tab waits for the desktop app to mount it before running headless. */ |
99 | 95 | const DESKTOP_ATTACH_TIMEOUT = "10 seconds"; |
@@ -264,7 +260,6 @@ interface ViewerState { |
264 | 260 | readonly push: (output: ServerBrowserViewerOutput) => void; |
265 | 261 | readonly pause: () => Promise<void>; |
266 | 262 | readonly resume: () => Promise<void>; |
267 | | - scrolledAt: number; |
268 | 263 | /** Last input from this viewer; page copies reach its clipboard only right after. */ |
269 | 264 | inputAt: number; |
270 | 265 | /** Panel bounds, retained in fixed mode; passive viewers never request a size. */ |
@@ -2149,7 +2144,6 @@ const make = Effect.gen(function* () { |
2149 | 2144 | return; |
2150 | 2145 | } |
2151 | 2146 | case "wheel": |
2152 | | - viewer.scrolledAt = Date.now(); |
2153 | 2147 | await session.send("Input.dispatchMouseEvent", { |
2154 | 2148 | type: "mouseWheel", |
2155 | 2149 | x: num(message.x), |
@@ -2288,22 +2282,18 @@ const make = Effect.gen(function* () { |
2288 | 2282 | // Chromium may drop the final frame during a burst; send a still when it settles. |
2289 | 2283 | let framesInFlight = 0; |
2290 | 2284 | let mayHaveDropped = false; |
2291 | | - let motion = false; |
2292 | | - const recentFrames: Array<number> = []; |
2293 | 2285 | let screencastParams = Promise.resolve(); |
2294 | | - let screencastScale = 1; |
2295 | | - const startScreencast = (scale: number) => { |
2296 | | - screencastScale = scale; |
| 2286 | + const startScreencast = () => { |
2297 | 2287 | screencastParams = screencastParams.then(async () => { |
2298 | 2288 | // A scaled capture is rendering; its resume starts the stream. |
2299 | 2289 | if (tab.capturing > 0) return; |
2300 | 2290 | await session.send("Page.stopScreencast").catch(constVoid); |
2301 | 2291 | await session |
2302 | 2292 | .send("Page.startScreencast", { |
2303 | 2293 | format: "jpeg", |
2304 | | - quality: screencastScale < 1 ? Math.min(quality, SCREENCAST_MOTION_QUALITY) : quality, |
2305 | | - maxWidth: Math.max(1, Math.round(input.maxWidth * screencastScale)), |
2306 | | - maxHeight: Math.max(1, Math.round(input.maxHeight * screencastScale)), |
| 2294 | + quality, |
| 2295 | + maxWidth: Math.max(1, Math.round(input.maxWidth)), |
| 2296 | + maxHeight: Math.max(1, Math.round(input.maxHeight)), |
2307 | 2297 | }) |
2308 | 2298 | .catch(constVoid); |
2309 | 2299 | }); |
@@ -2336,8 +2326,7 @@ const make = Effect.gen(function* () { |
2336 | 2326 | ); |
2337 | 2327 | return screencastParams; |
2338 | 2328 | }, |
2339 | | - resume: () => startScreencast(screencastScale), |
2340 | | - scrolledAt: 0, |
| 2329 | + resume: startScreencast, |
2341 | 2330 | inputAt: 0, |
2342 | 2331 | requestedSize: null, |
2343 | 2332 | }; |
@@ -2383,31 +2372,11 @@ const make = Effect.gen(function* () { |
2383 | 2372 | if (framesInFlight > 0) mayHaveDropped = true; |
2384 | 2373 | framesInFlight += 1; |
2385 | 2374 | const arrivedAt = Date.now(); |
2386 | | - recentFrames.push(arrivedAt); |
2387 | | - while (recentFrames[0]! < arrivedAt - SCREENCAST_MOTION_WINDOW_MS) recentFrames.shift(); |
2388 | | - if ( |
2389 | | - !motion && |
2390 | | - recentFrames.length >= SCREENCAST_MOTION_FRAMES && |
2391 | | - arrivedAt - viewer.scrolledAt < SCREENCAST_MOTION_WINDOW_MS |
2392 | | - ) { |
2393 | | - motion = true; |
2394 | | - void startScreencast(0.5); |
2395 | | - } else if (motion && arrivedAt - viewer.scrolledAt > SCREENCAST_SETTLE_MS) { |
2396 | | - // The page keeps animating after the scroll; its own frames are sharp again. |
2397 | | - motion = false; |
2398 | | - recentFrames.length = 0; |
2399 | | - void startScreencast(1); |
2400 | | - } |
2401 | 2375 | if (settleTimer !== null) clearTimeout(settleTimer); |
2402 | 2376 | settleTimer = setTimeout(() => { |
2403 | 2377 | settleTimer = null; |
2404 | | - if (!motion && !mayHaveDropped) return; |
| 2378 | + if (!mayHaveDropped) return; |
2405 | 2379 | mayHaveDropped = false; |
2406 | | - if (motion) { |
2407 | | - motion = false; |
2408 | | - recentFrames.length = 0; |
2409 | | - void startScreencast(1); |
2410 | | - } |
2411 | 2380 | void pushStill(); |
2412 | 2381 | }, SCREENCAST_SETTLE_MS); |
2413 | 2382 | viewer.push({ |
@@ -2424,7 +2393,7 @@ const make = Effect.gen(function* () { |
2424 | 2393 | }); |
2425 | 2394 | }); |
2426 | 2395 | broadcastViewport(tab); |
2427 | | - yield* Effect.promise(() => startScreencast(1)); |
| 2396 | + yield* Effect.promise(startScreencast); |
2428 | 2397 | // An idle page does not repaint for a new screencast, so the viewer |
2429 | 2398 | // starts from a still unless a live frame beat it. |
2430 | 2399 | if (!screencastStarted) yield* Effect.promise(pushStill); |
|