Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The update not installed, keeps rolled back or throwing an exception #2639

Closed
mununki opened this issue Dec 27, 2023 · 6 comments
Closed

The update not installed, keeps rolled back or throwing an exception #2639

mununki opened this issue Dec 27, 2023 · 6 comments

Comments

@mununki
Copy link

mununki commented Dec 27, 2023

Every updates are not installed and keep rolled back or throwing an exception on iOS.
I started facing this issue after upgrading RN 0.68.7 -> 0.72.7 and code-push 7.1.0 -> 8.1.0.

Steps to Reproduce

  1. RN v0.72.7 and code-push v8.1.0, might be relavant "react-native-reanimated": "^3.4.0"
  2. Wrap the app
export default codePush({
  checkFrequency: codePush.CheckFrequency.MANUAL,
  installMode: codePush.InstallMode.ON_NEXT_RESTART,
})(App);
  1. Release the update

Expected Behavior

The update is installed

Actual Behavior

The update keeps rolled back, not installed on iOS. AOS is fine. I observed symptoms in two cases. It works fine on the previous versions.

1. Auto update

{
  checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
  installMode: codePush.InstallMode.IMMEDIATE,
}

This case cause the exception when I ran the app through the xcode to get an error stack.
Thread 3: "Error when sending event: CodePushDownloadProgress with body: {\n receivedBytes = 8914917;\n totalBytes = 8914917;\n}. RCTCallableJSModules is not set. This is probably because you've explicitly synthesized the RCTCallableJSModules in CodePush, even though it's inherited from RCTEventEmitter."

2. Manual update

{
  checkFrequency: codePush.CheckFrequency.MANUAL,
  installMode: codePush.InstallMode.ON_NEXT_RESTART,
}

This case doesn't cause the exception, but the sync call is not working as intended. When the sync is called, it logs

[CodePush] Checking for update.
[CodePush] An update is available, but it is being ignored due to having been previously rolled back.

Even if you check the app center dashboard, all updates are rolled back and not installed.

Reproducible Demo

Environment

  • react-native-code-push version: "^8.1.0"
  • react-native version: "0.72.7"
  • iOS/Android/Windows version: iOS 16.5.1
  • Does this reproduce on a debug build or release build? release and debug
  • Does this reproduce on a simulator, or only on a physical device? physical device and simulator
@WilliamWelsh
Copy link

I have the exact same issue.

Did you ever have expo-updates installed?

@mununki
Copy link
Author

mununki commented Dec 27, 2023

I have the exact same issue.

Did you ever have expo-updates installed?

No, I'm not using expo. It is configured with react-native-cli.

@mununki
Copy link
Author

mununki commented Dec 27, 2023

Similar issue: #2598

@mununki
Copy link
Author

mununki commented Jan 16, 2024

I finally fix this issue.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
  NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:self.moduleName
                                               initialProperties:self.initialProps
                                                   launchOptions:launchOptions];
...
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
...
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

I suspect the cause of the issue is that it creates a new rootView again during the process of checking for codepush updates, downloading the latest jsbundle, and installing it, causing an interruption in the middle. So I made the following modification and codepush update installed normally and works as intended.

  1. Call super in the first part of the function.
  2. Remove the part of initializing RCTRootView rootView that is already done inside super
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [super application:application didFinishLaunchingWithOptions:launchOptions];

  # NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
  # RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
  #                                                     moduleName:self.moduleName
  #                                              initialProperties:self.initialProps
  #                                                  launchOptions:launchOptions];

  #  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  #  UIViewController *rootViewController = [UIViewController new];
  #  rootViewController.view = rootView;
  #  self.window.rootViewController = rootViewController;
  #  [self.window makeKeyAndVisible];
...
return YES;
}

@mununki mununki closed this as completed Jan 16, 2024
@Gautham495
Copy link

Can you share the full snippet of AppDelegate.mm please.

@amanthegreatone
Copy link

pls check this i had this issue which was solved. #2529 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants