expo / expo

An open-source framework for making universal native apps with React. Expo runs on Android, iOS, and the web.
https://docs.expo.dev
MIT License
34.1k stars 5.46k forks source link

expo-image-picker 14.5.0 crash at launch randomly #26446

Closed walkev13 closed 6 months ago

walkev13 commented 9 months ago

Minimal reproducible example

expo-image-picker 14.5.0

Summary

Hi, Since I updated the lib to expo-image-picker 14.5.0 I get this issue randomly on Android devices (expo-go) :

Expo SDK version "49.0.21" Expo Image picker 14.5.0

Screenshot_20240116_164730

android.os.BadParcelableException: ClassNotFoundException when unmarshalling: androidx.activity.result.ActivityResult android.os.Parcel.readParcelableCreatorInternal(Parcel.java:4950) android.os.Parcel.readParcelableInternal(Parcel.java:4807) android.os.Parcel.readValue(Parcel.java:4567) android.os.Parcel.readValue(Parcel.java:4347) android.os.Parcel.-$$Nest$mreadValue(Unknown Source:0) android.os.Parcel$LazyValue.apply(Parcel.java:4445) android.os.Parcel$LazyValue.apply(Parcel.java:4404) android.os.BaseBundle.getValueAt(BaseBundle.java:394) android.os.BaseBundle.getValue(BaseBundle.java:374) android.os.BaseBundle.getValue(BaseBundle.java:357) android.os.BaseBundle.getValue(BaseBundle.java:350) android.os.Bundle.getParcelable(Bundle.java:913) expo.modules.kotlin.activityresult.AppContextActivityResultRegistry.register$lambda$4(AppContextActivityResultRegistry.kt:180) expo.modules.kotlin.activityresult.AppContextActivityResultRegistry.$r8$lambda$gFnAFYQBDwbvoCVbuhBd_kklIEI(Unknown Source:0) expo.modules.kotlin.activityresult.AppContextActivityResultRegistry$$ExternalSyntheticLambda0.onStateChanged(Unknown Source:4) androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:314) androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.kt:192) expo.modules.kotlin.activityresult.AppContextActivityResultRegistry$LifecycleContainer.addObserver(AppContextActivityResultRegistry.kt:349) expo.modules.kotlin.activityresult.AppContextActivityResultRegistry.register(AppContextActivityResultRegistry.kt:204) expo.modules.kotlin.activityresult.ActivityResultsManager$registerForActivityResult$$inlined$withActivityAvailable$1.onActivityAvailable(AppCompatActivityAware.kt:52) expo.modules.kotlin.activityaware.AppCompatActivityAwareHelper.dispatchOnActivityAvailable$lambda$0(AppCompatActivityAwareHelper.kt:22) expo.modules.kotlin.activityaware.AppCompatActivityAwareHelper.$r8$lambda$L0_3q4QT_5Qc1BOqSsnIOw3Ce3A(Unknown Source:0) expo.modules.kotlin.activityaware.AppCompatActivityAwareHelper$$ExternalSyntheticLambda1.run(Unknown Source:4) android.app.Activity.runOnUiThread(Activity.java:7367) expo.modules.kotlin.activityaware.AppCompatActivityAwareHelper.dispatchOnActivityAvailable(AppCompatActivityAwareHelper.kt:20) expo.modules.kotlin.activityresult.ActivityResultsManager.onHostResume(ActivityResultsManager.kt:62) expo.modules.kotlin.AppContext.onHostResume$expo_modules_core_debug(AppContext.kt:294) expo.modules.kotlin.ReactLifecycleDelegate.onHostResume(ReactLifecycleDelegate.kt:21) com.facebook.react.bridge.ReactContext.onHostResume(ReactContext.java:308) com.facebook.react.ReactInstanceManager.moveToResumedLifecycleState(ReactInstanceManager.java:778) com.facebook.react.ReactInstanceManager.moveReactContextToCurrentLifecycleState(ReactInstanceManager.java:813) com.facebook.react.ReactInstanceManager.-$$Nest$mmoveReactContextToCurrentLifecycleState(Unknown Source:0) com.facebook.react.ReactInstanceManager$6.run(ReactInstanceManager.java:1202) android.os.Handler.handleCallback(Handler.java:942) android.os.Handler.dispatchMessage(Handler.java:99) android.os.Looper.loopOnce(Looper.java:201) android.os.Looper.loop(Looper.java:288) android.app.ActivityThread.main(ActivityThread.java:7884) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) Caused by java.lang.ClassNotFoundException: androidx.activity.result.ActivityResult java.lang.Class.classForName(Native Method) java.lang.Class.forName(Class.java:536) android.os.Parcel.readParcelableCreatorInternal(Parcel.java:4916) android.os.Parcel.readParcelableInternal(Parcel.java:4807) android.os.Parcel.readValue(Parcel.java:4567) android.os.Parcel.readValue(Parcel.java:4347) android.os.Parcel.-$$Nest$mreadValue(Unknown Source:0) android.os.Parcel$LazyValue.apply(Parcel.java:4445) android.os.Parcel$LazyValue.apply(Parcel.java:4404) android.os.BaseBundle.getValueAt(BaseBundle.java:394) android.os.BaseBundle.getValue(BaseBundle.java:374) android.os.BaseBundle.getValue(BaseBundle.java:357) android.os.BaseBundle.getValue(BaseBundle.java:350) android.os.Bundle.getParcelable(Bundle.java:913) expo.modules.kotlin.activityresult.AppContextActivityResultRegistry.register$lambda$4(AppContextActivityResultRegistry.kt:180) expo.modules.kotlin.activityresult.AppContextActivityResultRegistry.$r8$lambda$gFnAFYQBDwbvoCVbuhBd_kklIEI(Unknown Source:0) expo.modules.kotlin.activityresult.AppContextActivityResultRegistry$$ExternalSyntheticLambda0.onStateChanged(Unknown Source:4) androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:314) androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.kt:192) expo.modules.kotlin.activityresult.AppContextActivityResultRegistry$LifecycleContainer.addObserver(AppContextActivityResultRegistry.kt:349) expo.modules.kotlin.activityresult.AppContextActivityResultRegistry.register(AppContextActivityResultRegistry.kt:204) expo.modules.kotlin.activityresult.ActivityResultsManager$registerForActivityResult$$inlined$withActivityAvailable$1.onActivityAvailable(AppCompatActivityAware.kt:52) expo.modules.kotlin.activityaware.AppCompatActivityAwareHelper.dispatchOnActivityAvailable$lambda$0(AppCompatActivityAwareHelper.kt:22) expo.modules.kotlin.activityaware.AppCompatActivityAwareHelper.$r8$lambda$L0_3q4QT_5Qc1BOqSsnIOw3Ce3A(Unknown Source:0) expo.modules.kotlin.activityaware.AppCompatActivityAwareHelper$$ExternalSyntheticLambda1.run(Unknown Source:4) android.app.Activity.runOnUiThread(Activity.java:7367) expo.modules.kotlin.activityaware.AppCompatActivityAwareHelper.dispatchOnActivityAvailable(AppCompatActivityAwareHelper.kt:20) expo.modules.kotlin.activityresult.ActivityResultsManager.onHostResume(ActivityResultsManager.kt:62) expo.modules.kotlin.AppContext.onHostResume$expo_modules_core_debug(AppContext.kt:294) expo.modules.kotlin.ReactLifecycleDelegate.onHostResume(ReactLifecycleDelegate.kt:21) com.facebook.react.bridge.ReactContext.onHostResume(ReactContext.java:308) com.facebook.react.ReactInstanceManager.moveToResumedLifecycleState(ReactInstanceManager.java:778) com.facebook.react.ReactInstanceManager.moveReactContextToCurrentLifecycleState(ReactInstanceManager.java:813) com.facebook.react.ReactInstanceManager.-$$Nest$mmoveReactContextToCurrentLifecycleState(Unknown Source:0) com.facebook.react.ReactInstanceManager$6.run(ReactInstanceManager.java:1202) android.os.Handler.handleCallback(Handler.java:942) android.os.Handler.dispatchMessage(Handler.java:99) android.os.Looper.loopOnce(Looper.java:201) android.os.Looper.loop(Looper.java:288) android.app.ActivityThread.main(ActivityThread.java:7884) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) Caused by java.lang.ClassNotFoundException: androidx.activity.result.ActivityResult java.lang.Class.classForName(Native Method) java.lang.BootClassLoader.findClass(ClassLoader.java:1366) java.lang.BootClassLoader.loadClass(ClassLoader.java:1426) java.lang.ClassLoader.loadClass(ClassLoader.java:312) java.lang.Class.classForName(Native Method) java.lang.Class.forName(Class.java:536) android.os.Parcel.readParcelableCreatorInternal(Parcel.java:4916) android.os.Parcel.readParcelableInternal(Parcel.java:4807) android.os.Parcel.readValue(Parcel.java:4567) android.os.Parcel.readValue(Parcel.java:4347) android.os.Parcel.-$$Nest$mreadValue(Unknown Source:0) android.os.Parcel$LazyValue.apply(Parcel.java:4445) android.os.Parcel$LazyValue.apply(Parcel.java:4404) android.os.BaseBundle.getValueAt(BaseBundle.java:394) android.os.BaseBundle.getValue(BaseBundle.java:374) android.os.BaseBundle.getValue(BaseBundle.java:357) android.os.BaseBundle.getValue(BaseBundle.java:350) android.os.Bundle.getParcelable(Bundle.java:913) expo.modules.kotlin.activityresult.AppContextActivityResultRegistry.register$lambda$4(AppContextActivityResultRegistry.kt:180) expo.modules.kotlin.activityresult.AppContextActivityResultRegistry.$r8$lambda$gFnAFYQBDwbvoCVbuhBd_kklIEI(Unknown Source:0) expo.modules.kotlin.activityresult.AppContextActivityResultRegistry$$ExternalSyntheticLambda0.onStateChanged(Unknown Source:4) androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:314) androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.kt:192) expo.modules.kotlin.activityresult.AppContextActivityResultRegistry$LifecycleContainer.addObserver(AppContextActivityResultRegistry.kt:349) expo.modules.kotlin.activityresult.AppContextActivityResultRegistry.register(AppContextActivityResultRegistry.kt:204) expo.modules.kotlin.activityresult.ActivityResultsManager$registerForActivityResult$$inlined$withActivityAvailable$1.onActivityAvailable(AppCompatActivityAware.kt:52) expo.modules.kotlin.activityaware.AppCompatActivityAwareHelper.dispatchOnActivityAvailable$lambda$0(AppCompatActivityAwareHelper.kt:22) expo.modules.kotlin.activityaware.AppCompatActivityAwareHelper.$r8$lambda$L0_3q4QT_5Qc1BOqSsnIOw3Ce3A(Unknown Source:0) expo.modules.kotlin.activityaware.AppCompatActivityAwareHelper$$ExternalSyntheticLambda1.run(Unknown Source:4) android.app.Activity.runOnUiThread(Activity.java:7367) expo.modules.kotlin.activityaware.AppCompatActivityAwareHelper.dispatchOnActivityAvailable(AppCompatActivityAwareHelper.kt:20) expo.modules.kotlin.activityresult.ActivityResultsManager.onHostResume(ActivityResultsManager.kt:62) expo.modules.kotlin.AppContext.onHostResume$expo_modules_core_debug(AppContext.kt:294) expo.modules.kotlin.ReactLifecycleDelegate.onHostResume(ReactLifecycleDelegate.kt:21) com.facebook.react.bridge.ReactContext.onHostResume(ReactContext.java:308) com.facebook.react.ReactInstanceManager.moveToResumedLifecycleState(ReactInstanceManager.java:778) com.facebook.react.ReactInstanceManager.moveReactContextToCurrentLifecycleState(ReactInstanceManager.java:813) com.facebook.react.ReactInstanceManager.-$$Nest$mmoveReactContextToCurrentLifecycleState(Unknown Source:0) com.facebook.react.ReactInstanceManager$6.run(ReactInstanceManager.java:1202) android.os.Handler.handleCallback(Handler.java:942) android.os.Handler.dispatchMessage(Handler.java:99) android.os.Looper.loopOnce(Looper.java:201) android.os.Looper.loop(Looper.java:288) android.app.ActivityThread.main(ActivityThread.java:7884) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) Caused by java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

Environment

expo-env-info 1.0.5 environment info: System: OS: macOS 14.2.1 Shell: 5.9 - /bin/zsh Binaries: Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm Watchman: 2023.11.13.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.14.2 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 23.2, iOS 17.2, macOS 14.2, tvOS 17.2, watchOS 10.2 IDEs: Android Studio: 2022.3 AI-223.8836.35.2231.11005911 Xcode: 15.1/15C65 - /usr/bin/xcodebuild npmPackages: @expo/metro-config: ~0.10.0 => 0.10.7 expo: 49.0.21 => 49.0.21 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.6 => 0.19.9 npmGlobalPackages: eas-cli: 5.9.3 Expo Workflow: bare

alanjhughes commented 9 months ago

Hi @walkev13 - The supported version of expo-image-picker for SDK 49 in expo go is 14.3.2. To use higher versions you will need to build a development client. I would recommend doing this anyway. Expo go is a prototyping tool. Run npx expo install --fix to fix the dependency issue and that should resolve the error.

walkev13 commented 9 months ago

Hi @alanjhughes ! Thank your for your comment. I used 14.5.0 because I had an issue when I upload picture on "don't keep activity mode" and the bug has been fixed in the 14.5.0 release...

alanjhughes commented 9 months ago

@walkev13 SDK 50 will release soon with expo go containing version 14.7.1 of expo-image-picker. You could wait for that but I would try with a dev client first.

walkev13 commented 9 months ago

@alanjhughes I already use a custom development client on SDK 49 :)

alanjhughes commented 9 months ago

@walkev13 - There was changes in 14.5.0 to support react native 0.73. SDK 49 uses 0.72. Curious why you want to use Don't keep activities? That setting is useful for debugging activities being destroyed on low end devices but not as useful in a react native context where you only have a single activity to begin with and don't have precise insight to it's lifecycle

walkev13 commented 9 months ago

@alanjhughes some of our users are in this case "android system sometimes kills the MainActivity after the ImagePicker finishes." (https://docs.expo.dev/versions/latest/sdk/imagepicker/#imagepickergetpendingresultasync). To simulate this case, I use the "don't keep activity" mode

alanjhughes commented 9 months ago

@walkev13 - ok, well this was partially fixed in 14.5.0 but there is still an issue of reloading the entire app where in some instances react native doesn't finish initializing everything leading to a crash. I will investigate again but may be an upstream issue

github-actions[bot] commented 6 months ago

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[bot] commented 6 months ago

This issue was closed because it has been inactive for 7 days since being marked as stale. Please open a new issue if you believe you are encountering a related problem.