AppState emits `active` after locking iPhone with "Always On Screen"
まだ誰も着手していません。
- 主要言語
- C++
- スター
- 127k
- フォーク
- 25.3k
- 平均マージ
- 1日 23時間
- マージ済み PR(30日)
- 4
説明
Description
On iPhones that support "Always On Display" (see supported models) and have this setting on (it is on by default!), locking your phone whilst a React Native application is open causes AppState.addEventListener to emit the event: active.
This has several unwanted consequences: for popular applications who rely on the active event to fetch new data, this bug causes 1000s of unwanted API calls that automatically fail, as the runtime is immediately paused after the app is paused (which as a result causes HTTP calls to be dropped).
Steps to reproduce
- Ensure you're running this on an iPhone (or Simulator) that support the "Always On Display" feature.
- In a blank react native application, add the following code to a screen:
useEffect(() => {
const eventListener = AppState.addEventListener('change', (state) => {
console.log('🚨 AppState changed to: ', state)
})
return () => {
eventListener.remove()
}
}, [])
- Lock the phone.
- You should see a
inactiveevent, immediately followed by anactiveevent.
React Native Version
0.81.4
Affected Platforms
Runtime - iOS
Output of npx @react-native-community/cli info
System:
OS: macOS 26.1
CPU: (14) arm64 Apple M4 Pro
Memory: 1.92 GB / 48.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 22.16.0
path: ~/.nvm/versions/node/v22.16.0/bin/node
Yarn:
version: 1.22.22
path: ~/Documents/amber/amber-mobile/node_modules/.bin/yarn
npm:
version: 10.9.2
path: ~/.nvm/versions/node/v22.16.0/bin/npm
Watchman:
version: 2025.03.03.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /Users/rudy/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 25.1
- iOS 26.1
- macOS 26.1
- tvOS 26.1
- visionOS 26.1
- watchOS 26.1
Android SDK: Not Found
IDEs:
Android Studio: 2025.2 AI-252.25557.131.2521.14432022
Xcode:
version: 26.1.1/17B100
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.10
path: /usr/bin/javac
Ruby:
version: 3.1.2
path: /Users/rudy/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli":
installed: 20.0.0
wanted: ^20.0.0
react:
installed: 19.1.0
wanted: 19.1.0
react-native:
installed: 0.81.4
wanted: 0.81.4
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
Stacktrace or Logs
Not relevant.
MANDATORY Reproducer
https://snack.expo.dev/@amber-pli/fascinated-violet-popcorn
Screenshots and Videos
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Always On Display を搭載した iPhone または Simulator を使用し、必須の Snack リプロデューサーにおける AppState.addEventListener('change') の動作から始めます。デバイスをロックしたときに iOS のライフサイクルで発生するイベントを追跡し、active が inactive に続く理由を特定します。デバイスをロックしても余分な active イベントが発生せず、通常のアプリ状態の遷移が引き続き機能すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- ios, react-native
- 領域
- mobile
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100