What’s happening?
The App .apk build crashes on first load then works after reopening the app, this behaviour happens on both emulator and physical devices.
The app works fine on the expo go app for both android and ios.
Log cat error
6765-6824/com.company.appname E/ReactNativeJS: Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
2022-05-24 12:08:09.997 6765-6825/com.company.appname E/unknown:ReactContextBaseJavaModule: Unhandled SoftException
java.lang.RuntimeException: Catalyst Instance has already disappeared: requested by DeviceInfo
at com.facebook.react.bridge.ReactContextBaseJavaModule.getReactApplicationContextIfActiveOrWarn(ReactContextBaseJavaModule.java:66)
at com.facebook.react.modules.deviceinfo.DeviceInfoModule.invalidate(DeviceInfoModule.java:114)
at com.facebook.react.bridge.ModuleHolder.destroy(ModuleHolder.java:110)
at com.facebook.react.bridge.NativeModuleRegistry.notifyJSInstanceDestroy(NativeModuleRegistry.java:108)
at com.facebook.react.bridge.CatalystInstanceImpl$1.run(CatalystInstanceImpl.java:368)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loop(Looper.java:223)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
at java.lang.Thread.run(Thread.java:923)
2022-05-24 12:08:09.997 6765-6825/com.company.appname E/unknown:ReactContextBaseJavaModule: Unhandled SoftException
java.lang.RuntimeException: Catalyst Instance has already disappeared: requested by AppState
at com.facebook.react.bridge.ReactContextBaseJavaModule.getReactApplicationContextIfActiveOrWarn(ReactContextBaseJavaModule.java:66)
at com.facebook.react.modules.appstate.AppStateModule.invalidate(AppStateModule.java:127)
at com.facebook.react.bridge.ModuleHolder.destroy(ModuleHolder.java:110)
at com.facebook.react.bridge.NativeModuleRegistry.notifyJSInstanceDestroy(NativeModuleRegistry.java:108)
at com.facebook.react.bridge.CatalystInstanceImpl$1.run(CatalystInstanceImpl.java:368)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loop(Looper.java:223)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
at java.lang.Thread.run(Thread.java:923)
2022-05-24 12:08:09.997 6765-6825/com.company.appname E/unknown:ReactContextBaseJavaModule: Unhandled SoftException
java.lang.RuntimeException: Catalyst Instance has already disappeared: requested by NativeAnimatedModule
at com.facebook.react.bridge.ReactContextBaseJavaModule.getReactApplicationContextIfActiveOrWarn(ReactContextBaseJavaModule.java:66)
at com.facebook.react.animated.NativeAnimatedModule.invalidate(NativeAnimatedModule.java:897)
at com.facebook.react.bridge.ModuleHolder.destroy(ModuleHolder.java:110)
at com.facebook.react.bridge.NativeModuleRegistry.notifyJSInstanceDestroy(NativeModuleRegistry.java:108)
at com.facebook.react.bridge.CatalystInstanceImpl$1.run(CatalystInstanceImpl.java:368)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loop(Looper.java:223)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
at java.lang.Thread.run(Thread.java:923)
2022-05-24 12:08:09.997 6765-6825/com.company.appname E/unknown:ReactContextBaseJavaModule: Unhandled SoftException
java.lang.RuntimeException: Catalyst Instance has already disappeared: requested by FrescoModule
at com.facebook.react.bridge.ReactContextBaseJavaModule.getReactApplicationContextIfActiveOrWarn(ReactContextBaseJavaModule.java:66)
at com.facebook.react.modules.fresco.FrescoModule.invalidate(FrescoModule.java:202)
at com.facebook.react.bridge.ModuleHolder.destroy(ModuleHolder.java:110)
at com.facebook.react.bridge.NativeModuleRegistry.notifyJSInstanceDestroy(NativeModuleRegistry.java:108)
at com.facebook.react.bridge.CatalystInstanceImpl$1.run(CatalystInstanceImpl.java:368)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loop(Looper.java:223)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
See if running in production mode in Expo Go helps to track down the cause of this problem:
I’ve done some searching based on the errors you’re seeing and I have not found a definitive answer.
It could be that you have some JavaScript error that’s causing this, so hopefully running in production mode in Expo Go will give you more information.
2022-05-25 08:22:54.198 22339-22426/host.exp.exponent E/Loader: Failed to load all assets
java.lang.Exception: Failed to load all assets
at expo.modules.updates.loader.Loader.handleAssetDownloadCompleted(Loader.kt:24)
at expo.modules.updates.loader.Loader.access$handleAssetDownloadCompleted(Loader.kt:1)
at expo.modules.updates.loader.Loader$downloadAllAssets$1.onFailure(Loader.kt:6)
at expo.modules.updates.loader.FileDownloader$downloadAsset$1.onFailure(FileDownloader.kt:1)
at expo.modules.updates.loader.FileDownloader$downloadFileToPath$1.onFailure(FileDownloader.kt:1)
at expo.modules.updates.loader.FileDownloader$downloadData$1.onFailure(FileDownloader.kt:2)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:15)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
2022-05-25 08:22:54.200 22339-22426/host.exp.exponent E/LoaderTask: Unexpected error encountered while loading this app
java.lang.Exception: Failed to load all assets
at expo.modules.updates.loader.Loader.handleAssetDownloadCompleted(Loader.kt:24)
at expo.modules.updates.loader.Loader.access$handleAssetDownloadCompleted(Loader.kt:1)
at expo.modules.updates.loader.Loader$downloadAllAssets$1.onFailure(Loader.kt:6)
at expo.modules.updates.loader.FileDownloader$downloadAsset$1.onFailure(FileDownloader.kt:1)
at expo.modules.updates.loader.FileDownloader$downloadFileToPath$1.onFailure(FileDownloader.kt:1)
at expo.modules.updates.loader.FileDownloader$downloadData$1.onFailure(FileDownloader.kt:2)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:15)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
2022-05-25 08:22:54.206 22339-22426/host.exp.exponent E/LoaderTask: Failed to download remote update
java.lang.Exception: Failed to load all assets
at expo.modules.updates.loader.Loader.handleAssetDownloadCompleted(Loader.kt:24)
at expo.modules.updates.loader.Loader.access$handleAssetDownloadCompleted(Loader.kt:1)
at expo.modules.updates.loader.Loader$downloadAllAssets$1.onFailure(Loader.kt:6)
at expo.modules.updates.loader.FileDownloader$downloadAsset$1.onFailure(FileDownloader.kt:1)
at expo.modules.updates.loader.FileDownloader$downloadFileToPath$1.onFailure(FileDownloader.kt:1)
at expo.modules.updates.loader.FileDownloader$downloadData$1.onFailure(FileDownloader.kt:2)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:15)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
OK, then I think you should try to narrow down the problem to find where in your code the problem is originating.
If a previous commit was working then check the changes you’ve made between then and the current version of the code. One way to do help with this is to use git bisect, but if it’s only a small number of changes it might be easy enough to just look at the changes manually.
Otherwise, try commenting out half of your code. If you no longer get the error it is likely coming from the commented out part of your code. If you still get the error then it is likely coming from the part that you did not comment out.
Based on the above, try commenting out another part of the code (e.g. take the half that you think the problem is coming from and comment out just half of that code.)
i.e. do a bisection search on your code to find where the error is coming from. (a.k.a. binary search)
I understand this might be a bit tricky depending on how your code is structured, but give it a try.
Alternatively, create a new app and start copying code into it from your real app and see when the error starts happening.
@wodin thanks for your recommendation. I did follow it and observe that the app crashes with Unexpected error encountered while loading this app java.lang.Exception: Failed to load all assets before metro Bundler completes bundling, the bundler gets to around 80% before the app crashes.
After app crash, I then close the expo go app and restart it pressing a on the command line, this opens expo and the app works fine.
My observation is that the app is attempting to get some file before bundling completes which results into the failed to load all assets error.
Is there a way to ensure the bundler completes before app the boot.
2022-05-25 12:20:41.195 5054-5152/host.exp.exponent W/unknown:ReactNative: StatusBarModule: Ignored status bar change, current activity is null.
2022-05-25 12:20:41.220 5054-5152/host.exp.exponent I/chatty: uid=10169(host.exp.exponent) mqt_native_modu identical 3 lines
2022-05-25 12:20:41.220 5054-5152/host.exp.exponent W/unknown:ReactNative: StatusBarModule: Ignored status bar change, current activity is null.
2022-05-25 12:20:41.233 5054-5151/host.exp.exponent W/ReactNativeJS: EventEmitter.removeListener('url', ...): Method has been deprecated. Please instead use `remove()` on the subscription returned by `EventEmitter.addListener`.
2022-05-25 12:20:41.278 5054-5054/host.exp.exponent I/ReactNative: [GESTURE HANDLER] Gesture handler is already enabled for a parent view
2022-05-25 12:20:41.278 5054-5054/host.exp.exponent I/chatty: uid=10169(host.exp.exponent) identical 1 line
2022-05-25 12:20:41.289 5054-5054/host.exp.exponent I/ReactNative: [GESTURE HANDLER] Gesture handler is already enabled for a parent view
2022-05-25 12:20:42.175 5054-5236/host.exp.exponent D/b: Do not have cached source file for https://exp.host/@exponent/home/bundle?versionName=2.24.4
2022-05-25 12:20:42.343 5054-5164/host.exp.exponent W/a: Could not find listener for key: devicePushToken
2022-05-25 12:20:43.684 5054-5071/host.exp.exponent I/st.exp.exponen: Background concurrent copying GC freed 245412(12MB) AllocSpace objects, 39(1496KB) LOS objects, 34% free, 46MB/70MB, paused 287us total 216.569ms
2022-05-25 12:20:43.688 5054-5054/host.exp.exponent D/q: Successfully preloaded kernel bundle
2022-05-25 12:20:43.697 5054-5073/host.exp.exponent W/System: A resource failed to call close.
2022-05-25 12:20:43.702 5054-5073/host.exp.exponent W/System: A resource failed to call close.
2022-05-25 12:21:00.970 5054-5140/host.exp.exponent E/Loader: Failed to download asset with key null
java.net.SocketTimeoutException: timeout
at okio.f0.newTimeoutException(JvmOkio.kt:1)
at okio.g.access$newTimeoutException(AsyncTimeout.kt:1)
at okio.g$d.read(AsyncTimeout.kt:6)
at okio.a0.d(RealBufferedSource.kt:7)
at okio.a0.e0(RealBufferedSource.kt:1)
at okhttp3.internal.http1.HeadersReader.readLine(HeadersReader.kt:1)
at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:2)
at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:1)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:25)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:12)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:4)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:12)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:27)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:12)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:22)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:12)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:7)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:12)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:16)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:6)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Caused by: java.net.SocketException: Socket closed
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:144)
at okio.s.read(JvmOkio.kt:5)
at okio.g$d.read(AsyncTimeout.kt:3)
at okio.a0.d(RealBufferedSource.kt:7)
at okio.a0.e0(RealBufferedSource.kt:1)
at okhttp3.internal.http1.HeadersReader.readLine(HeadersReader.kt:1)
at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:2)
at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:1)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:25)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:12)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:4)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:12)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:27)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:12)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:22)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:12)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:7)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:12)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:16)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:6)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
2022-05-25 12:21:00.980 5054-5140/host.exp.exponent E/Loader: Failed to load all assets
java.lang.Exception: Failed to load all assets
at expo.modules.updates.loader.Loader.handleAssetDownloadCompleted(Loader.kt:24)
You appear to be getting a socket timeout error, but I think this should all be happening on your own network (between your computer and the device you’re running Expo Go on). Unless you’re running expo start in tunnel mode or something like that.
The original issue was with a standalone app, right? So any assets would have been coming from a CDN and should in theory have downloaded OK.
But the fact that it also says the following makes me wonder if there really is a timeout:
The above error is being logged here:
It would be useful to know what URL or filename etc. it’s getting the error for, but for that you’d probably have to patch some of the native code involved. I think logging the url, relativePath and maybe these filenames would help.