Skip to content

Skip image-paste pasteboard probe in TextInput to avoid main-thread hangs - #59374

Open
cortinico wants to merge 1 commit into
react:mainfrom
cortinico:export-D125922446
Open

cortinico wants to merge 1 commit into
react:mainfrom
cortinico:export-D125922446

Conversation

@cortinico

Copy link
Copy Markdown
Contributor

Summary:
WARNING: Generated by Autopilot (alpha) — review carefully, verify the underlying claim before accepting.
Agent: React Native Agent (Bugs) | Trajectory: https://www.internalfb.com/intern/devai/devmate/inspector/dea80a9f-a635-4ecc-874d-33f0741108ca/ | SC job: https://www.internalfb.com/intern/sandcastle/instance/9007202303535554/


When the app returns to the foreground with a TextInput focused, UIKit refreshes the keyboard's paste support. To decide whether the field supports image paste, UIKit calls -[RCTUITextView canPerformAction:withSender:] with paste:. super then synchronously queries the system pasteboard over XPC on the main thread. If the pasteboard service is slow to reply, the main thread blocks long enough for the system to terminate the app.

This diff overrides supportsImagePaste to return NO in RCTUITextView and RCTUITextField, so UIKit skips that pasteboard query. TextInput only accepts text, so no image paste capability is lost. canPerformAction: and paste: are unchanged, so the edit menu and text paste work as before.

Changelog:
[iOS][Fixed] - Avoid a synchronous main-thread pasteboard query (and possible app hang) when a focused TextInput's keyboard becomes active on app foreground

Reviewed By: cortinico

Differential Revision: D125922446

…angs

Summary:
WARNING: Generated by Autopilot (alpha) — review carefully, verify the underlying claim before accepting.
Agent: [React Native Agent (Bugs)](https://www.internalfb.com/autopilot/marketplace?agent=1645742253726459) | Trajectory: https://www.internalfb.com/intern/devai/devmate/inspector/dea80a9f-a635-4ecc-874d-33f0741108ca/ | SC job: https://www.internalfb.com/intern/sandcastle/instance/9007202303535554/

---

When the app returns to the foreground with a TextInput focused, UIKit refreshes the keyboard's paste support. To decide whether the field supports image paste, UIKit calls `-[RCTUITextView canPerformAction:withSender:]` with `paste:`. `super` then synchronously queries the system pasteboard over XPC on the main thread. If the pasteboard service is slow to reply, the main thread blocks long enough for the system to terminate the app.

This diff overrides `supportsImagePaste` to return `NO` in `RCTUITextView` and `RCTUITextField`, so UIKit skips that pasteboard query. TextInput only accepts text, so no image paste capability is lost. `canPerformAction:` and `paste:` are unchanged, so the edit menu and text paste work as before.

Changelog:
[iOS][Fixed] - Avoid a synchronous main-thread pasteboard query (and possible app hang) when a focused TextInput's keyboard becomes active on app foreground

Reviewed By: cortinico

Differential Revision: D125922446
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 22, 2026
@meta-codesync

meta-codesync Bot commented Oct 22, 2026

Copy link
Copy Markdown

@cortinico has exported this pull request. If you are a Meta employee, you can view the originating Diff in D125922446.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant