Repository navigation
fix(gestures): each document's gesture host reads that window's clock - #11155
Conversation
A same-origin iframe or a Picture-in-Picture window stamps its events on its own window's clock, which reads less than the page's. A long press in an iframe gets a 120 ms tap stamped on that clock, and it may not begin. A second case pins the page's own clock object for the page's document.
A gesture host built every document's arena on the page's clock. In a same-origin iframe or a Picture-in-Picture window, events come stamped on that window's own clock, so the arena's timers ran early: a long press began on a short tap. The host now reads the clock of its document's window, and an epoch stamp converts with that window's time origin. The page's document keeps the page's clock object, so nothing changes there.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC |
|---|---|---|
| lab/TabBar | 81.9 kB (+134 B) · 1.8 kB CSS (0) | — |
| lab/ChatVirtualizer | 55.7 kB (+119 B) · 144 B CSS (0) | — |
| ButtonGroup | 42.6 kB (+115 B) · 3.7 kB CSS (0) | — |
113 more components
| Component | Size | LoC |
|---|---|---|
| lab/CommentThread | 348.8 kB (+113 B) · 2.4 kB CSS (0) | — |
| lab/PageControl | 75.7 kB (+109 B) · 709 B CSS (0) | — |
| ToggleButtonGroup | 39.9 kB (+108 B) · 3.7 kB CSS (0) | — |
| lab/NavigationScreen | 83.5 kB (+105 B) · 1.5 kB CSS (0) | — |
| lab/NavigationStack | 83.5 kB (+105 B) · 1.5 kB CSS (0) | — |
| Switch | 105.5 kB (+100 B) · 10.0 kB CSS (0) | — |
| AlertDialog | 107.9 kB (+97 B) · 14.6 kB CSS (0) | — |
| DateTimeInput | 211.7 kB (+95 B) · 18.7 kB CSS (0) | — |
| Lightbox | 124.7 kB (+84 B) · 10.6 kB CSS (0) | — |
| richtext/RichTextEditorToolbar | 281.4 kB (+83 B) · 454 B CSS (0) | — |
| Toast | 99.9 kB (+78 B) · 10.3 kB CSS (0) | — |
| lab/Comments | 355.6 kB (+72 B) · 2.5 kB CSS (0) | — |
| SegmentedControl | 99.4 kB (+71 B) · 6.9 kB CSS (0) | — |
| ToggleButton | 88.8 kB (+69 B) · 10.1 kB CSS (0) | — |
| lab/Schedule | 108.4 kB (+69 B) · 3.9 kB CSS (0) | — |
| Slider | 110.9 kB (+67 B) · 8.8 kB CSS (0) | — |
| DateInput | 189.6 kB (+63 B) · 17.1 kB CSS (0) | — |
| PowerSearch | 292.8 kB (+62 B) · 24.2 kB CSS (0) | — |
| TimeInput | 164.8 kB (+60 B) · 16.1 kB CSS (0) | — |
| AppShell | 93.7 kB (0) · 13.5 kB CSS (0) | — |
| AvatarGroupOverflow | 50.4 kB (0) · 5.7 kB CSS (0) | — |
| Banner | 63.9 kB (0) · 10.5 kB CSS (0) | — |
| BaseTypeahead | 73.8 kB (0) · 11.0 kB CSS (0) | — |
| BreadcrumbItem | 86.7 kB (0) · 12.1 kB CSS (0) | — |
| Button | 62.0 kB (0) · 10.0 kB CSS (0) | — |
| Calendar | 72.9 kB (0) · 10.6 kB CSS (0) | — |
| Carousel | 71.7 kB (0) · 11.0 kB CSS (0) | — |
| ChatComposer | 80.5 kB (0) · 12.1 kB CSS (0) | — |
| ChatComposerInput | 78.1 kB (0) · 11.3 kB CSS (0) | — |
| ChatComposerTokenElement | 78.1 kB (0) · 11.3 kB CSS (0) | — |
| ChatDictationButton | 62.5 kB (0) · 10.1 kB CSS (0) | — |
| ChatLayout | 84.8 kB (0) · 10.6 kB CSS (0) | — |
| ChatLayoutScrollButton | 62.5 kB (0) · 10.2 kB CSS (0) | — |
| ChatSendButton | 62.4 kB (0) · 10.0 kB CSS (0) | — |
| CheckboxInput | 66.0 kB (0) · 9.2 kB CSS (0) | — |
| CheckboxListItem | 73.0 kB (0) · 11.5 kB CSS (0) | — |
| ClickableCard | 18.1 kB (0) · 7.3 kB CSS (0) | — |
| CodeBlock | 77.1 kB (0) · 11.3 kB CSS (0) | — |
| Collapsible | 28.5 kB (0) · 4.5 kB CSS (0) | — |
| CommandPalette | 74.9 kB (0) · 12.7 kB CSS (0) | — |
| CommandPaletteItem | 13.1 kB (0) · 3.6 kB CSS (0) | — |
| ComplexSelector | 73.0 kB (0) · 11.9 kB CSS (0) | — |
| ContextMenu | 111.0 kB (0) · 17.5 kB CSS (0) | — |
| ContextMenuItem | 32.9 kB (0) · 6.3 kB CSS (0) | — |
| DateRangeInput | 95.0 kB (0) · 12.5 kB CSS (0) | — |
| DialogHeader | 64.8 kB (0) · 11.5 kB CSS (0) | — |
| DrawerHeader | 64.9 kB (0) · 13.0 kB CSS (0) | — |
| DropdownMenu | 99.1 kB (0) · 17.6 kB CSS (0) | — |
| DropdownMenuCheckboxItem | 23.4 kB (0) · 6.6 kB CSS (0) | — |
| DropdownMenuItem | 22.6 kB (0) · 6.3 kB CSS (0) | — |
| DropdownMenuRadioItem | 23.4 kB (0) · 6.6 kB CSS (0) | — |
| DropdownMenuSubMenu | 72.0 kB (0) · 9.7 kB CSS (0) | — |
| FileInput | 70.9 kB (0) · 11.0 kB CSS (0) | — |
| IconButton | 62.0 kB (0) · 10.0 kB CSS (0) | — |
| Item | 17.6 kB (0) · 5.5 kB CSS (0) | — |
| Link | 54.7 kB (0) · 7.1 kB CSS (0) | — |
| ListItem | 72.1 kB (0) · 11.5 kB CSS (0) | — |
| Markdown | 190.8 kB (0) · 20.8 kB CSS (0) | — |
| MobileNav | 72.5 kB (0) · 10.6 kB CSS (0) | — |
| MobileNavToggle | 62.3 kB (0) · 10.0 kB CSS (0) | — |
| MoreMenu | 99.3 kB (0) · 17.6 kB CSS (0) | — |
| MultiSelector | 97.0 kB (0) · 16.9 kB CSS (0) | — |
| NavHeadingMenu | 16.9 kB (0) · 3.5 kB CSS (0) | — |
| NumberInput | 73.5 kB (0) · 11.5 kB CSS (0) | — |
| Outline | 24.9 kB (0) · 4.1 kB CSS (0) | — |
| Pagination | 112.5 kB (0) · 17.8 kB CSS (0) | — |
| Popover | 93.0 kB (0) · 14.2 kB CSS (0) | — |
| RadioListItem | 69.1 kB (0) · 10.2 kB CSS (0) | — |
| SegmentedControlItem | 17.5 kB (0) · 4.3 kB CSS (0) | — |
| SelectableCard | 18.3 kB (0) · 7.5 kB CSS (0) | — |
| Selector | 102.4 kB (0) · 17.4 kB CSS (0) | — |
| SelectorOption | 21.2 kB (0) · 6.1 kB CSS (0) | — |
| SideNav | 116.8 kB (0) · 11.4 kB CSS (0) | — |
| SideNavCollapseButton | 62.8 kB (0) · 10.1 kB CSS (0) | — |
| SideNavHeading | 77.6 kB (0) · 11.3 kB CSS (0) | — |
| SideNavItem | 72.4 kB (0) · 11.2 kB CSS (0) | — |
| Step | 31.2 kB (0) · 5.6 kB CSS (0) | — |
| Stepper | 63.6 kB (0) · 10.2 kB CSS (0) | — |
| Tab | 14.5 kB (0) · 4.2 kB CSS (0) | — |
| Table | 127.8 kB (0) · 18.4 kB CSS (0) | — |
| TableCell | 112.2 kB (0) · 17.9 kB CSS (0) | — |
| TableHeaderCell | 111.8 kB (0) · 17.7 kB CSS (0) | — |
| TableSelectionToolbar | 72.3 kB (0) · 13.3 kB CSS (0) | — |
| TabMenu | 73.9 kB (0) · 11.2 kB CSS (0) | — |
| TextInput | 69.6 kB (0) · 11.2 kB CSS (0) | — |
| Thumbnail | 66.3 kB (0) · 11.6 kB CSS (0) | — |
| Timestamp | 34.7 kB (0) · 10.3 kB CSS (0) | — |
| Token | 28.7 kB (0) · 4.7 kB CSS (0) | — |
| Tokenizer | 94.5 kB (0) · 18.8 kB CSS (0) | — |
| TopNav | 74.3 kB (0) · 11.0 kB CSS (0) | — |
| TopNavHeading | 77.2 kB (0) · 11.3 kB CSS (0) | — |
| TopNavItem | 14.1 kB (0) · 4.0 kB CSS (0) | — |
| TopNavMegaMenu | 71.7 kB (0) · 11.9 kB CSS (0) | — |
| TopNavMegaMenuItem | 13.8 kB (0) · 4.2 kB CSS (0) | — |
| TopNavMenu | 76.6 kB (0) · 11.3 kB CSS (0) | — |
| TreeList | 45.7 kB (0) · 5.6 kB CSS (0) | — |
| Typeahead | 82.7 kB (0) · 12.5 kB CSS (0) | — |
| lab/ChatEmojiPicker | 108.2 kB (0) · 773 B CSS (0) | — |
| lab/ChatReactionBar | 109.4 kB (0) · 1.1 kB CSS (0) | — |
| lab/CommentComposer | 154.4 kB (0) · 1.9 kB CSS (0) | — |
| lab/CommentPin | 58.9 kB (0) · 1.2 kB CSS (0) | — |
| lab/DialogHeroHeader | 85.0 kB (0) · 372 B CSS (0) | — |
| lab/DiffViewer | 89.1 kB (0) · 2.1 kB CSS (0) | — |
| lab/EmojiPicker | 88.7 kB (0) · 751 B CSS (0) | — |
| lab/ListInput | 90.0 kB (0) · 922 B CSS (0) | — |
| lab/SelectableCardGroup | 66.1 kB (0) · 162 B CSS (0) | — |
| lab/TabBarItem | 3.9 kB (0) · 1.8 kB CSS (0) | — |
| lab/TabBarMoreList | 94.2 kB (0) · 1.8 kB CSS (0) | — |
| lab/TourStep | 99.2 kB (0) · 590 B CSS (0) | — |
| lab/TransferList | 104.1 kB (0) · 1.2 kB CSS (0) | — |
| lab/TransferListSelector | 111.9 kB (0) · 1.4 kB CSS (0) | — |
| richtext/RichTextEditor | 300.2 kB (0) · 2.6 kB CSS (0) | — |
| richtext/RichTextView | 278.5 kB (0) · 2.3 kB CSS (0) | — |
Package size: @astryxdesign/core 7.30 MB packed (+765 B); no new dependencies.
Not run on this PR: add ci:run-visual or ci:run-rtl to run them.
Generated by PR Enrichment workflow | View full report
|
/approve-spec 93d0770 |
There was a problem hiding this comment.
Changes requested. The fix itself is right: the new case fails on main and passes here, and the page's own document keeps the same clock object. One change is needed before it lands:
GestureHost.ts:924-926copies the window-clock lookup thatclockOfinutils/inputAge.tsalready owns, anddocumentClockreads it again; takethis.timingfrom oneclockOf(doc)call, build the arena clock from it, and widenEventClocktoPick<Performance, 'now' | 'timeOrigin'>soeventTimekeeps its epoch conversion.
CI has not run on this head yet.
The gesture host read its document's window clock itself, a copy of the lookup that clockOf in the input-age utility owns for the press tracker and the long-press hold. The host now takes that clock from one clockOf call and builds the arena clock from it. EventClock gains the time origin, so an epoch stamp still converts on that clock. In the page's document clockOf returns the page's own performance, so the host keeps the same clock object.
|
/approve-spec 220119c |
There was a problem hiding this comment.
Approved pending CI. CI has not run on this head yet: it starts once the pull request is marked ready for review.
The host now takes its window's clock from clockOf, which resolves the earlier change request. The new long-press case fails on main and passes here, and in Chromium a 120 ms tap in a same-origin iframe or a Picture-in-Picture window no longer starts a 500 ms long press, while the page's own document keeps its clock object.
|
/approve-spec 220119c |
Fake timers replace the page's performance object after the gesture host exists. A hold that starts then must begin at its deadline: the touch's epoch stamp converts on the clock the page has now.
The host kept the clock object its window had when the host was made. A page that replaces it later, as fake timers do, then converted touch stamps on a stale origin, so a hold began far from its deadline. The host now looks the clock up at each read. The page's own document keeps the page's clock, found by its window.
|
/approve-spec 99175c7 |
There was a problem hiding this comment.
Approved pending CI. CI has not run on this head yet: it starts once the pull request is marked ready for review.
The host now looks up its window's clock through clockOf at each event, which fixes the PageControl hold case that CI failed on the previous revision; the new case for a clock replaced after the host exists fails there and passes here. The iframe long-press case still fails on main and passes here, and in Chromium a 120 ms tap in a same-origin iframe no longer starts a 500 ms long press while the page's own document keeps its timing.
User impact
An app can render a component into a same-origin iframe or a Document Picture-in-Picture window through a portal. Under a finger there, every timed gesture runs early. A long press begins on a short tap, and the press can claim the finger, so the tap loses its click. This restores the timing that the page's own document already has.
Problem and solution fit
The fix gives each host its own window's clock, so an event's time and the arena's clock share one origin.
Expected behavior and authority
spec:AST-094FR16: recognizers read time from the input events' timestamps, and a long press is a deadline on that clock. An event'stimeStampcounts from the time origin of its own window (High Resolution Time).LongPressGestureRecognizerbegins only afterminimumPressDuration. In the page's document the arena already meets both.Smallest restoration
GestureHostlooks up its document's window clock throughclockOfat each read. For the page's document, the arena clock is the samebrowserClockobject as before. For another window, it is a copy whosenow()reads that window'sperformance.now().eventTimeconverts an epoch-stamped event with that window's time origin. In the page's document it reads the sameperformanceobject as before.Beyond
GestureHost.ts, only the internalEventClocktype changes: it gainstimeOrigin. There is no new API.Evidence
browserClockitself. A third starts a hold after fake timers replace the page's clock; it fails at 220119c.Scope
Components: gestures
Testing
The first CI run at 220119c failed lab's PageControl hold case. That head kept the clock object its window had when the host was made. Fake timers replace that object, so touch stamps converted on a stale origin, and the hold began late. This head looks the clock up at each read.
Local checks at 99175c7, one worker:
GestureHostclock cases: at cf8a455 the iframe case fails; at 220119c the replaced-clock case fails; at this head all three pass;uiproject: 220119c fails in 20 of 20 runs, main passes in 20 of 20, this head passes in 20 of 20;test:ui --changed): 481 files, 14,331 passed; the core typecheck, eslint ongestures/, check:changesets and check:knowledge;Public and internal API delta
Public: none.
Internal, changed:
EventClockinutils/inputAge.tswidens fromPick<Performance, 'now'>toPick<Performance, 'now' | 'timeOrigin'>.GestureHost.tspassesclockOf(doc), read at each event, to its event-time read, which subtractstimeOriginfrom an epoch-stamped event. An epoch stamp converts only with its own window's origin.GestureHost.tsandlongPressDetector.tsimport the type.Usage:
const clock: EventClock | null = clockOf(doc);No new module, hook or exported function:
clockOfis already on main, so no owning-record line is needed.Lines: product +67/−34 (
GestureHost.ts+62/−32,inputAge.ts+5/−2), tests +100/−0, changeset +7/−0.App-level size, eager JS gzip of the
example-vitepage in a Vite production build: no change as shipped or with one ContextMenu; +67 B with one Switch, which loads the gesture host.