Skip to content

fix: web-core touch event cloning#2636

Merged
Sherry-hue merged 1 commit into
lynx-family:mainfrom
PupilTong:codex/clone-touch-events
May 14, 2026
Merged

fix: web-core touch event cloning#2636
Sherry-hue merged 1 commit into
lynx-family:mainfrom
PupilTong:codex/clone-touch-events

Conversation

@PupilTong
Copy link
Copy Markdown
Collaborator

@PupilTong PupilTong commented May 14, 2026

Summary:

  • Always run touches, targetTouches, and changedTouches through toCloneableObject in createCrossThreadEvent.
  • Add regression coverage for synthetic/untrusted touch events so non-cloneable fields are filtered consistently.
  • Add a patch changeset for @lynx-js/web-core.

Validation:

  • pnpm dprint check .changeset/clone-touch-events.md packages/web-platform/web-core/ts/client/mainthread/elementAPIs/createCrossThreadEvent.ts packages/web-platform/web-core/tests/element-apis.spec.ts
  • pnpm build:wasm
  • pnpm exec tsc --build packages/tools/css-serializer/tsconfig.json packages/web-platform/web-worker-rpc/tsconfig.json packages/web-platform/web-elements/tsconfig.json
  • pnpm test tests/element-apis.spec.ts (74 tests)
  • pnpm changeset status --since=upstream/main

Summary by CodeRabbit

  • Bug Fixes

    • Touch event lists are now consistently cloned when creating cross-thread events, ensuring only structured-clone-safe primitive fields are included in synthetic touch events.
  • Tests

    • Added test coverage verifying proper cloning of touch event data during cross-thread event creation.

Review Change Stack

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 14, 2026

🦋 Changeset detected

Latest commit: 96cbb39

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@lynx-js/web-core Patch
upgrade-rspeedy Patch
@lynx-js/web-rsbuild-server-middleware Patch
@lynx-js/template-webpack-plugin Patch
@lynx-js/react-rsbuild-plugin Patch
create-rspeedy Patch
@lynx-js/web-worker-rpc Patch
@lynx-js/react-alias-rsbuild-plugin Patch
@lynx-js/rspeedy Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f1d0b5c6-9adb-4796-8a60-d9a2f0bf5c0a

📥 Commits

Reviewing files that changed from the base of the PR and between 66f6ecf and 96cbb39.

📒 Files selected for processing (3)
  • .changeset/clone-touch-events.md
  • packages/web-platform/web-core/tests/element-apis.spec.ts
  • packages/web-platform/web-core/ts/client/mainthread/elementAPIs/createCrossThreadEvent.ts

📝 Walkthrough

Walkthrough

Touch event handling in createCrossThreadEvent now unconditionally clones touch arrays to ensure only structured-clone-safe primitive fields are included, removing the prior condition that checked domEvent.isTrusted. A test validates this sanitization behavior, and a changelog entry documents the patch-level change.

Changes

Touch Event Cloning

Layer / File(s) Summary
Touch cloning implementation
packages/web-platform/web-core/ts/client/mainthread/elementAPIs/createCrossThreadEvent.ts
Removes the isTrusted branching variable and always maps touches, targetTouches, and changedTouches through toCloneableObject to produce serializable plain objects.
Test validation and release notes
packages/web-platform/web-core/tests/element-apis.spec.ts, .changeset/clone-touch-events.md
New test case verifies untrusted touch events are sanitized to a minimal shape with only primitive fields. Changeset documents the patch-level behavior change.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

platform:Web

Suggested reviewers

  • Sherry-hue

Poem

🐰 Touch events now dance without a trust check,
Cloned and sanitized—no structured wreck!
Plain fields only, safe to serialize,
Cross-thread messages that won't mesmerize.
A patch of safety, hopping through the code! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: fixing touch event cloning in web-core, which is the central objective of the PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@PupilTong PupilTong changed the title [codex] fix web-core touch event cloning fix: web-core touch event cloning May 14, 2026
@PupilTong PupilTong self-assigned this May 14, 2026
@PupilTong PupilTong marked this pull request as ready for review May 14, 2026 08:34
@PupilTong PupilTong requested a review from Sherry-hue as a code owner May 14, 2026 08:34
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 14, 2026

Merging this PR will degrade performance by 25.87%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 2 regressed benchmarks
✅ 78 untouched benchmarks
⏩ 26 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
008-many-use-state-destroyBackground 8 ms 9.5 ms -16.12%
transform 1000 view elements 47.2 ms 44.7 ms +5.43%
basic-performance-large-css 16.1 ms 35.1 ms -53.93%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing PupilTong:codex/clone-touch-events (96cbb39) with main (66f6ecf)

Open in CodSpeed

Footnotes

  1. 26 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 14, 2026

React Example

#8208 Bundle Size — 236.51KiB (0%).

96cbb39(current) vs 66f6ecf main#8200(baseline)

Bundle metrics  no changes
                 Current
#8208
     Baseline
#8200
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 197 197
No change  Duplicate Modules 80 80
No change  Duplicate Code 44.87% 44.87%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#8208
     Baseline
#8200
No change  IMG 145.76KiB 145.76KiB
No change  Other 90.75KiB 90.75KiB

Bundle analysis reportBranch PupilTong:codex/clone-touch-even...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 14, 2026

React External

#1322 Bundle Size — 693.04KiB (0%).

96cbb39(current) vs 66f6ecf main#1314(baseline)

Bundle metrics  no changes
                 Current
#1322
     Baseline
#1314
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 17 17
No change  Duplicate Modules 5 5
No change  Duplicate Code 8.59% 8.59%
No change  Packages 0 0
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#1322
     Baseline
#1314
No change  Other 693.04KiB 693.04KiB

Bundle analysis reportBranch PupilTong:codex/clone-touch-even...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 14, 2026

React MTF Example

#1341 Bundle Size — 207.46KiB (0%).

96cbb39(current) vs 66f6ecf main#1333(baseline)

Bundle metrics  no changes
                 Current
#1341
     Baseline
#1333
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 192 192
No change  Duplicate Modules 77 77
No change  Duplicate Code 44.38% 44.38%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#1341
     Baseline
#1333
No change  IMG 111.23KiB 111.23KiB
No change  Other 96.23KiB 96.23KiB

Bundle analysis reportBranch PupilTong:codex/clone-touch-even...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 14, 2026

Web Explorer

#9782 Bundle Size — 901.35KiB (~-0.01%).

96cbb39(current) vs 66f6ecf main#9775(baseline)

Bundle metrics  Change 2 changes
                 Current
#9782
     Baseline
#9775
No change  Initial JS 45.06KiB 45.06KiB
No change  Initial CSS 2.22KiB 2.22KiB
Change  Cache Invalidation 8.13% 0%
No change  Chunks 9 9
No change  Assets 11 11
Change  Modules 230(+0.88%) 228
No change  Duplicate Modules 11 11
No change  Duplicate Code 27.22% 27.22%
No change  Packages 10 10
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#9782
     Baseline
#9775
Improvement  JS 497.08KiB (~-0.01%) 497.1KiB
No change  Other 402.06KiB 402.06KiB
No change  CSS 2.22KiB 2.22KiB

Bundle analysis reportBranch PupilTong:codex/clone-touch-even...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 14, 2026

React Example with Element Template

#474 Bundle Size — 199.83KiB (0%).

96cbb39(current) vs 66f6ecf main#466(baseline)

Bundle metrics  Change 2 changes
                 Current
#474
     Baseline
#466
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
Change  Modules 87(+2.35%) 85
No change  Duplicate Modules 25 25
Change  Duplicate Code 39.93%(-0.1%) 39.97%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#474
     Baseline
#466
No change  IMG 145.76KiB 145.76KiB
No change  Other 54.08KiB 54.08KiB

Bundle analysis reportBranch PupilTong:codex/clone-touch-even...Project dashboard


Generated by RelativeCIDocumentationReport issue

@Sherry-hue Sherry-hue merged commit ee79eff into lynx-family:main May 14, 2026
83 of 87 checks passed
PupilTong added a commit to PupilTong/lynx-stack that referenced this pull request May 15, 2026
After merging main (lynx-family#2636 dropped the isTrusted touch-cloning gate) the
shifted touch helper became unused, breaking the Ubuntu/Windows build.

Re-apply the lynx-view-relative shift as an addition rather than a
replacement: every touch in `touches`/`targetTouches`/`changedTouches`
now carries a new `x`/`y` pair in lynx-view-local space while keeping
its original `clientX`/`clientY`/`pageX`/`pageY` (viewport/document).
Same shape for mouse events (top-level `x`/`y` lynx-view-relative,
`clientX`-and-friends untouched) and for `click`/`touch*` detail (gains
`clientX`/`clientY`/`pageX`/`pageY` alongside `x`/`y`).

This preserves Web interop (overlays, drag-drop, viewport alignment)
while still giving Lynx handlers the local coordinates they expect.

Touch e2e fixture and changeset updated to match.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants