Debugger: DevTools/Metro is disconnecting from the websocket if the app is backgrounded - was: `AppState.addEventListener('change')` on Android seems to suddenly stop working
还没有人认领这个 Issue。
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 4
描述
Description
AppState.addEventListener('change' on Android seems to suddenly stop working.
Steps to reproduce
https://github.com/NorseGaud/expo-testing
npx expo run:android
Once up and running, background the app by switching to something like the Contacts app. Then, open a contact, create a contact, etc, and then come back. You won't see the active log. However, if you just background the app and don't do anything significant it will show active logs switching back.
React Native Version
0.79.3
Affected Platforms
Runtime - Android
Output of npx @react-native-community/cli info
❯ npx @react-native-community/cli info
info Fetching system and libraries information...
System:
OS: macOS 15.5
CPU: (8) arm64 Apple M2
Memory: 121.03 MB / 24.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 21.7.3
path: ~/.nvm/versions/node/v21.7.3/bin/node
Yarn:
version: 1.22.21
path: /opt/homebrew/bin/yarn
npm:
version: 10.8.3
path: ~/.nvm/versions/node/v21.7.3/bin/npm
Watchman:
version: 2025.04.14.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /opt/homebrew/opt/ruby/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.5
- iOS 18.5
- macOS 15.5
- tvOS 18.5
- visionOS 2.5
- watchOS 11.5
Android SDK:
API Levels:
- "26"
- "27"
- "28"
- "29"
- "30"
- "31"
- "32"
- "33"
- "34"
- "35"
- "36"
Build Tools:
- 26.0.3
- 30.0.3
- 33.0.1
- 34.0.0
- 35.0.0
- 36.0.0
System Images:
- android-26 | Google APIs Intel x86_64 Atom
- android-28 | Google ARM64-V8a Play ARM 64 v8a
- android-29 | Google Play ARM 64 v8a
- android-30 | Google Play ARM 64 v8a
- android-34 | Google APIs ARM 64 v8a
- android-34 | Google Play ARM 64 v8a
- android-35 | Google Play ARM 64 v8a
- android-36 | Google Play ARM 64 v8a
- android-UpsideDownCakePrivacySandbox | Google Play ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2025.1 AI-251.25410.109.2511.13665796
Xcode:
version: 16.4/16F6
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.13
path: /usr/bin/javac
Ruby:
version: 3.3.6
path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 18.0.0
wanted: ^18.0.0
react:
installed: 19.0.0
wanted: 19.0.0
react-native:
installed: 0.79.3
wanted: 0.79.3
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
info React Native v0.80.1 is now available (your project is running on v0.79.3).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.80.1
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.79.3&to=0.80.1
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".
Stacktrace or Logs
LOG AppState has come to the background! 0.6961324593405451
LOG AppState has come to the active! 0.6961324593405451
MANDATORY Reproducer
https://github.com/NorseGaud/expo-testing
Screenshots and Videos
https://github.com/user-attachments/assets/f9f564b7-3495-4054-953f-e843a5ae2312
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 github.com/NorseGaud/expo-testing 中的必需复现器开始,并运行 npx expo run:android。将应用置于后台,使用另一个应用,返回,然后将 AppState 日志与 DevTools/Metro websocket 连接进行比较;当置于后台不再阻止预期的 active 日志或断开调试连接时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- android, react-native
- 领域
- developer-experience, mobile
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100