expo: Adding expo-localization as dependency causes some Play Store / Robo tests to fail with native crash

Summary

Having expo-localization as dependency causes some Play Store pre-launch tests and manually run Robo tests to fail. The crash doesn’t even require importing expo-localization in code. Crash occurs on app startup before the splash screen gets hidden and the device locale seems to be a deciding factor in the crash. For example, English (United States), Dutch (Belgium),English (United Kingdom) and English (Guam) are fine. On the other hand, Finnish, Swedish, Norwegian Bokmål, English and Afrikaans seem to trigger the crash.

       *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'Sony/H8296/H8296:9/52.0.A.8.25/2936766125:user/release-keys'
Revision: '0'
ABI: 'arm64'
pid: 27505, tid: 27622, name: mqt_js  >>> com.jouhou.loc_crash_test <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
    x0  0000000000000000  x1  0000000000006be6  x2  0000000000000006  x3  0000000000000008
    x4  fefeff00ad349b0a  x5  fefeff00ad349b0a  x6  fefeff00ad349b0a  x7  7f7f7f7fff7fff7f
    x8  0000000000000083  x9  8002ff6da7d9ecb9  x10 0000000000000000  x11 fffffffc7ffffbdf
    x12 0000000000000001  x13 000000000000000f  x14 0000000000000780  x15 00000074fb2b70f0
    x16 00000075991322b8  x17 0000007599053be8  x18 00000000ebad6082  x19 0000000000006b71
    x20 0000000000006be6  x21 434c4e47432b2b00  x22 0000000000000000  x23 00000074fb2ba588
    x24 0000000000000000  x25 00000074fb7bd060  x26 00000074fb2ba588  x27 00000074fb2b8338
    x28 0000007515dde9c0  x29 00000074fb2b70f0
    sp  00000074fb2b70b0  lr  0000007599045314  pc  000000759904533c

Here is a tombstone file of the crash: web-build_2022-01-15T20 18 50.txt

I haven’t been able to reproduce this on real devices or on emulators, but for obvious reasons, I have refrained from publishing the recent builds to production.

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

Android, with both hermes and jsc

SDK Version (managed workflow only)

44

Environment

Expo CLI 5.0.3 environment info: System: OS: Linux 5.15 Fedora Linux 35 (Workstation Edition) Shell: 5.1.8 - /bin/bash Binaries: Node: 14.18.2 - /var/lib/snapd/snap/bin/node Yarn: 1.22.15 - /var/lib/snapd/snap/bin/yarn npm: 6.14.15 - /var/lib/snapd/snap/bin/npm npmPackages: expo: ~44.0.4 => 44.0.4 react: 17.0.1 => 17.0.1 react-dom: 17.0.1 => 17.0.1 react-native: 0.64.3 => 0.64.3 react-native-web: 0.17.1 => 0.17.1 npmGlobalPackages: eas-cli: 0.38.3 expo-cli: 5.0.1 Expo Workflow: managed

Reproducible demo

This is basically unaltered code right after expo init, apart from running expo install expo-localization.

App.js:

import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';

export default function App() {
  return (
    <View style={styles.container}>
      <Text>Open up App.js to start working on your app!</Text>
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

Package.json:

{
  "name": "loc_crash_test",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "expo": "~44.0.0",
    "expo-localization": "~12.0.0",
    "expo-status-bar": "~1.2.0",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-native": "0.64.3",
    "react-native-web": "0.17.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9"
  },
  "private": true
}

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (3 by maintainers)

Most upvoted comments

Okay, seems that I found the problem.

In LocalizationModule.kt there is:

  • a function getConstants() which is returning Map<String, Any>.
  • in that function there is a HashMap: val constants = HashMap<String, Any>()
  • and assignment to that map: constants[key] = bundle[key] as Any

If I have understood Kotlin correctly by my Googlings today, Any cannot be assigned a null value, but region is in this locale (ie. Finnish) null.

By changing this…

override fun getConstants(): Map<String, **Any**> {
  val constants = HashMap<String, **Any**>()
  val bundle = bundledConstants
  for (key in bundle.keySet()) {
    constants[key] = bundle[key] as **Any**
  }
  return constants
}

to this…

override fun getConstants(): Map<String, **Any?**> {
  val constants = HashMap<String, **Any?**>()
  val bundle = bundledConstants
  for (key in bundle.keySet()) {
    constants[key] = bundle[key] as **Any?**
  }
  return constants
}

…the app launches without a problem. Now I have no Kotlin experience (besides today’s experiments), so someone else more experienced than me can say if those changes could have any side effects.

This issue was resolved for us with SDK 47.

The app crashes when added 13.1.0 as a dependency for SDK 46, but works fine when added 13.0.0

Not sure what those workflows are and we do not use eas, so those steps don’t apply to our project. But for patch-package you normally edit the files, create the patch file and then in package.json add postinstall to run patch package, so it is already patched when the node_modules are installed.

  "scripts": {
    "postinstall": "patch-package",
  },

Btw thanks for finding the issue 😉

Crash occurs on app startup before the splash screen gets hidden and the device locale seems to be a deciding factor in the crash. For example, English (United States), Dutch (Belgium), English (United Kingdom) and English (Guam) are fine. On the other hand, Finnish, Swedish, Norwegian Bokmål, English and Afrikaans seem to trigger the crash.

Just realized that all of those locales that cause the crash do not have the latter (region?) part in them, so maybe expo-localization expects that part always to exist?

Edit: I just confirmed this, a test with Finnish locale fails, but Finnish (Finland) succeeds.