react-native-code-push icon indicating copy to clipboard operation
react-native-code-push copied to clipboard

minimumBackgroundDuration seems to not working

Open s-aleinik opened this issue 6 years ago • 8 comments

Steps to Reproduce

  1. Add the following CodePush config:
import CodePush from 'react-native-code-push';

CodePush.sync({
  minimumBackgroundDuration: Time.ONE_MINUTE * 5,
  installMode: CodePush.InstallMode.ON_NEXT_SUSPEND
})

or:

import CodePush from 'react-native-code-push';

export default CodePush({
  minimumBackgroundDuration: Time.ONE_MINUTE * 5,
  checkFrequency: CodePush.CheckFrequency.ON_APP_RESUME,
  installMode: CodePush.InstallMode.ON_NEXT_SUSPEND
})(App);
  1. Install the app and launch it for the first time.

Expected Behavior

CodePush update will be downloaded, but installed after app is being on a background for at least 5 minutes.

Actual Behavior

App reloads instantly.

 BUNDLE  [android, dev] ./index.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (1/1), done.

 LOG  Running "App" with {"rootTag":1}
 LOG  [CodePush] Checking for update.
 LOG  [CodePush] Reporting binary update (1.0)
 LOG  [CodePush] Downloading package.
 LOG  [CodePush] Installing update.
 LOG  [CodePush] Restarting app
 BUNDLE  [android, dev] ./index.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (1/1), done.

 LOG  Running "App" with {"rootTag":11}
 LOG  [CodePush] Checking for update.
 LOG  [CodePush] Reporting CodePush update success (v17)
 LOG  [CodePush] App is up to date.

Reproducible Demo

This is pretty much all the info I could provide. Have tried InstallMode.ON_NEXT_RESUME and InstallMode.ON_NEXT_SUSPEND - both are behaving the same way.

Environment

  • react-native-code-push version: 6.2.0
  • react-native version: 0.61.5
  • iOS: 13.3.1, Android: 9
  • Both debug and release builds.
  • Both simulator and physical device

s-aleinik avatar Apr 08 '20 16:04 s-aleinik

Any updates on this?

feiyingx avatar Apr 26 '20 23:04 feiyingx

Hi @s-aleinik, @feiyingx Thank you for reporting!

We found a problem with the ON_NEXT_SUSPEND mode but in other modes the minimumBackgroundDuration works as expected. We are currently working on this issue. Сurrent PR: #1863.

Please let me know if you have any questions.

andreidubov avatar May 27 '20 13:05 andreidubov

@andreidubov have you also checked android behavior?

s-aleinik avatar May 28 '20 04:05 s-aleinik

@s-aleinik yes, unfortunately, I do not know about Time.ONE_MINUTE, so I tried

CodePush.sync({
  minimumBackgroundDuration: 60 * 5,
  installMode: CodePush.InstallMode.ON_NEXT_SUSPEND
})

and

CodePush.sync({
  minimumBackgroundDuration: 60 * 5,
  installMode: CodePush.InstallMode.ON_NEXT_RESUME
})

These configurations worked correctly and I did not have any problems, I think that you can try to replace Time.ONE_MINUTE because it can lead to the wrong data format.

Please let me know if it was helpful or you have any questions.

andreidubov avatar May 28 '20 10:05 andreidubov

@andreidubov yes, Time.ONE_MINUTE is simply 60. I have tried with 60 * 5 as well, but app was restarting after being 5-10 sec or even 1-2 sec on a background on android with both modes. I will check it again tomorrow.

Thank you for your responses!

s-aleinik avatar May 28 '20 10:05 s-aleinik

Hi @s-aleinik,

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

Thanks, Andrei

andreidubov avatar Jun 03 '20 10:06 andreidubov

@andreidubov Hi! I think I found a possible issue. For me CodePush.sync() works in a correct way only if I provide mandatoryInstallMode to options, even if update is not mandatory. So for not a mandatory update:

    const options = {
      minimumBackgroundDuration: Time.ONE_MINUTE * 0.25,
      installMode: CodePush.InstallMode.ON_NEXT_SUSPEND,
      rollbackRetryOptions: {
        delayInHours: 2.5,
        maxRetryAttempts: 5
      }
    };

    CodePush.sync(options);

restarts immediately, but

    const options = {
      minimumBackgroundDuration: Time.ONE_MINUTE * 0.25,
      installMode: CodePush.InstallMode.ON_NEXT_SUSPEND,
      mandatoryInstallMode: CodePush.InstallMode.ON_NEXT_SUSPEND,
      rollbackRetryOptions: {
        delayInHours: 2.5,
        maxRetryAttempts: 5
      }
    };

    CodePush.sync(options);

works fine and restarts only after being more than 15 sec on a background.

Platform: iOS, react-native-code-push: 6.3.0, react-native: 0.62.2

Will check Android later

s-aleinik avatar Jul 27 '20 16:07 s-aleinik

works for android as well

s-aleinik avatar Jul 27 '20 18:07 s-aleinik