React-native-code-push: Android crash with InstallMode.IMMEDIATE - IllegalViewOperationException: Trying to remove a view index above child count

Created on 31 Aug 2017  路  14Comments  路  Source: microsoft/react-native-code-push

I wondered if you'd seen something similar in https://github.com/facebook/react-native/issues/14533? @sergey-akhalkov ?

Steps to Reproduce

  1. Install old app with RN 0.44 & code push v3.0.1.
  2. Download and run a new bundle update.
  3. Update app binary with RN 0.47 & code push v5.0.0
  4. Install code push update with InstallMode.IMMEDIATE

Only occurs when the app is upgrading, but I can't see if it is doing anything different so far.

Expected Behaviour

App Restarts

Actual Behavior

What actually happens?
App will crash with following stacktrace.

FATAL EXCEPTION: main
Process: com.example, PID: 14747
com.facebook.react.uimanager.IllegalViewOperationException: Trying to remove a view index above child count 0 view tag: 1
 detail: View tag:-1
  children(0): [
 ],
  indicesToRemove(1): [
0,
 ],
  tagsToDelete(1): [
4,
 ]

    at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(NativeViewHierarchyManager.java:346)
    at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:177)
    at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:776)
    at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:855)
    at com.facebook.react.uimanager.UIViewOperationQueue.access$1600(UIViewOperationQueue.java:46)
    at com.facebook.react.uimanager.UIViewOperationQueue$2.runGuarded(UIViewOperationQueue.java:813)
    at com.facebook.react.bridge.GuardedRunnable.run(GuardedRunnable.java:21)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6541)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Environment

  • react-native-code-push version: v3.0.1 / v5.0.0
  • react-native version: 0.44/0.47
  • iOS/Android/Windows version: Android - Any
  • Does this reproduce on a debug build or release build? release
  • Does this reproduce on a simulator, or only on a physical device? physical
android waiting-for-clarification

Most helpful comment

@AndrewJack , Even I am facing the same error with RN 0.45.1 and RNCP 3.0.0-beta.

My CodePush configuration is

CodePush.sync(
  { updateDialog: true, installMode: CodePush.InstallMode.IMMEDIATE },
    status => {
        switch (status) {
          case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
            this.setState({ showDownloadingModal: true });
            this._modal.open();
            break;
          case CodePush.SyncStatus.INSTALLING_UPDATE:
            this.setState({ showInstalling: true });
            break;
          case CodePush.SyncStatus.UPDATE_INSTALLED:
            this._modal.close();
            this.setState({ showDownloadingModal: false });
            break;
          default:
            break;
        }
      },
      ({ receivedBytes, totalBytes }) => {
        this.setState({ downloadProgress: receivedBytes / totalBytes * 100 });
      }
    );

What is the install mode you set which got your code push working?

All 14 comments

Hi @AndrewJack, thanks for reaching us. No, I've not seen similar issues.

  1. Is there a chance if you have the same issue as here https://github.com/Microsoft/react-native-code-push/issues/775#issuecomment-291534691 ?
  2. Have you incremented your app version after upgrade?
  3. Is there a chance that you've released a CodePush update a long time ago that may target to your current app binary version?

Thanks, I don't think there is any chance of mixing RN versions, they are all targeted at the correct binary versions.

I will try to reproduce in a simpler sample app.

@AndrewJack, got it, thank you, please let us know if you have any updates or have any questions.

Hi @AndrewJack, just a friendly ping - do you have any updates on this?

Hey sorry, I'm a bit busy right now. I've worked around my problem for now by removing the immediate update.

Feel free to close this issue. I'll reopen when I have more information.

Got it, thanks for the update!

@AndrewJack , Even I am facing the same error with RN 0.45.1 and RNCP 3.0.0-beta.

My CodePush configuration is

CodePush.sync(
  { updateDialog: true, installMode: CodePush.InstallMode.IMMEDIATE },
    status => {
        switch (status) {
          case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
            this.setState({ showDownloadingModal: true });
            this._modal.open();
            break;
          case CodePush.SyncStatus.INSTALLING_UPDATE:
            this.setState({ showInstalling: true });
            break;
          case CodePush.SyncStatus.UPDATE_INSTALLED:
            this._modal.close();
            this.setState({ showDownloadingModal: false });
            break;
          default:
            break;
        }
      },
      ({ receivedBytes, totalBytes }) => {
        this.setState({ downloadProgress: receivedBytes / totalBytes * 100 });
      }
    );

What is the install mode you set which got your code push working?

Removing this piece of code from UPDATE_INSTALLED case made my code-push working

this._modal.close();
this.setState({ showDownloadingModal: false });

So my UPDATE_INSTALLED case is just empty.

FYI - removing any state changes after a UPDATE_INSTALLED status change fixed this for me.

Yup,I too face same issue it is not happening on debug mode it is happening on release apk only. After removing setState code under UPDATE_INSTALLED it is working fine. Guess it is accessing state which is not there

@sood03 How did you end up closing your modal then? I'm depending on state to know when codepush is finished installing the update. Only then do I actually render my App component. How would I know when codepush is finished?

@Li357 Did you ever figure this out? I'm wondering the same thing.... How to show the app content once the update is complete. I'm making a wild guess that the second time the app is loaded that it will trigger UP_TO_DATE, which can then close the loading screen?

I can actually confirm that it works. Seems my UP_TO_DATE case that closes my loading screen is good enough.

@tmaly1980 @vinaysmart @sergey-akhalkov In my app I have removed all setState in codepush notifications. We are not doing anything in codepush notifications except logging. Still we face this issue.

About 2-3% of the users are facing this issue.

In our app we dont do anything in codepush notifications, so the app continues rendering the screens. Then the user will start using the app when the codepush download/install is in progress. If we dont have any logic in notifications then how to avoid user to stop using the app? since the user is using the app there will be some setState in the app, which may be causing this issue.

Also I have noticed then after the codepush gives UPDATE_INSTALLED notification, app is not restarting. I have tested by killing and opening the app. Codepush is downloading/installing the update, the changes are reflected in app but there is no restart(I have added logs in the constructor to verify this)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SudoPlz picture SudoPlz  路  4Comments

sergey-akhalkov picture sergey-akhalkov  路  4Comments

jaysig picture jaysig  路  3Comments

osdnk picture osdnk  路  3Comments

vira-khdr picture vira-khdr  路  3Comments