expo icon indicating copy to clipboard operation
expo copied to clipboard

[android] Rare crash with "Exception java.lang.IllegalStateException: Already resumed"

Open mozzius opened this issue 1 month ago • 1 comments

Minimal reproducible example

n/a

Steps to reproduce

Hello. First off, I'm very sorry, I don't have a minimal reproduction, as I am only seeing this through the Play Console. Feel free to close, but I wanted to open this in the hope anyone else was seeing this too. This makes up 4.3% of our crash rate, and was introduced in the app version that updated to SDK 54. I am guessing it's an edge case with the activity lifecycle, but beyond that I cannot narrow it down further :(

It seems similar but not the same as #34347

Exception java.lang.IllegalStateException: Already resumed
  at kotlin.coroutines.SafeContinuation.resumeWith (SafeContinuationJvm.kt:44)
  at expo.modules.kotlin.activityresult.AppContextActivityResultLauncher$launch$2$1.onActivityResult (AppContextActivityResultLauncher.kt:26)
  at expo.modules.kotlin.activityresult.AppContextActivityResultRegistry.doDispatch (AppContextActivityResultRegistry.kt:325)
  at expo.modules.kotlin.activityresult.AppContextActivityResultRegistry.dispatchResult (AppContextActivityResultRegistry.kt:303)
  at expo.modules.kotlin.activityresult.ActivityResultsManager.onActivityResult (ActivityResultsManager.kt:52)
  at expo.modules.kotlin.AppContext.onActivityResult$expo_modules_core_release (AppContext.kt:313)
  at expo.modules.kotlin.ReactLifecycleDelegate.onActivityResult (ReactLifecycleDelegate.kt:37)
  at com.facebook.react.bridge.ReactContext.onActivityResult (ReactContext.java:348)
  at com.facebook.react.ReactInstanceManager.onActivityResult (ReactInstanceManager.java:907)
  at com.facebook.react.ReactDelegate.onActivityResult (ReactDelegate.kt:209)
  at com.facebook.react.ReactActivityDelegate.onActivityResult (ReactActivityDelegate.java:211)
  at expo.modules.ReactActivityDelegateWrapper$onActivityResult$1.invokeSuspend (ReactActivityDelegateWrapper.kt:297)
  at expo.modules.ReactActivityDelegateWrapper$onActivityResult$1.invoke (Unknown Source:8)
  at expo.modules.ReactActivityDelegateWrapper$onActivityResult$1.invoke (Unknown Source:4)
  at expo.modules.ReactActivityDelegateWrapper$launchLifecycleScopeWithLock$1.invokeSuspend (ReactActivityDelegateWrapper.kt:510)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
  at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith (DispatchedContinuation.kt:359)
  at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable (Cancellable.kt:26)
  at kotlinx.coroutines.CoroutineStart.invoke (CoroutineStart.kt:358)
  at kotlinx.coroutines.AbstractCoroutine.start (AbstractCoroutine.kt:124)
  at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch (Builders.common.kt:52)
  at kotlinx.coroutines.BuildersKt.launch (Unknown Source:1)
  at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default (Builders.common.kt:43)
  at kotlinx.coroutines.BuildersKt.launch$default (Unknown Source:1)
  at expo.modules.ReactActivityDelegateWrapper.launchLifecycleScopeWithLock (ReactActivityDelegateWrapper.kt:508)
  at expo.modules.ReactActivityDelegateWrapper.launchLifecycleScopeWithLock$default (ReactActivityDelegateWrapper.kt:504)
  at expo.modules.ReactActivityDelegateWrapper.onActivityResult (ReactActivityDelegateWrapper.kt:283)
  at com.facebook.react.ReactActivity.onActivityResult (ReactActivity.java:96)
  at android.app.Activity.dispatchActivityResult (Activity.java:8761)
  at android.app.ActivityThread.deliverResults (ActivityThread.java:5664)
  at android.app.ActivityThread.handleSendResult (ActivityThread.java:5710)
  at android.app.servertransaction.ActivityResultItem.execute (ActivityResultItem.java:67)
  at android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:45)
  at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2474)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loopOnce (Looper.java:240)
  at android.os.Looper.loop (Looper.java:351)
  at android.app.ActivityThread.main (ActivityThread.java:8411)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:568)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1013)

Environment

expo-env-info 2.0.7 environment info:
    System:
      OS: macOS 15.7
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 20.19.4 - ~/.nvm/versions/node/v20.19.4/bin/node
      Yarn: 1.22.22 - ~/.nvm/versions/node/v20.19.4/bin/yarn
      npm: 10.8.2 - ~/.nvm/versions/node/v20.19.4/bin/npm
      Watchman: 2025.11.10.00 - /opt/homebrew/bin/watchman
    Managers:
      CocoaPods: 1.16.2 - /opt/homebrew/bin/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:
        API Levels: 29, 33, 34, 35, 36
        Build Tools: 30.0.3, 34.0.0, 35.0.0, 35.0.1, 36.0.0
        System Images: android-29 | Google Play ARM 64 v8a, android-30 | Google APIs ARM 64 v8a, android-35 | Google Play ARM 64 v8a, android-36 | Google Play ARM 64 v8a
    IDEs:
      Android Studio: 2025.1 AI-251.27812.49.2514.14217341
      Xcode: 26.1.1/17B100 - /usr/bin/xcodebuild
    npmPackages:
      @expo/webpack-config: ^19.0.1 => 19.0.1
      babel-preset-expo: ~54.0.0 => 54.0.2
      expo: ^54.0.22 => 54.0.22
      expo-updates: ~29.0.12 => 29.0.12
      react: 19.1.0 => 19.1.0
      react-dom: 19.1.0 => 19.1.0
      react-native: 0.81.5 => 0.81.5
      react-native-web: ^0.21.0 => 0.21.1
    Expo Workflow: bare

Expo Doctor Diagnostics

env: load .env
env: export EXPO_PUBLIC_LOG_LEVEL EXPO_PUBLIC_BUNDLE_DATE CROWDIN_API_TOKEN
12/17 checks passed. 5 checks failed. Possible issues detected:
Use the --verbose flag to see more details about passed checks.

✖ Check dependencies for packages that should not be installed directly
The package "@expo/config-plugins" should not be installed directly in your project. You should instead use "expo/config-plugins" which is a sub-export of the expo package.
If you installed "@expo/config-plugins" to fulfill a peer dependency for a config plugin, the plugin's maintainer should switch to the "expo/config-plugins" import, and you can ignore this warning.
Advice:
Remove these packages from your package.json.

✖ Check that required peer dependencies are installed
Missing peer dependency: @shopify/flash-list
Required by: @discord/bottom-sheet
Advice:
Install missing required peer dependency with "npx expo install @shopify/flash-list"
Your app may crash outside of Expo Go without this dependency. Native module peer dependencies must be installed directly.

✖ Check that no duplicate dependencies are installed
Your project contains duplicate native module dependencies, which should be de-duplicated.
Native builds may only contain one version of any given native module, and having multiple versions of a single Native module installed may lead to unexpected build errors.
Found duplicates for @react-native-async-storage/async-storage:
  ├─ @react-native-async-storage/[email protected] (at: node_modules/@react-native-async-storage/async-storage)
  └─ @react-native-async-storage/[email protected] (at: node_modules/statsig-react-native-expo/node_modules/@react-native-async-storage/async-storage)
Found duplicates for expo-device:
  ├─ [email protected] (at: node_modules/expo-device)
  └─ [email protected] (at: node_modules/statsig-react-native-expo/node_modules/expo-device)
Found duplicates for react-native-get-random-values:
  ├─ [email protected] (at: node_modules/react-native-get-random-values)
  └─ [email protected] (at: node_modules/statsig-react-native-expo/node_modules/react-native-get-random-values)
Advice:
Resolve your dependency issues and deduplicate your dependencies. Learn more: https://expo.fyi/resolving-dependency-issues

✖ Validate packages against React Native Directory package metadata
The following issues were found when validating your dependencies against React Native Directory:
  Untested on New Architecture: expo-image-crop-tool
  No metadata available: bottom-sheet, expo-background-notification-handler, expo-bluesky-gif-view, expo-bluesky-swiss-army, expo-receive-android-intents, @bitdrift/react-native, @bsky.app/react-native-mmkv, @haileyok/bluesky-video, @mozzius/expo-dynamic-app-icon, expo-scroll-forwarder
Advice:
Use libraries that are actively maintained and support the New Architecture. Find alternative libraries with https://reactnative.directory.
Add packages to expo.doctor.reactNativeDirectoryCheck.exclude in package.json to selectively skip validations, if the warning is not relevant.
Update React Native Directory to include metadata for unknown packages. Alternatively, set expo.doctor.reactNativeDirectoryCheck.listUnknownPackages in package.json to false to skip warnings about packages with no metadata, if the warning is not relevant.

✖ Check that packages match versions required by installed Expo SDK

❗ Major version mismatches
package                  expected  found
@sentry/react-native     ~7.2.0    6.20.0
react-native-reanimated  ~4.1.1    3.19.1

⚠️ Minor version mismatches
package                  expected  found
react-native-pager-view  6.9.1     6.8.0

🔧 Patch version mismatches
package                  expected  found
expo                     ~54.0.25  54.0.22
expo-dev-client          ~6.0.18   6.0.16
expo-file-system         ~19.0.19  19.0.17
expo-linking             ~8.0.9    8.0.8
expo-notifications       ~0.32.13  0.32.12
expo-splash-screen       ~31.0.11  31.0.10
expo-updates             ~29.0.13  29.0.12
expo-video               ~3.0.14   3.0.13

Changelogs:
- expo-dev-client → https://github.com/expo/expo/blob/sdk-54/packages/expo-dev-client/CHANGELOG.md
- expo-file-system → https://github.com/expo/expo/blob/sdk-54/packages/expo-file-system/CHANGELOG.md
- expo-linking → https://github.com/expo/expo/blob/sdk-54/packages/expo-linking/CHANGELOG.md
- expo-notifications → https://github.com/expo/expo/blob/sdk-54/packages/expo-notifications/CHANGELOG.md
- expo-splash-screen → https://github.com/expo/expo/blob/sdk-54/packages/expo-splash-screen/CHANGELOG.md
- expo-updates → https://github.com/expo/expo/blob/sdk-54/packages/expo-updates/CHANGELOG.md
- expo-video → https://github.com/expo/expo/blob/sdk-54/packages/expo-video/CHANGELOG.md

11 packages out of date.
Advice:
Use 'npx expo install --check' to review and upgrade your dependencies.
To ignore specific packages, add them to "expo.install.exclude" in package.json. Learn more: https://expo.fyi/dependency-validation

5 checks failed, indicating possible issues with the project.

mozzius avatar Dec 01 '25 09:12 mozzius

I ran https://github.com/expo/expo/pull/41319 in production and am no longer seeing these errors, so I think it's safe to say it successfully fixes this issue

mozzius avatar Dec 10 '25 12:12 mozzius