fix: skip ShortcutBadger on API 26+ to prevent SIGSEGV on Xiaomi devices#2570
fix: skip ShortcutBadger on API 26+ to prevent SIGSEGV on Xiaomi devices#2570fadi-george wants to merge 1 commit into5.7-mainfrom
Conversation
26c7e3a to
905aefb
Compare
📊 Diff Coverage ReportDiff Coverage Report (Changed Lines Only)Threshold: 80% Changed Files Coverage
Overall Coverage (Changed Lines Only)270/1208 changed lines covered (22.4%) ❌ Coverage Check FailedFiles below 80% threshold:
|
On Android 8+ (API 26), notification channels handle app icon badges natively, making ShortcutBadger unnecessary. ShortcutBadger's DefaultBadger fallback causes native SIGSEGV crashes on certain Xiaomi devices (Redmi 10C, Redmi 9A) where MIUI's broadcast receiver has buggy native code that cannot be caught at the Java level. Fixes OneSignal/react-native-onesignal#1766 Made-with: Cursor
905aefb to
5139ef3
Compare
Description
One Line Summary
Skip ShortcutBadger badge updates on Android 8+ (API 26) to prevent native SIGSEGV crashes on Xiaomi devices.
Details
Motivation
ShortcutBadger causes a native SIGSEGV (segmentation fault) on certain Xiaomi devices (Redmi 10C, Redmi 9A) running Android 11-13. The crash occurs in
ShortcutBadger.applyCountOrThrowwhenDefaultBadger.executeBadgesends a broadcast that MIUI's framework handles with buggy native code. Since SIGSEGV is a native crash, Java try-catch cannot intercept it, so the only safe fix is to avoid calling ShortcutBadger on affected API levels.Reported in OneSignal/react-native-onesignal#1766 and #2222.
Scope
On API 26+ (Android 8+),
NotificationChannelhandles app icon badges natively, making ShortcutBadger redundant. This change skips ShortcutBadger on those versions. Pre-API 26 devices still use ShortcutBadger as before.Testing
Unit testing
No existing tests for
BadgeCountUpdater. The change is a straightforward API level guard.Manual testing
The crash was reported on Xiaomi Redmi 10C (Android 13) and Redmi 9A (Android 11). The fix prevents the code path from being reached on those devices.
Affected code checklist
Checklist
Overview
Testing
Final pass
Made with Cursor