[android] java.lang.AssertionError: Pausing an activity that is not the current activity, this is incorrect!
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 25/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Stack de tecnologia
- android, kotlin, react-native
- Domínio
- mobile-dev
Direção de pesquisa
Comece em ReactHostImpl.kt, em onHostPause, e reproduza o crash usando o branch obrigatório rn-tester e o fluxo de tela dividida/compartilhamento descrito na issue. Está concluído quando várias instâncias de ReactActivity em primeiro plano não causarem mais a assertion nem o crash quando uma atividade for pausada; compare o comportamento com o pull request vinculado #54122.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Description
In our app's telemetry tools we are seeing crashes with the following stack:
java.lang.AssertionError: Pausing an activity that is not the current activity, this is incorrect! Current activity: ShareActivity Paused activity: MainActivity
at com.facebook.infer.annotation.Assertions.assertCondition(Assertions.java:88)
at com.facebook.react.runtime.ReactHostImpl.onHostPause(ReactHostImpl.java:347)
... full stack below
There is a bit of history around this issue:
And recently meta added changes to simply turn this assertion off by a feature flag:
For our use case the issue seems to caused by the fact that we have multiple ReactActivity instances.
The code in ReactHostImpl.kt is kind of build on the assumption that there will only ever be one active activity:
- Historically the
ReactInstancewhichReactHostmaintains was on the old arch bound to theReactActivity, so it made sense that it was just caring about one activity - It's very well possible to have multiple activities in the foreground. Examples are share extensions, picture in picture mode, split screen app usage (and probably other stuff i can't think of right now)
I opened a PR which addresses this behaviour:
Steps to reproduce
- Clone this branch: https://github.com/hannojg/react-native/tree/fix/android-onpause-host-properly-reproduction
- It contains a new activity that you can share to: https://github.com/hannojg/react-native/blob/96defe6865a37e47068fdbc0a86df746bb8998aa/packages/rn-tester/android/app/src/main/AndroidManifest.xml#L92-L111
- Follow the reproduction steps from this video:
- Open the rn-tester app
- Move it to a split screen view
- As second view for split screen choose gallery
- Share a picture from gallery to the RNTester app
- Now both the
RNTesterActivityandRNTesterShareActivitywill be in foreground and inresume - In the rn-tester app go to API > Share
- Share text from the first button. Opening a share dialog will
pausetheRNTesterActivity, which will lead to a crash the whole app, as the last active activity tracked wasRNTesterShareActivity
https://github.com/user-attachments/assets/966dd70e-c65f-4460-8749-ce332c1d51c2
React Native Version
0.82.0
Affected Platforms
Runtime - Android
Output of npx @react-native-community/cli info
System:
OS: macOS 15.7
CPU: (14) arm64 Apple M4 Pro
Memory: 640.88 MB / 48.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 22.14.0
path: /nix/store/04fc23dsflkxl4s9p6lkigia1hq3vjp2-nodejs-22.14.0/bin/node
Yarn:
version: 1.22.19
path: ~/.nix-profile/bin/yarn
npm:
version: 10.9.2
path: /nix/store/04fc23dsflkxl4s9p6lkigia1hq3vjp2-nodejs-22.14.0/bin/npm
Watchman:
version: 2024.03.11.00
path: /Users/hannogodecke/Documents/discord-2/.local/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /Users/hannogodecke/.rbenv/shims/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:
- "31"
- "35"
- "36"
Build Tools:
- 34.0.0
- 35.0.0
- 35.0.1
- 36.0.0
System Images:
- android-31 | ARM 64 v8a
- android-31 | Google APIs ARM 64 v8a
- android-31 | Google Play ARM 64 v8a
- android-31 | Google APIs ATD ARM 64 v8a
- android-35 | Google APIs ARM 64 v8a
- android-35 | Google Play ARM 64 v8a
- android-35 | Pre-Release 16 KB Page Size Google Play ARM 64 v8a
- android-35 | Pre-Release 16 KB Page Size Google APIs ARM 64 v8a
- android-35 | Google APIs ATD ARM 64
- android-36 | Google Play ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2025.1 AI-251.26094.121.2512.13930704
Xcode:
version: 16.4/16F6
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.15
path: /usr/bin/javac
Ruby:
version: 3.3.4
path: /Users/hannogodecke/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 19.1.1
wanted: 19.1.1
react-native: Not Found
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
*Building the rn-tester app from main*
Stacktrace or Logs
java.lang.AssertionError: Pausing an activity that is not the current activity, this is incorrect! Current activity: ShareActivity Paused activity: MainActivity
at com.facebook.infer.annotation.Assertions.assertCondition(Assertions.java:88)
at com.facebook.react.runtime.ReactHostImpl.onHostPause(ReactHostImpl.java:347)
at com.facebook.react.ReactDelegate.onHostPause(ReactDelegate.java:139)
at com.facebook.react.ReactActivityDelegate.onPause(ReactActivityDelegate.java:166)
at com.discord.react_activities.ReactActivity$ActivityDelegate.onPause(ReactActivity.kt:133)
at com.facebook.react.ReactActivity.onPause(ReactActivity.java:55)
at com.discord.react_activities.ReactActivity.onPause(ReactActivity.kt:82)
at android.app.Activity.performPause(Activity.java:9587)
MANDATORY Reproducer
https://github.com/hannojg/react-native/tree/fix/android-onpause-host-properly-reproduction
Screenshots and Videos
No response
- Linguagem predominante
- C++
- Estrelas
- 127k
- Forks
- 25.3k
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de react/react-native
-
Needs: Attention Needs: Repro
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
react/react-native#58904 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Needs: Author Feedback Needs: Repro
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
react/react-native#58659 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Needs: Author Feedback Needs: Repro
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 92/100
react/react-native#58621 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Add TypeScript declaration for the performance globalTalvez já em andamento @Cedric921 assumiu há 3 dias. AbertaNeeds: Attention Needs: Repro
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
react/react-native#58610 · 4 comentários ·
Mantenedores costumam responder em até 1 dia
-
Needs: Triage :mag:
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
react/react-native#58565 · 2 comentários · 2 reações ·
Mantenedores costumam responder em até 1 dia
Todas as issues de react/react-native
Issues semelhantes
-
Round video messages start gray and blocky with libx264: encoder is configured for 1,000,000 fpsAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
telegramdesktop/tdesktop#31422 ·
Mantenedores costumam responder em até 9 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
Mantenedores costumam responder em até 5 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
zen-browser/desktop#15809 · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
ggml-org/whisper.cpp#4103 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
bitcoin-core/gui-qml#987 ·
Mantenedores costumam responder em até 3 dias