Skip to content

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

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

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

Conversation

@cortinico

@cortinico cortinico commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request resolved: #59374

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: javache, 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.

@github-actions

Copy link
Copy Markdown

Visual regression

No visual differences at 850496b73974.

android: no capture

@meta-codesync meta-codesync Bot closed this in 79c6c23 Oct 23, 2026
@react-native-bot react-native-bot added the Merged This PR has been merged. label Oct 23, 2026
@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by generatedunixname1608173377072046 in 79c6c23

When will my fix make it into a release? | How to file a pick request?

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. Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants