Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production only crash in expo-constants on samsung devices #25760

Closed
jbaxleyiii opened this issue Dec 5, 2023 · 22 comments
Closed

Production only crash in expo-constants on samsung devices #25760

jbaxleyiii opened this issue Dec 5, 2023 · 22 comments
Assignees
Labels
needs review Issue is ready to be reviewed by a maintainer

Comments

@jbaxleyiii
Copy link

jbaxleyiii commented Dec 5, 2023

Summary

Hey Expo team, I'm experiencing a hard-to-debug crash and was hoping you had some pointers or an idea of what to do next. Over the last 3 months, our Android app has been crashing at a rate of around 20% per user but primarily on Samsung devices. I haven't been able to reproduce it outside of a production build and it is quite rare to be able to make it happen on production as well.

The behavior is that of a delayed then sudden crash that doesn't seem to be tied to any user behavior. The only insight that we have is from the Google play crash logs (sentry isn't picking this up). The stack is below but the top line is:

Expo native runtime is not available: something went wrong and we aren't sure what it was. Please post more information and get support at https://forums.expo.dev.

From what I can tell this only happens in expo-constants (#11814 (comment)).

I don't have a reproducible example app since this only happens in production builds but I've included a link to a recent EAS build that did have the crash at least once.

Sorry for the cryptic error but at this point I'm pretty lost on what to do next!

Exception com.facebook.react.common.JavascriptException: Error: Expo native runtime is not available: something went wrong and we aren't sure what it was. Please post more information and get support at https://forums.expo.dev., js engine: hermes, stack:
anonymous@1:703526
loadModuleImplementation@1:94248
guardedLoadModule@1:93803
metroRequire@1:93431
anonymous@1:702325
loadModuleImplementation@1:94248
guardedLoadModule@1:93803
metroRequire@1:93431
anonymous@1:701478
loadModuleImplementation@1:94248
guardedLoadModule@1:93803
metroRequire@1:93431
anonymous@1:700816
loadModuleImplementation@1:94248
guardedLoadModule@1:93803
metroRequire@1:93431
anonymous@1:100685
loadModuleImplementation@1:94248
guardedLoadModule@1:93760
metroRequire@1:93431
global@1:92987
  at com.facebook.react.modules.core.ExceptionsManagerModule.reportException (ExceptionsManagerModule.java:65)
  at java.lang.reflect.Method.invoke
  at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:372)
  at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:188)
  at com.facebook.jni.NativeRunnable.run
  at android.os.Handler.handleCallback (Handler.java:942)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:27)
  at android.os.Looper.loopOnce (Looper.java:201)
  at android.os.Looper.loop (Looper.java:288)
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:228)
  at java.lang.Thread.run (Thread.java:1012)

Environment

  expo-env-info 1.0.5 environment info:
    System:
      OS: macOS 14.1
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
      Yarn: 3.6.0 - ~/.nvm/versions/node/v18.16.0/bin/yarn
      npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
    Managers:
      CocoaPods: 1.13.0 - /usr/local/homebrew/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 23.0, iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0
      Android SDK:
        API Levels: 33, 34
        Build Tools: 30.0.3, 33.0.0, 34.0.0
        System Images: android-33 | Google APIs ARM 64 v8a, android-34 | Google APIs ARM 64 v8a, android-34 | Google Play ARM 64 v8a
    IDEs:
      Android Studio: 2022.2 AI-222.4459.24.2221.10121639
      Xcode: 15.0.1/15A507 - /usr/bin/xcodebuild
    npmPackages:
      expo: ^49.0.16 => 49.0.16
      react: 18.2.0 => 18.2.0
      react-dom: 18.2.0 => 18.2.0
      react-native: 0.72.6 => 0.72.6
      react-native-web: ~0.19.9 => 0.19.9
    npmGlobalPackages:
      eas-cli: 5.9.0
    Expo Workflow: bare
@jbaxleyiii jbaxleyiii added the needs validation Issue needs to be validated label Dec 5, 2023
@expo-bot expo-bot added needs review Issue is ready to be reviewed by a maintainer and removed needs validation Issue needs to be validated labels Dec 5, 2023
@nbonatsakis
Copy link

We are also seeing this, also only on Samsung devices.

@anandvc
Copy link

anandvc commented Dec 10, 2023

We have this issue as well, so far it seems specific to Samsung Android.

@wodin
Copy link
Contributor

wodin commented Dec 10, 2023

Are you all using EAS Update? Is the app trying to fetch and apply an update on start (i.e. the way Expo's updates work by default)?

This might have something to do with network connectivity or a race condition. Here's where the wording in this error message was introduced: #10239

Also, I see the check that throws this error seems to have been removed recently by @tsapeta: #23732

Maybe you can use patch-package to apply this diff:

diff --git packages/expo/build/Expo.fx.js packages/expo/build/Expo.fx.js
index 604e0be6f0..1eb0308c1a 100644
--- packages/expo/build/Expo.fx.js
+++ packages/expo/build/Expo.fx.js
@@ -1,4 +1,3 @@
-import './environment/validate.fx';
 // load expo-asset immediately to set a custom `source` transformer in React Native
 import 'expo-asset';
 import Constants, { ExecutionEnvironment } from 'expo-constants';

I have no idea if the above patch will solve the problem. It might just cause it to crash somewhere else instead. It's just a guess based on seeing that this validation was removed recently.

@brentvatne
Copy link
Member

brentvatne commented Dec 10, 2023

is anyone able to provide a full stacktrace with what is reported through sentry? there isn't much to go off of here - this error message could have a multitude of causes. for example - in one case it was reported, the developer who reported it found that their babel config was making changes that broke internals in unexpected ways: #20249 (comment)

@brentvatne
Copy link
Member

@jbaxleyiii - I looked at your project dependencies and found "@babel/plugin-transform-modules-commonjs" - so this seems potentially related to the comment I mentioned above - #20249 (comment)

@brentvatne
Copy link
Member

@jbaxleyiii - are you able to tell me which version of the expo package you started to see this in? (perhaps by tracing crash reports back to app versions, and app versions to git commits). also, would you be able to look at a compare view between the commit prior to starting to see this issue, and the release where the issue started, and see if there is anything that jumps out to you?

@nbonatsakis
Copy link

@brentvatne I did stumble upon that other issue where the resolution was related to changing babel config, but I suspect it is a different issue, as in that case it seems like the issue was happening in development and was happening 100% of the3 time.

To answer your other question, we are in fact using Expo Updates and checking for updates on startup. Maybe related, but we have seen the update check failing with a strange error related to updates being disabled, even though the app is running in production mode. This failure is intermittent as well, however not limited to Samsung devices.

Sentry is not catching this error, and the places where I can see it (Google Play and Crashlytics) only show the raw native error which I can get if you think that would help.

If that validation logic has since been removed, we can try the patch, but it would be great to know why it was removed.

@brentvatne
Copy link
Member

@nbonatsakis - are you able to tell me which version of the expo package you started to see this in? (perhaps by tracing crash reports back to app versions, and app versions to git commits). also, would you be able to look at a compare view between the commit prior to starting to see this issue, and the release where the issue started, and see if there is anything that jumps out to you?

@nbonatsakis
Copy link

@brentvatne Unfortunately we've only released the Android version of our app this past August and I believe we've been experiencing this crash since the beginning, however we've just started really trying to address crashes. It's hard to tell however, because it shows up in Play Console as a common JS error with no detail. Firebase has the detail I've posted here, but that's only been in the app for a few weeks.

@brentvatne
Copy link
Member

@nbonatsakis - one way you could improve reporting with sentry is by enabling auto init on the native side in your AndroidManifest - https://docs.sentry.io/platforms/react-native/manual-setup/native-init/

@jbaxleyiii
Copy link
Author

jbaxleyiii commented Dec 19, 2023

@brentvatne it has been happening since 48 but that is also when the project was started! I'm not manually using @babel/plugin-transform-modules-commonjs but I'll trace down my deps to see what is!

This is my current babel setup:

 {
    presets: ["babel-preset-expo"],
    plugins: [
      "react-native-reanimated/plugin",
      "expo-router/babel",
      "nativewind/babel",
      "@fullstory/react-native",
    ],
  }

Also, I just wanted to say thank you so much for taking a look @brentvatne!

@nbonatsakis
Copy link

Any update on this one? We tried deploying an update with the patch suggested earlier in this issue, but the issue persists.

@RenanGarcia
Copy link

@nbonatsakis - are you able to tell me which version of the expo package you started to see this in? (perhaps by tracing crash reports back to app versions, and app versions to git commits). also, would you be able to look at a compare view between the commit prior to starting to see this issue, and the release where the issue started, and see if there is anything that jumps out to you?

In our case, the error started to occur when we migrated to expo version 48

@RenanGarcia
Copy link

We have this issue as well, so far it seems specific to Samsung Android.

In our project it also occurs on other devices... Motorola, Redmi and others

@jbaxleyiii
Copy link
Author

Any update on this one? We tried deploying an update with the patch suggested earlier in this issue, but the issue persists.

I did the same and it still occurred

@brentvatne
Copy link
Member

we have been out of office since dec 22, but it looks like there still isn't much to go on here. anything folks can share that can help us to understand when/how this happens and especially how we can reproduce it would be much appreciated. a full sentry stack trace would also be great

@stevekuznetsov
Copy link
Contributor

@brentvatne could you please point me to some documentation on how to get better information to you? We're seeing errors like this and all we have to go off of are issues in the Google Play console, for whatever reason Sentry has not caught any of these. An example:

Exception com.facebook.react.common.JavascriptException: Error: Expo native runtime is not available: something went wrong and we aren't sure what it was. Please post more information and get support at https://forums.expo.dev., js engine: hermes, stack:
anonymous@1:120095
loadModuleImplementation@1:111567
guardedLoadModule@1:111121
metroRequire@1:110749
anonymous@1:118891
loadModuleImplementation@1:111567
guardedLoadModule@1:111121
metroRequire@1:110749
anonymous@1:118142
loadModuleImplementation@1:111567
guardedLoadModule@1:111121
metroRequire@1:110749
anonymous@1:117944
loadModuleImplementation@1:111567
guardedLoadModule@1:111078
metroRequire@1:110749
global@1:110305
  at com.facebook.react.modules.core.ExceptionsManagerModule.reportException (ExceptionsManagerModule.java:65)
  at java.lang.reflect.Method.invoke
  at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:372)
  at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:188)
  at com.facebook.jni.NativeRunnable.run
  at android.os.Handler.handleCallback (Handler.java:958)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:27)
  at android.os.Looper.loopOnce (Looper.java:230)
  at android.os.Looper.loop (Looper.java:319)
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:228)
  at java.lang.Thread.run (Thread.java:1012)

Copy link
Contributor

github-actions bot commented May 1, 2024

This issue is stale because it has been open for 90 days with no activity. If there is no activity in the next 7 days, the issue will be closed.

@github-actions github-actions bot added the stale label May 1, 2024
@wodin
Copy link
Contributor

wodin commented May 2, 2024

@stevekuznetsov maybe see if you can enable Native Initialization:
https://docs.sentry.io/platforms/react-native/manual-setup/native-init/

@github-actions github-actions bot removed the stale label May 2, 2024
@stevekuznetsov
Copy link
Contributor

@wodin since we're on Expo, I don't think we have the ability to mess with the native layer for initialization, is that right?

@wodin
Copy link
Contributor

wodin commented May 4, 2024

@stevekuznetsov you can with a config plugin, although I haven't looked into what exactly is required for native init

@lukmccall
Copy link
Contributor

I believe this issue is outdated. We no longer need to check if Expo native runtime is available in the same way. If I remember correctly, we rewrote this part in SDK 50. The setup is much simpler now and doesn't involve as many moving parts as it used to. Since we can't reproduce this behavior and we've made a lot of changes in the code related to that crash, I will close this issue for now. However, feel free to open a new one if you encounter similar problems on SDK 50 or 51.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Issue is ready to be reviewed by a maintainer
Projects
None yet
Development

No branches or pull requests

9 participants