Neither the Selenium nor the Nightwatch adapter publishes a viewport at all — grep -rn "viewport" packages/selenium-devtools/src packages/nightwatch-devtools/src returns nothing. So trace.metadata.viewport is absent for every trace either one produces, and the reader falls back to a hard-coded default in three places (packages/trace/src/trace-exporter.ts:190, :318, :367):
const viewport = trace.metadata.viewport ?? { width: 1280, height: 720 }
That default is what the player lays the DOM-replay iframe out at (packages/app/src/components/browser/snapshot.ts:309 — viewport?.width || 1280), so every Selenium and Nightwatch trace is replayed at 1280x720 regardless of the window the run actually used. It is not a mobile-only problem; a desktop run at 2560x1440 is framed just as wrongly, which is presumably why it went unnoticed — the proportions are plausible.
The WDIO service and the Python adapter both do this already, and they show what it takes:
packages/service/src/session-metadata.ts resolveViewport — reads window.visualViewport for a page (it carries the real scale and offsets, unlike the driver window, which includes browser chrome) and getWindowSize() for a native app, degrading to no viewport rather than failing the session.
packages/selenium-devtools-py/src/selenium_devtools/instrumentation.py _viewport / _driver_window — the same split, with the read marked internal so it does not re-enter the command hook as a captured executeScript/getWindowRect row. Both adapters here would need that same care: Selenium's unpatched getDriverOriginals(), Nightwatch's raw webdriverHttp transport.
isNativeAppSession (shared) already answers which of the two reads applies, so the branch is settled — this is the read itself plus its plumbing into each adapter's metadata.
Worth doing in the same change: metadata.viewport is documented as "metadata only" in a couple of places, and it is not — it is load-bearing geometry wherever there is DOM to replay. Whichever comment survives should say so.
Split out of #372, which covered native detection and deliberately stopped short of this.
Neither the Selenium nor the Nightwatch adapter publishes a
viewportat all —grep -rn "viewport" packages/selenium-devtools/src packages/nightwatch-devtools/srcreturns nothing. Sotrace.metadata.viewportis absent for every trace either one produces, and the reader falls back to a hard-coded default in three places (packages/trace/src/trace-exporter.ts:190,:318,:367):That default is what the player lays the DOM-replay iframe out at (
packages/app/src/components/browser/snapshot.ts:309—viewport?.width || 1280), so every Selenium and Nightwatch trace is replayed at 1280x720 regardless of the window the run actually used. It is not a mobile-only problem; a desktop run at 2560x1440 is framed just as wrongly, which is presumably why it went unnoticed — the proportions are plausible.The WDIO service and the Python adapter both do this already, and they show what it takes:
packages/service/src/session-metadata.tsresolveViewport— readswindow.visualViewportfor a page (it carries the real scale and offsets, unlike the driver window, which includes browser chrome) andgetWindowSize()for a native app, degrading to no viewport rather than failing the session.packages/selenium-devtools-py/src/selenium_devtools/instrumentation.py_viewport/_driver_window— the same split, with the read marked internal so it does not re-enter the command hook as a capturedexecuteScript/getWindowRectrow. Both adapters here would need that same care: Selenium's unpatchedgetDriverOriginals(), Nightwatch's rawwebdriverHttptransport.isNativeAppSession(shared) already answers which of the two reads applies, so the branch is settled — this is the read itself plus its plumbing into each adapter's metadata.Worth doing in the same change:
metadata.viewportis documented as "metadata only" in a couple of places, and it is not — it is load-bearing geometry wherever there is DOM to replay. Whichever comment survives should say so.Split out of #372, which covered native detection and deliberately stopped short of this.