Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
This repository was archived by the owner on May 20, 2025. It is now read-only.

Problem with restartApp() #1684

Closed
Closed
@peacepostman

Description

@peacepostman

Hello, i am having an issue while trying to use codePush.restartApp() on android, we have no problem on ios but android trigger the following error

Steps to Reproduce

  1. Add codePush.restartApp() on a react-native screen with a setTimeout
  2. Wait for app to crash 🗡

Expected Behavior

App should restart without any problem

Actual Behavior

App crash on release mode, no problem in dev mode

com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets
CatalystInstanceImpl.java, line -2
java.lang.RuntimeException: Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle 'null' is packaged correctly for release.

Environment

  • react-native-code-push version: 5.7.0
  • react-native version: 0.60.5
  • iOS/Android/Windows version: Android 8.1.0
  • Release build, no problem on dev

Activity

peacepostman

peacepostman commented on Sep 19, 2019

@peacepostman
Author

Note that the issue also happens with or without hermes enabled

KingAmo

KingAmo commented on Oct 11, 2019

@KingAmo

same problem here, restartApp() works fine in iOS and debug mode in Android; while in release mode in Android, when call restartApp(), app restart successfully but get stuck, and cannot do anything unless you kill app and restart manually , logcat info:

2019-10-11 13:57:11.093 23049-23049/com.kjkdoctor W/MessageQueue: Handler 
(com.facebook.react.bridge.queue.MessageQueueThreadHandler) {ce71c1c} sending message to a 
Handler on a dead thread

  java.lang.IllegalStateException: Handler 
(com.facebook.react.bridge.queue.MessageQueueThreadHandler) {551795a} sending message to a
 Handler on a dead thread
        at android.os.MessageQueue.enqueueMessage(MessageQueue.java:654)
        at android.os.Handler.enqueueMessage(Handler.java:769)
        at android.os.Handler.sendMessageAtTime(Handler.java:718)
        at android.os.Handler.sendMessageDelayed(Handler.java:688)
        at android.os.Handler.post(Handler.java:405)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl.runOnQueue(MessageQueueThreadImpl.java:65)
        at com.facebook.react.bridge.ReactContext.runOnJSQueueThread(ReactContext.java:330)
        at com.facebook.react.uimanager.events.EventDispatcher$ScheduleDispatchFrameCallback.doFrame(EventDispatcher.java:291)
        at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:174)
        at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:84)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1090)
        at android.view.Choreographer.doCallbacks(Choreographer.java:893)
        at android.view.Choreographer.doFrame(Choreographer.java:809)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1078)
        at android.os.Handler.handleCallback(Handler.java:907)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:216)
        at android.app.ActivityThread.main(ActivityThread.java:7625)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)

react-native info

System:
    OS: macOS 10.14.6
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 20.14 MB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 12.3.1 - /usr/local/bin/node
    Yarn: 1.16.0 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK:
      API Levels: 21, 23, 26, 27, 28
      Build Tools: 23.0.1, 26.0.1, 28.0.3, 29.0.2
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5900203
    Xcode: 11.1/11A1027 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.2 => 0.61.2
    "react-native-code-push": "^5.6.1",
KingAmo

KingAmo commented on Oct 11, 2019

@KingAmo

temporary solution in my case:

 setTimeout(() => {
     CodePush.restartApp();
 }, 300);
peacepostman

peacepostman commented on Oct 11, 2019

@peacepostman
Author

Even with the setTimeout we were encountering this issue, the problem went away when i tried with https://github.com/avishayil/react-native-restart, so even if the linked lib is based upon react-native-code-push, there must something different not causing the issue.

nkashyap

nkashyap commented on Oct 16, 2019

@nkashyap

I tried both workarounds but with no luck :(

aymanblank

aymanblank commented on Oct 26, 2019

@aymanblank

Make sure that you added the following override to your MainApplication.java

@Override
protected String getJSBundleFile() {
  return CodePush.getJSBundleFile();
}

inside private final ReactNativeHost mReactNativeHost

this solved the issue in my case.

self-assigned this
on Feb 12, 2020
andreidubov

andreidubov commented on Feb 12, 2020

@andreidubov
Contributor

Hi @peacepostman ,
Thank you for reporting!

As I can see, you are using react-native v0.60.5 and react-native-code-push v5.7.0 but these are incompatible versions, you can take a look at supporting CodePush versions here: https://github.com/microsoft/react-native-code-push#supported-react-native-platforms

Not so long ago we released a new version of Code Push which supports react-native v0.60-v0.61.
All steps for installing the latest version of the plugin are described in our documentation: https://github.com/microsoft/react-native-code-push/blob/master/docs/setup-android.md

I'm going to close this issue for now. Please feel free to reopen it if you have any questions or issues.

rafetkhallaf

rafetkhallaf commented on Mar 18, 2022

@rafetkhallaf

Hi there,

I'm facing the same issue on RN 0.66.3 and using the latest codePush 7.0.4. I see in the ReadMe the supported version is v7.2 is there a specific way to upgrade the version from 7.0 to 7.2? I tried hard coding the version but I get an error that it doesn't exists.

    "react-native": "0.66.3",
    "react-native-cli": "^2.0.1",
    "react-native-code-push": "^7.0.4",

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @nkashyap@aymanblank@peacepostman@rafetkhallaf@KingAmo

      Issue actions

        Problem with restartApp() · Issue #1684 · microsoft/react-native-code-push