Skip to content

Prevent parent-routed keyDown re-entry#49

Merged
satoshi-szk merged 3 commits into
novonotes:novonotes-internalfrom
satoshi-assistant:codex/prevent-keydown-reentry
Jul 4, 2026
Merged

Prevent parent-routed keyDown re-entry#49
satoshi-szk merged 3 commits into
novonotes:novonotes-internalfrom
satoshi-assistant:codex/prevent-keydown-reentry

Conversation

@satoshi-assistant

Copy link
Copy Markdown
Contributor

Summary

  • Add a macOS parent-forwarding guard around parent-routed keyDown dispatch.
  • Drop only synchronous nested keyDown re-entry while preserving the initial host delivery.

Why

A local REAPER crash report from 2026-07-04 showed the main thread failing with EXC_BAD_ACCESS / SIGSEGV and Thread stack size exceeded due to excessive recursion. The faulting stack repeatedly involved REAPERSwell_hwnd keyDown, WryWebViewParent::key_down, WKWebView _web_superKeyDown, and WryWebView::key_down, which indicates a host/WebView keyDown bounce while forwarding an event to the parent.

The guard is scoped to the synchronous parent-forwarding window so host shortcuts such as Space still receive the first event, while recursive re-entry is treated as handled.

Validation

  • cargo fmt --check
  • cargo check -p wry

Note: cargo fmt --check still prints the existing stable-rustfmt warning for imports_granularity = Crate, and cargo check -p wry still prints pre-existing deprecation / unnecessary-unsafe warnings.

Some plugin hosts can synchronously bounce a parent-routed keyDown back into the embedded WebView while the original event is still being forwarded. Guarding only that nested dispatch preserves the first host delivery and avoids AppKit recursion that can overflow the main thread stack.
The guard is intentionally narrow, so reviewers and future changes need to understand that it suppresses only synchronous host bounce-back while preserving the first parent-routed event for host shortcuts.
The re-entry guard must only suppress child-wrapper bounce-back. Window WebViews route their first parent delivery to the wrapper itself, so treating every guarded wrapper call as re-entry drops existing parent keyboard routing.
@satoshi-szk
satoshi-szk marked this pull request as ready for review July 4, 2026 14:22
@satoshi-szk
satoshi-szk merged commit 25f9438 into novonotes:novonotes-internal Jul 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants