Expo bug - After a crash, the Android Back Button causes standalone app to be put into the background


#1

@ide @adamjnav
We’re running into an issue where after the app “crashes” and reloads (user gets kicked back to the first screen), whenever the user presses the Android Back Button, the app gets put into the background. I was able to reproduce this with the default “Tabs” project that’s provided by CRNA on Expo 31 SDK (link: https://exp-shell-app-assets.s3.us-west-1.amazonaws.com/android/%40allen.lin/split-screen-poc-c25e728a483c4c71ba9109ac70a93ef1-signed.apk) with no additional code added. The current work around is to have the user open up the app switcher and kill and re-open the app.

Here are some steps to consistently reproduce it on a Google Pixel 2 Phone (or any other phone with the split-screen feature), which will cause the app the reload:

  1. Open the app. Tap on any of the tabs to switch to different screens (i.e. “Links”). Pressing the Android Back Button should put the user back to the “Home” tab.
  2. From here, activate the split-screen feature by long-pressing the Square icon located at the bottom of the device (where the Back and Home buttons are). This will cause the app to crash and reload.
  3. Get out of the split screen view by dragging the black horizontal bar at the center of the screen to the bottom of the screen so that the app is focused again. This will again cause the app to crash and reload.
  4. Tap on the “Link” tab again. Now press the Android Back Button. The app should be minimized.

I tried looking at ADB Logcat but there was too much noise in the logs. One line did stick out when I grep’d the logs for ‘exception’ though:

12-05 16:03:07.137 23448 23448 E j : Runtime exception in RNObject when calling method getCurrentReactContext: java.lang.NullPointerException: null receiver

I also saw some calls to moveTaskToBack() being made when the back button is pressed.

Just to be clear, this is not linked to the Split-Screen feature on Android devices. One of my colleagues was able to reproduce this on his XiaoMi A1M1 device (running Vanilla Android 8.1.0 – he’s on the Android One program) in our main Expo app (SDK 30). His device does not have the split-screen feature and he still saw this problem. I think our actual app might’ve crashed on his device due to some code problem.

Is this a known issue in Expo? Is there a workaround to avoid this Android Back Button problem?


#2

bump.