Skip to content

feat: own Three discrete event commits at the renderer boundary - #2111

Merged
domgan-oai merged 2 commits into
octanejs:mainfrom
openai-oss-forks:feat/three-discrete-event-ownership
Oct 15, 2026
Merged

domgan-oai merged 2 commits into
octanejs:mainfrom
openai-oss-forks:feat/three-discrete-event-ownership

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Three's default web event manager uses the DOM renderer's global flushSync for discrete mesh events, making it a Strong dependency boundary and admitting unrelated task-held transitions. Adapt discrete listeners once at event-manager construction so their ordinary DOM updates commit before the native listener returns while deferred transitions keep their scheduler ownership. Continuous event handling is unchanged.

Related to #2059.

Why

Removing the wrapper alone makes a mesh click's DOM update invisible to later native listeners and the dispatching script until a microtask. Three's scene event scope cannot own that cross-renderer DOM commit.

Changes

  • Add an internal renderer-listener adapter to Octane's client/server entry surfaces. Renderer update priority is independent of delegated DOM propagation, preserves nested controlled-input restoration, and does not turn an implicit first root mount into a ViewTransition.
  • Mark Three's event module Strong and coordinate the Octane/Three patch release so consumers receive the internal adapter.
  • Extend existing scheduler and real WebGL browser fixtures with observable listener, first-mount, controlled-input, and deferred-work timing checks.

Validation

  • pnpm format:check (scoped changed-file check passed)
  • pnpm typecheck (affected source selection and Three owning program passed)
  • pnpm test (targeted suites run locally; full workspace delegated to CI)
  • Targeted tests: 158 Octane scheduler/Action/dispatch cases across development and production; 22 Three event and 2 differential cases; 28 release-policy cases. Final-head Three browser integration passed 9/9, including WebGL mesh click, pointer capture/removal, recovery, and production bundlers.
  • Matched production website: clean main d65e896 and signed head 2c48e67; homepage flame hydration, idle rotation, drag/cursor, reduced-motion behavior, client navigation, and canvas teardown match. The homepage uses native canvas listeners, so the separate real mesh fixture is the timing proof: main and candidate expose selected to the later listener and immediately after dispatch; deleting the wrapper exposes idle until the microtask. Both revisions had the same existing Lynx teardown diagnostics after navigation and no failed/HTTP-error requests.
  • Strong analysis: 98 authored website modules, zero diagnostics and no ReactCompat boundary on both; Three src/web/events.ts drops out, leaving Router compiled/MatchLifecycle.tsrx and compiled/RouterProvider.tsrx.
  • Production bytes: complete website public JavaScript, 615 files each, 19,406,640 → 19,406,965 raw (+325) and 4,353,400 → 4,353,003 summed per-file gzip-9 (−397). A no-Three state-hook fixture is +51 raw / +14 gzip / −67 Brotli with identical behavior and module inventory. Neither measurement establishes interaction speed or initial-route payload.
  • pnpm sync passed and left the worktree clean.
  • perf-review: exact d65e896..2c48e67 shipped-source diff scan: 0 candidates. Hot paths: native read scheduling (runtime.ts:1828), Action/update classification (:3298, :3675, :8118), first-root admission (:51790), and discrete listener dispatch (:31614; three/src/web/events.ts:29). No hot-record shape changes, per-event closure, DOM measurement, new task poster, or extra microtask chain. Flag reads are short-circuited behind the relevant Action/native-producer paths; the wrapper is allocated once per discrete listener. The shared-runtime byte cost is measured above; PR benchmark counters and bundle rows remain CI evidence.
  • concise-code: shipped source +72/−10 (Octane runtime +66/−6); one internal adapter exported through paired client/server surfaces, no new runtime module or record field, one release changeset. Deletion breaks same-task DOM timing; reusing delegated propagation depth breaks nested controlled restoration; retaining global flushSync keeps the Strong boundary and admits unrelated deferred work.

Risk / follow-ups

Eligible ordinary work and effects can still commit across roots; the boundary is narrower than an all-priority global flush, not root-isolated. Explicit transitions retain scheduler ownership. Full upstream React Three Fiber parity was not established by these focused checks. The remaining Router boundaries, descriptor elimination, and package declarations/enforcement stay under #2059.

Provenance

  • An agent produced this diff (agent-authored)

Origin: Codex task · host com-79386.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Note

Medium Risk
Touches core update-priority and transition scheduling in runtime.ts; incorrect depth handling could mis-classify urgent vs transition work, though behavior is heavily regression-tested.

Overview
Adds __createDiscreteEventListener, an internal Octane helper that commits urgent renderer work before a native listener returns while not treating that window like an in-flight async Action or deferred transition.

The client scheduler tracks RENDERER_DISCRETE_EVENT_DEPTH so updates during renderer-owned discrete events stay urgent, implicit first-root mounts from those listeners do not queue as ViewTransitions, and unrelated task-held transitions are not admitted. The server stub is a no-op identity wrapper.

@octanejs/three switches discrete canvas handlers from global flushSync to this adapter (module marked use strong) and aligns its Octane peer with coordinated core consumers. Octane and Three get patch changesets; tests cover controlled-input nesting, async-Action interaction, and a real WebGL mesh click proving DOM updates are visible before dispatch returns.

Reviewed by Cursor Bugbot for commit 2c48e67. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent feat PR: new feature or capability labels Oct 15, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review October 15, 2026 23:32
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 67 value(s) increased
  • 🔴 bundle-reachability: 77 value(s) increased

Compares d65e89623, the merge commit's first parent with d3e8485ab on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 3.108 2.958 ±0.0% −4.6% … +3.7% ⚪ within noise
octane-tsrx replace 7.975 7.492 +0.7% −3.3% … +5.1% ⚪ within noise
octane-tsrx add 2.842 3.058 −0.0% −3.7% … +5.6% ⚪ within noise
octane-tsrx update 0.174 0.175 +3.7% −3.2% … +13.6% ⚪ within noise
octane-tsrx select 0.007 0.007 +2.9% −3.2% … +11.2% ⚪ within noise
octane-tsrx swap 0.025 0.026 +1.7% −3.8% … +7.8% ⚪ within noise
octane-tsrx remove 0.027 0.026 −5.2% −7.9% … +6.8% ⚪ within noise
octane-tsrx runlots 38.425 40.300 +4.4% −4.1% … +19.4% ⚪ within noise
octane-tsrx select_lots 0.009 0.008 +2.0% −4.3% … +6.6% ⚪ within noise
octane-tsrx clear 89.325 90.958 +2.7% −5.3% … +7.6% ⚪ within noise
octane-jsx run 5.925 5.958 +0.7% −10.9% … +10.1% ⚪ within noise
octane-jsx replace 15.208 14.742 −4.3% −17.7% … +1.3% ⚪ within noise
octane-jsx add 5.683 5.883 +3.2% −4.9% … +18.6% ⚪ within noise
octane-jsx update 0.425 0.403 −7.1% −13.9% … +0.5% ⚪ within noise
octane-jsx select 0.191 0.181 −4.8% −8.6% … +11.4% ⚪ within noise
octane-jsx swap 0.223 0.224 +1.9% −4.9% … +9.1% ⚪ within noise
octane-jsx remove 0.268 0.270 −2.9% −7.6% … +5.4% ⚪ within noise
octane-jsx runlots 34.933 33.400 −3.2% −5.8% … +1.0% ⚪ within noise
octane-jsx select_lots 2.053 2.121 +0.4% −4.0% … +9.7% ⚪ within noise
octane-jsx clear 56.025 63.367 +6.7% −0.9% … +12.5% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

target metric base head Δ
octane-tsrx js_raw 87,542 87,594 +52 (+0.1%) 🔴
octane-tsrx js_gzip 29,181 29,203 +22 (+0.1%) 🔴
octane-tsrx js_brotli 26,068 26,137 +69 (+0.3%) 🔴
octane-tsrx app_gzip 2,337 2,335 −2 (−0.1%) 🟢
octane-tsrx app_brotli 2,028 2,032 +4 (+0.2%) 🔴
octane-tsrx fw_raw 80,590 80,642 +52 (+0.1%) 🔴
octane-tsrx fw_gzip 26,844 26,868 +24 (+0.1%) 🔴
octane-tsrx fw_brotli 24,040 24,105 +65 (+0.3%) 🔴
octane-tsrx todo_js_raw 100,282 100,334 +52 (+0.1%) 🔴
octane-tsrx todo_js_gzip 33,788 33,812 +24 (+0.1%) 🔴
octane-tsrx todo_js_brotli 30,093 30,069 −24 (−0.1%) 🟢
octane-tsrx todo_app_gzip 2,234 2,235 +1 (+0.0%) 🔴
octane-tsrx todo_app_brotli 1,893 1,896 +3 (+0.2%) 🔴
octane-tsrx todo_fw_raw 95,643 95,695 +52 (+0.1%) 🔴
octane-tsrx todo_fw_gzip 31,554 31,577 +23 (+0.1%) 🔴
octane-tsrx todo_fw_brotli 28,200 28,173 −27 (−0.1%) 🟢
octane-tsrx chat_js_raw 99,618 99,670 +52 (+0.1%) 🔴
octane-tsrx chat_js_gzip 33,703 33,731 +28 (+0.1%) 🔴
octane-tsrx chat_js_brotli 30,060 30,074 +14 (+0.0%) 🔴
octane-tsrx chat_app_brotli 2,400 2,390 −10 (−0.4%) 🟢
octane-tsrx chat_fw_raw 93,841 93,893 +52 (+0.1%) 🔴
octane-tsrx chat_fw_gzip 30,980 31,008 +28 (+0.1%) 🔴
octane-tsrx chat_fw_brotli 27,660 27,684 +24 (+0.1%) 🔴
octane-tsrx weather_js_raw 134,344 134,396 +52 (+0.0%) 🔴
octane-tsrx weather_js_gzip 44,567 44,587 +20 (+0.0%) 🔴
octane-tsrx weather_js_brotli 39,331 39,360 +29 (+0.1%) 🔴
octane-tsrx weather_app_brotli 6,681 6,679 −2 (−0.0%) 🟢
octane-tsrx weather_fw_raw 112,188 112,240 +52 (+0.0%) 🔴
octane-tsrx weather_fw_gzip 36,687 36,707 +20 (+0.1%) 🔴
octane-tsrx weather_fw_brotli 32,650 32,681 +31 (+0.1%) 🔴
octane-tsrx bindings_js_raw 681,325 681,412 +87 (+0.0%) 🔴
octane-tsrx bindings_js_gzip 224,424 224,444 +20 (+0.0%) 🔴
octane-tsrx bindings_js_brotli 191,022 191,013 −9 (−0.0%) 🟢
octane-tsrx bindings_app_gzip 115,661 115,660 −1 (−0.0%) 🟢
octane-tsrx bindings_app_brotli 96,191 96,222 +31 (+0.0%) 🔴
octane-tsrx bindings_fw_raw 333,598 333,685 +87 (+0.0%) 🔴
octane-tsrx bindings_fw_gzip 108,763 108,784 +21 (+0.0%) 🔴
octane-tsrx bindings_fw_brotli 94,831 94,791 −40 (−0.0%) 🟢
octane-tsrx wayfinder_js_raw 458,227 458,315 +88 (+0.0%) 🔴
octane-tsrx wayfinder_js_gzip 149,137 149,175 +38 (+0.0%) 🔴
octane-tsrx wayfinder_js_brotli 129,102 129,097 −5 (−0.0%) 🟢
octane-tsrx threadline_oxc_js_raw 146,296 146,348 +52 (+0.0%) 🔴
octane-tsrx threadline_oxc_js_gzip 49,055 49,080 +25 (+0.1%) 🔴
octane-tsrx threadline_oxc_js_brotli 43,001 42,996 −5 (−0.0%) 🟢
octane-tsrx threadline_esbuild_js_raw 173,566 173,656 +90 (+0.1%) 🔴
octane-tsrx threadline_esbuild_js_gzip 58,300 58,339 +39 (+0.1%) 🔴
octane-tsrx threadline_esbuild_js_brotli 50,850 50,926 +76 (+0.1%) 🔴
octane-tsrx pagecraft_oxc_js_raw 541,689 541,777 +88 (+0.0%) 🔴
octane-tsrx pagecraft_oxc_js_gzip 169,656 169,671 +15 (+0.0%) 🔴
octane-tsrx pagecraft_oxc_js_brotli 143,415 143,442 +27 (+0.0%) 🔴
octane-tsrx pagecraft_esbuild_js_raw 591,929 592,025 +96 (+0.0%) 🔴
octane-tsrx pagecraft_esbuild_js_gzip 189,079 189,145 +66 (+0.0%) 🔴
octane-tsrx pagecraft_esbuild_js_brotli 159,903 159,773 −130 (−0.1%) 🟢
octane-tsrx full_fw_raw 571,801 572,063 +262 (+0.0%) 🔴
octane-tsrx full_fw_gzip 173,010 173,089 +79 (+0.0%) 🔴
octane-tsrx full_fw_brotli 145,746 145,783 +37 (+0.0%) 🔴
octane-jsx js_raw 167,246 167,296 +50 (+0.0%) 🔴
octane-jsx js_gzip 54,259 54,305 +46 (+0.1%) 🔴
octane-jsx js_brotli 47,626 47,643 +17 (+0.0%) 🔴
octane-jsx app_gzip 2,860 2,857 −3 (−0.1%) 🟢
octane-jsx app_brotli 2,423 2,422 −1 (−0.0%) 🟢
octane-jsx fw_raw 158,975 159,025 +50 (+0.0%) 🔴
octane-jsx fw_gzip 51,399 51,448 +49 (+0.1%) 🔴
octane-jsx fw_brotli 45,203 45,221 +18 (+0.0%) 🔴
octane-jsx shell_js_raw 390,493 390,589 +96 (+0.0%) 🔴
octane-jsx shell_js_gzip 122,653 122,720 +67 (+0.1%) 🔴
octane-jsx shell_js_brotli 104,719 104,818 +99 (+0.1%) 🔴
octane-jsx shell_app_brotli 677 670 −7 (−1.0%) 🟢
octane-jsx shell_fw_raw 389,400 389,496 +96 (+0.0%) 🔴
octane-jsx shell_fw_gzip 121,887 121,954 +67 (+0.1%) 🔴
octane-jsx shell_fw_brotli 104,042 104,148 +106 (+0.1%) 🔴
octane-jsx shell_client_js_raw 324,844 324,940 +96 (+0.0%) 🔴
octane-jsx shell_client_js_gzip 101,505 101,592 +87 (+0.1%) 🔴
octane-jsx shell_client_js_brotli 87,459 87,572 +113 (+0.1%) 🔴
octane-jsx shell_client_app_gzip 770 772 +2 (+0.3%) 🔴
octane-jsx shell_client_app_brotli 670 659 −11 (−1.6%) 🟢
octane-jsx shell_client_fw_raw 323,743 323,839 +96 (+0.0%) 🔴
octane-jsx shell_client_fw_gzip 100,735 100,820 +85 (+0.1%) 🔴
octane-jsx shell_client_fw_brotli 86,789 86,913 +124 (+0.1%) 🔴
octane-jsx full_fw_raw 571,801 572,063 +262 (+0.0%) 🔴
octane-jsx full_fw_gzip 173,010 173,089 +79 (+0.0%) 🔴
octane-jsx full_fw_brotli 145,746 145,783 +37 (+0.0%) 🔴

11 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
cli-spa-starter raw 80,910 80,945 +35 (+0.0%) 🔴
cli-spa-starter gzip 27,848 27,869 +21 (+0.1%) 🔴
cli-spa-starter brotli 24,733 24,814 +81 (+0.3%) 🔴
root-static-specialized raw 52,955 52,989 +34 (+0.1%) 🔴
root-static-specialized gzip 18,041 18,064 +23 (+0.1%) 🔴
root-static-specialized brotli 16,362 16,381 +19 (+0.1%) 🔴
root-chained-jsx raw 54,290 54,324 +34 (+0.1%) 🔴
root-chained-jsx gzip 18,430 18,448 +18 (+0.1%) 🔴
root-chained-jsx brotli 16,731 16,740 +9 (+0.1%) 🔴
root-static raw 148,773 148,808 +35 (+0.0%) 🔴
root-static gzip 48,261 48,287 +26 (+0.1%) 🔴
root-static brotli 42,470 42,562 +92 (+0.2%) 🔴
root-static-local raw 52,855 52,889 +34 (+0.1%) 🔴
root-static-local gzip 17,987 17,995 +8 (+0.0%) 🔴
root-static-local brotli 16,334 16,333 −1 (−0.0%) 🟢
root-callback-local raw 54,671 54,705 +34 (+0.1%) 🔴
root-callback-local gzip 18,513 18,542 +29 (+0.2%) 🔴
root-callback-local brotli 16,877 16,869 −8 (−0.0%) 🟢
hooks-state raw 62,298 62,349 +51 (+0.1%) 🔴
hooks-state gzip 20,959 20,968 +9 (+0.0%) 🔴
hooks-state brotli 19,043 18,976 −67 (−0.4%) 🟢
prop-attributes raw 59,402 59,453 +51 (+0.1%) 🔴
prop-attributes gzip 20,086 20,115 +29 (+0.1%) 🔴
prop-attributes brotli 18,197 18,237 +40 (+0.2%) 🔴
context raw 69,716 69,767 +51 (+0.1%) 🔴
context gzip 23,269 23,303 +34 (+0.1%) 🔴
context brotli 20,990 21,019 +29 (+0.1%) 🔴
hydrate-root raw 108,832 108,867 +35 (+0.0%) 🔴
hydrate-root gzip 35,830 35,852 +22 (+0.1%) 🔴
hydrate-root brotli 31,767 31,766 −1 (−0.0%) 🟢
deferred-hydration raw 191,633 191,685 +52 (+0.0%) 🔴
deferred-hydration gzip 61,242 61,261 +19 (+0.0%) 🔴
deferred-hydration brotli 53,377 53,404 +27 (+0.1%) 🔴
hydrate-frame raw 340,771 340,861 +90 (+0.0%) 🔴
hydrate-frame gzip 108,286 108,297 +11 (+0.0%) 🔴
hydrate-frame brotli 93,064 92,986 −78 (−0.1%) 🟢
suspense-transition raw 123,707 123,794 +87 (+0.1%) 🔴
suspense-transition gzip 39,674 39,718 +44 (+0.1%) 🔴
suspense-transition brotli 35,201 35,251 +50 (+0.1%) 🔴
component-owned-effects raw 55,772 55,806 +34 (+0.1%) 🔴
component-owned-effects gzip 18,921 18,941 +20 (+0.1%) 🔴
component-owned-effects brotli 17,155 17,176 +21 (+0.1%) 🔴
binding-hooks raw 64,952 64,986 +34 (+0.1%) 🔴
binding-hooks gzip 22,121 22,140 +19 (+0.1%) 🔴
binding-hooks brotli 20,014 20,023 +9 (+0.0%) 🔴
split-shell raw 415,287 415,383 +96 (+0.0%) 🔴
split-shell gzip 133,040 133,065 +25 (+0.0%) 🔴
split-shell brotli 114,538 114,622 +84 (+0.1%) 🔴
split-shell-runtime raw 332,442 332,538 +96 (+0.0%) 🔴
split-shell-runtime gzip 105,546 105,569 +23 (+0.0%) 🔴
split-shell-runtime brotli 89,941 90,045 +104 (+0.1%) 🔴
binding-base-ui-vite raw 189,900 189,987 +87 (+0.0%) 🔴
binding-base-ui-vite gzip 61,162 61,206 +44 (+0.1%) 🔴
binding-base-ui-vite brotli 53,509 53,532 +23 (+0.0%) 🔴
binding-base-ui-esbuild raw 217,238 217,326 +88 (+0.0%) 🔴
binding-base-ui-esbuild gzip 70,740 70,775 +35 (+0.0%) 🔴
binding-base-ui-esbuild brotli 61,480 61,516 +36 (+0.1%) 🔴
binding-aria-esbuild brotli 2,808 2,812 +4 (+0.1%) 🔴
binding-radix-vite raw 190,264 190,351 +87 (+0.0%) 🔴
binding-radix-vite gzip 61,035 61,063 +28 (+0.0%) 🔴
binding-radix-vite brotli 53,441 53,472 +31 (+0.1%) 🔴
binding-radix-esbuild raw 217,384 217,472 +88 (+0.0%) 🔴
binding-radix-esbuild gzip 70,659 70,684 +25 (+0.0%) 🔴
binding-radix-esbuild brotli 61,448 61,483 +35 (+0.1%) 🔴
binding-mantine-hooks-vite raw 62,955 63,006 +51 (+0.1%) 🔴
binding-mantine-hooks-vite gzip 21,386 21,406 +20 (+0.1%) 🔴
binding-mantine-hooks-vite brotli 19,371 19,399 +28 (+0.1%) 🔴
binding-mantine-hooks-esbuild raw 74,674 74,756 +82 (+0.1%) 🔴
binding-mantine-hooks-esbuild gzip 25,961 26,005 +44 (+0.2%) 🔴
binding-mantine-hooks-esbuild brotli 23,280 23,368 +88 (+0.4%) 🔴
binding-apollo-client-vite raw 332,216 332,306 +90 (+0.0%) 🔴
binding-apollo-client-vite gzip 103,454 103,462 +8 (+0.0%) 🔴
binding-apollo-client-vite brotli 90,746 90,785 +39 (+0.0%) 🔴
binding-apollo-client-esbuild raw 367,533 367,621 +88 (+0.0%) 🔴
binding-apollo-client-esbuild gzip 117,174 117,223 +49 (+0.0%) 🔴
binding-apollo-client-esbuild brotli 102,319 102,469 +150 (+0.1%) 🔴
binding-usehooks-ts-vite raw 63,737 63,788 +51 (+0.1%) 🔴
binding-usehooks-ts-vite gzip 21,594 21,618 +24 (+0.1%) 🔴
binding-usehooks-ts-vite brotli 19,569 19,614 +45 (+0.2%) 🔴
binding-usehooks-ts-esbuild raw 75,442 75,524 +82 (+0.1%) 🔴
binding-usehooks-ts-esbuild gzip 26,191 26,224 +33 (+0.1%) 🔴
binding-usehooks-ts-esbuild brotli 23,553 23,607 +54 (+0.2%) 🔴

38 other measured values are unchanged.

@domgan-oai
domgan-oai merged commit 5dc82f5 into octanejs:main Oct 15, 2026
53 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent feat PR: new feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant