Skip to content

Fix main-thread watchdog hang in PushNotificationIOS.setApplicationIconBadgeNumber (#57707) - #57707

Closed
christophpurrer wants to merge 1 commit into
react:mainfrom
christophpurrer:export-D113810036
Closed

Fix main-thread watchdog hang in PushNotificationIOS.setApplicationIconBadgeNumber (#57707)#57707
christophpurrer wants to merge 1 commit into
react:mainfrom
christophpurrer:export-D113810036

Conversation

@christophpurrer

@christophpurrer christophpurrer commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary:

Adopts the non-blocking -[UNUserNotificationCenter setBadgeCount:withCompletionHandler:] API (iOS 16+) to fix a chronic main-thread hang in PushNotificationIOS.setApplicationIconBadgeNumber. The deprecated applicationIconBadgeNumber setter performs a synchronous XPC round-trip to usernotificationsd on the calling thread, which triggers 0x8badf00d watchdog kills when the daemon is slow. The async API returns immediately and invokes a completion handler later, keeping the main thread responsive.

Also adds an RNTester example screen with a "Rapid-fire 50x set" stress test to validate the fix.

API Documentation say:

property(nonatomic) NSInteger applicationIconBadgeNumber API_DEPRECATED("Use -[UNUserNotificationCenter setBadgeCount:withCompletionHandler:] instead.", ios(2.0, 17.0)) API_UNAVAILABLE(watchos);

Changelog: [iOS][Fixed] Fix main-thread watchdog hang in PushNotificationIOS.setApplicationIconBadgeNumber

Reviewed By: fkgozali

Differential Revision: D113810036

@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 Jul 27, 2026
@meta-codesync

meta-codesync Bot commented Jul 27, 2026

Copy link
Copy Markdown

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

@meta-codesync meta-codesync Bot changed the title Fix main-thread watchdog hang in PushNotificationIOS.setApplicationIconBadgeNumber Fix main-thread watchdog hang in PushNotificationIOS.setApplicationIconBadgeNumber (#57707) Jul 27, 2026
christophpurrer added a commit to christophpurrer/react-native-macos that referenced this pull request Jul 27, 2026
…onBadgeNumber (react#57707)

Summary:

Adopts the non-blocking `-[UNUserNotificationCenter setBadgeCount:withCompletionHandler:]` API (iOS 16+) to fix a chronic main-thread hang in `PushNotificationIOS.setApplicationIconBadgeNumber`. The deprecated `applicationIconBadgeNumber` setter performs a synchronous XPC round-trip to `usernotificationsd` on the calling thread, which triggers `0x8badf00d` watchdog kills when the daemon is slow. The async API returns immediately and invokes a completion handler later, keeping the main thread responsive.

Also adds an RNTester example screen with a "Rapid-fire 50x set" stress test to validate the fix.

API Documentation say:

```
property(nonatomic) NSInteger applicationIconBadgeNumber API_DEPRECATED("Use -[UNUserNotificationCenter setBadgeCount:withCompletionHandler:] instead.", ios(2.0, 17.0)) API_UNAVAILABLE(watchos);
```

Changelog: [iOS][Fixed] Fix main-thread watchdog hang in PushNotificationIOS.setApplicationIconBadgeNumber

Reviewed By: fkgozali

Differential Revision: D113810036
christophpurrer added a commit to christophpurrer/react-native-macos that referenced this pull request Jul 27, 2026
…onBadgeNumber (react#57707)

Summary:

Adopts the non-blocking `-[UNUserNotificationCenter setBadgeCount:withCompletionHandler:]` API (iOS 16+) to fix a chronic main-thread hang in `PushNotificationIOS.setApplicationIconBadgeNumber`. The deprecated `applicationIconBadgeNumber` setter performs a synchronous XPC round-trip to `usernotificationsd` on the calling thread, which triggers `0x8badf00d` watchdog kills when the daemon is slow. The async API returns immediately and invokes a completion handler later, keeping the main thread responsive.

Also adds an RNTester example screen with a "Rapid-fire 50x set" stress test to validate the fix.

API Documentation say:

```
property(nonatomic) NSInteger applicationIconBadgeNumber API_DEPRECATED("Use -[UNUserNotificationCenter setBadgeCount:withCompletionHandler:] instead.", ios(2.0, 17.0)) API_UNAVAILABLE(watchos);
```

Changelog: [iOS][Fixed] Fix main-thread watchdog hang in PushNotificationIOS.setApplicationIconBadgeNumber

Reviewed By: fkgozali

Differential Revision: D113810036
…onBadgeNumber (react#57707)

Summary:

Adopts the non-blocking `-[UNUserNotificationCenter setBadgeCount:withCompletionHandler:]` API (iOS 16+) to fix a chronic main-thread hang in `PushNotificationIOS.setApplicationIconBadgeNumber`. The deprecated `applicationIconBadgeNumber` setter performs a synchronous XPC round-trip to `usernotificationsd` on the calling thread, which triggers `0x8badf00d` watchdog kills when the daemon is slow. The async API returns immediately and invokes a completion handler later, keeping the main thread responsive.

Also adds an RNTester example screen with a "Rapid-fire 50x set" stress test to validate the fix.

API Documentation say:

```
property(nonatomic) NSInteger applicationIconBadgeNumber API_DEPRECATED("Use -[UNUserNotificationCenter setBadgeCount:withCompletionHandler:] instead.", ios(2.0, 17.0)) API_UNAVAILABLE(watchos);
```

Changelog: [iOS][Fixed] Fix main-thread watchdog hang in PushNotificationIOS.setApplicationIconBadgeNumber

Reviewed By: fkgozali

Differential Revision: D113810036
@meta-codesync

meta-codesync Bot commented Jul 27, 2026

Copy link
Copy Markdown

This pull request has been merged in 6f6efed.

@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Jul 27, 2026
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.

1 participant