react-native-v8 icon indicating copy to clipboard operation
react-native-v8 copied to clipboard

Crash when using with react-native-code-push

Open Alaa-Ben opened this issue 4 years ago • 15 comments

Hi ! Since upgrading to 0.61.2 (and now I'm using 0.61.4), installing an update with codepush crashes the app. This only happens when using V8 (tried Hermes and JSC, no issue there). I have 2 traces, a JS one et a native one: JS: LOG [CodePush] Exception in HostFunction: Malformed calls from JS: field sizes are different. [[23,28],[1,0],[[80,100,1574329821120,false]],263]

Native:

11-21 10:44:47.153 15878 15878 E AndroidRuntime: java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: index=1 count=0 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.bridge.ReactContext.handleException(ReactContext.java:344) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.bridge.ReactContext$ExceptionHandlerWrapper.handleException(ReactContext.java:351) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.bridge.GuardedRunnable.run(GuardedRunnable.java:31) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:789) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:98) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6944) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: Caused by: java.lang.IndexOutOfBoundsException: index=1 count=0 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at android.view.ViewGroup.addInArray(ViewGroup.java:5234) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at android.view.ViewGroup.addViewInner(ViewGroup.java:5144) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at android.view.ViewGroup.addView(ViewGroup.java:4953) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at android.view.ViewGroup.addView(ViewGroup.java:4893) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.uimanager.ViewGroupManager.addView(ViewGroupManager.java:35) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(NativeViewHierarchyManager.java:512) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:205) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:779) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:888) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.uimanager.UIViewOperationQueue.access$2200(UIViewOperationQueue.java:42) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.uimanager.UIViewOperationQueue$2.runGuarded(UIViewOperationQueue.java:846) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.bridge.GuardedRunnable.run(GuardedRunnable.java:29) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: ... 7 more

Any leads ? thanks in advance !

Alaa-Ben avatar Nov 21 '19 09:11 Alaa-Ben

@Alaa-Ben Which react-native-v8 version you currently use? And could you explain the scenario of codepush you tried? (E.g. just update a new JS bundle through codepush and it will crash immediately?)

Kudo avatar Nov 23 '19 03:11 Kudo

hi @Kudo, thanks for your reply ! I am using React native 0.61.4 and react-native-v8 0.61.4-patch.1 (no-intl version). The scenario:

  • Release a new js bundle via codepush
  • Phone receives it, there is a pop-up "New update available, would you like to install it ?"
  • Press "yes"
  • crash "Your app has stopped working" + stacktrace in my first post. What's weird is sometimes the bundle is installed despite the crash (when I relaunch the app after crash, the new update is running). But still can't use it in production as it is bad for customers.

If you need more information, just ask ;)

Alaa-Ben avatar Nov 25 '19 08:11 Alaa-Ben

@Alaa-Ben I tried to setup codepush but unfortunately unable to reproduce the crash. Could you share how to setup codepush ? I referenced this steps and leveraged RN autolink: https://github.com/MicrosoftDocs/appcenter-docs/pull/767

Kudo avatar Nov 29 '19 02:11 Kudo

Oh I saw the error in log, although there were not crashes. Will try to dig the problem.

Kudo avatar Nov 29 '19 02:11 Kudo

Confirmed this is duplicated as #27 that CodePush will fetch data and there is an existing FileReader passed into RN bridge.

Kudo avatar Nov 29 '19 04:11 Kudo

@Kudo

@Alaa-Ben I tried to setup codepush but unfortunately unable to reproduce the crash. Could you share how to setup codepush ? I referenced this steps and leveraged RN autolink: MicrosoftDocs/appcenter-docs#767

I didn't autolink it. I'm using asymetric keys to sign my bundle, and I didn't find instructions about how to add that to autolinking yet. So basically my setup is like for RN < 0.60 as i'm ignoring autolinking.

Confirmed this is duplicated as #27 that CodePush will fetch data and there is an existing FileReader passed into RN bridge.

So for now, the only solution is the PR you submitted to react native ?

Alaa-Ben avatar Nov 29 '19 08:11 Alaa-Ben

So for now, the only solution is the PR you submitted to react native ?

A workaround is to patch V8 internally and remove the exception from Object.freeze(). Please let me wait for some days to see if there are any updates from the PR first.

Kudo avatar Nov 29 '19 13:11 Kudo

@Kudo FYI, Debugging through chrome doesn't produce the error. Weird, no ? I thought it was the same engine (different versions maybe).

Alaa-Ben avatar Dec 03 '19 15:12 Alaa-Ben

@Alaa-Ben AFAIK, for remote debugging, RN will run on legacy bridge mode, i.e. not JSI objects. That's why the error will not happen on remote debugging mode.

Kudo avatar Dec 04 '19 01:12 Kudo

@Alaa-Ben Considering the PR not updated for a while, I finally decide to workaround the issue in V8. Please try to use [email protected] / [email protected] and see if this could solve your problems. Thank you.

Kudo avatar Dec 17 '19 00:12 Kudo

@Kudo Thanks for your work ! It works in debug version, no more issues there. In release config, there's still a problem. here's what I did:

  • Download the codepush update for the first time: works
  • Delete data + cache of the app (so I can redownload bundle for more tests)
  • Launch the app, I get the update popup, press 'yes' to update, then the same crash occurs (your app stopped working) with the IndexOutOfBoundException. And same as before when i relaunch app after the crash, the app is updated and everything works fine.

Maybe I shouldn't be deleting data + cache and this remaining issue has nothing to do with v8. Still an improvement though because before it didn't work at all, thanks a lot !

Alaa-Ben avatar Dec 18 '19 10:12 Alaa-Ben

Hi ! Since upgrading to 0.61.2 (and now I'm using 0.61.4), installing an update with codepush crashes the app. This only happens when using V8 (tried Hermes and JSC, no issue there). I have 2 traces, a JS one et a native one: JS: LOG [CodePush] Exception in HostFunction: Malformed calls from JS: field sizes are different. [[23,28],[1,0],[[80,100,1574329821120,false]],263]

Native:

11-21 10:44:47.153 15878 15878 E AndroidRuntime: java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: index=1 count=0 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.bridge.ReactContext.handleException(ReactContext.java:344) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.bridge.ReactContext$ExceptionHandlerWrapper.handleException(ReactContext.java:351) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.bridge.GuardedRunnable.run(GuardedRunnable.java:31) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:789) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:98) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6944) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: Caused by: java.lang.IndexOutOfBoundsException: index=1 count=0 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at android.view.ViewGroup.addInArray(ViewGroup.java:5234) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at android.view.ViewGroup.addViewInner(ViewGroup.java:5144) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at android.view.ViewGroup.addView(ViewGroup.java:4953) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at android.view.ViewGroup.addView(ViewGroup.java:4893) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.uimanager.ViewGroupManager.addView(ViewGroupManager.java:35) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(NativeViewHierarchyManager.java:512) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:205) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:779) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:888) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.uimanager.UIViewOperationQueue.access$2200(UIViewOperationQueue.java:42) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.uimanager.UIViewOperationQueue$2.runGuarded(UIViewOperationQueue.java:846) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: at com.facebook.react.bridge.GuardedRunnable.run(GuardedRunnable.java:29) 11-21 10:44:47.153 15878 15878 E AndroidRuntime: ... 7 more

Any leads ? thanks in advance !

hi @Kudo I upgraded my app to React Native 0.62.2, i'm using:

"react-native-v8": "^0.62.2-patch.1"
  "v8-android-nointl": "^8.80.1"

This issue still happens. What is weird is that it happens only on the first time. Here are the steps I do and what happens exactly:

  1. Create codepush update using appcenter-cli
  2. Open app, user gets a modal informing him about the update. Press Yes (to update app).
  3. App crashes and quits, logcat shows the error above (java.lang.IndexOutOfBoundsException). When I open the app again, update isn't installed, but the modal doesn't appear, which means the update is on the phone storage.
  4. Go to my app's settings, press "delete all data" so it deletes the update.
  5. Reopen app, modal appears again, press "yes", update is installed correctly and everything is fine.

Any ideas ? thanks in advance !

Alaa-Ben avatar Jun 02 '20 12:06 Alaa-Ben

Hello, we have this issue too? Any ideas on how to fix it?

marf avatar Mar 20 '21 11:03 marf

Could you have a sample repo to have the issue? You could leave the deployment key as stub string and I could replace with my own. Appreciating if you could have a sample.

Kudo avatar Mar 26 '21 01:03 Kudo

Hello, unfortunately, we do not have a reproducible demo, but we see in crash logs that on our release version once we apply a code-push patch crashes spikes while if we do not release a code-push patch no crash happens. We auto-apply the code-push patch without showing an alert to update it. We are at the disposal to share our project code-base if you want but I think it may be better to try to integrate code push in a sample project with react native navigation and try to publish a patch in release mode. If you want I can leave my private email so that we can discuss this in private.

marf avatar Mar 26 '21 11:03 marf