bug: back handler stops working after re-foregrounding the app
还没有人认领这个 Issue。
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 4
描述
Description
back handlers seem to stop working after sending the app to the background - all back gestures (except in Modals) just close the app instead. see the video below for a clearer demonstration.
I'm using the Android 16 QPR2 beta (BP41.250916.015.A1) on a Pixel 8.
I can reproduce this using either the @react-native-community/hooks hook or the usage example in the BackHandler docs. the hook works fine in React Native v0.80 (I assume because the target SDK was still 35?).
Steps to reproduce
- Start the app
- Press the button at the top
- Do a back gesture and observe that it respects the back handler
- Do another one to go home
- Re-open the app
- Press the button at the top again
- Do another back gesture and observe that it exits out of the app instead of respecting the back handler
React Native Version
0.83.0
Affected Platforms
Runtime - Android, Build - Linux
Output of npx @react-native-community/cli info
System:
OS: Linux 6.17 Ubuntu 25.10 25.10 (Questing Quokka)
CPU: (8) x64 Intel(R) Core(TM) Ultra 7 256V
Memory: 4.46 GB / 14.72 GB
Shell:
version: 5.2.37
path: /bin/bash
Binaries:
Node:
version: 24.5.0
path: /home/rexo/.nvm/versions/node/v24.5.0/bin/node
Yarn:
version: 4.12.0
path: /home/rexo/.nvm/versions/node/v24.5.0/bin/yarn
npm:
version: 11.5.1
path: /home/rexo/.nvm/versions/node/v24.5.0/bin/npm
Watchman: Not Found
SDKs:
Android SDK:
API Levels:
- "31"
- "35"
- "36"
Build Tools:
- 34.0.0
- 35.0.0
- 35.0.1
- 36.0.0
System Images:
- android-35 | Google APIs Intel x86_64 Atom
- android-35 | Google Play Intel x86_64 Atom
- android-36 | Google Play Intel x86_64 Atom
Android NDK: Not Found
IDEs:
Android Studio: Not Found
Languages:
Java:
version: 17.0.17
path: /usr/bin/javac
Ruby: Not Found
npmPackages:
"@react-native-community/cli":
installed: 20.0.0
wanted: 20.0.0
react:
installed: 19.2.0
wanted: 19.2.0
react-native:
installed: 0.83.0
wanted: 0.83.0
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: false
Stacktrace or Logs
N/A
MANDATORY Reproducer
https://github.com/Rexogamer/backhandler-test
Screenshots and Videos
https://github.com/user-attachments/assets/a48256a0-d956-446d-b5da-1ceccc824d91
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 issue 中链接的必需 reproducer 和 BackHandler 使用示例开始,在 Android 16 QPR2 上使用 React Native 0.83 运行它。比较应用进入后台前和重新打开应用后的 back-handler 行为。完成标准是:应用回到前台后,已注册的 handler 仍会继续运行,而不是由返回手势退出应用。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- react-native
- 领域
- mobile
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100