Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Changes disappear after app restart #451

Closed
krzyhub opened this issue Sep 24, 2018 · 20 comments
Closed

Changes disappear after app restart #451

krzyhub opened this issue Sep 24, 2018 · 20 comments
Assignees

Comments

@krzyhub
Copy link

krzyhub commented Sep 24, 2018

Hello,

After new version of app is pushed I can see that app was updated on my device after I launched it (installMode: InstallMode.IMMEDIATE). In the console I can see that everything related to installation process is fine:

CODE PUSH SUCCESSFUL: 5
[CodePush] Checking for update.
[CodePush] Awaiting user action.
CODE PUSH SUCCESSFUL: 6

Then I confirm to continue installation.

CODE PUSH SUCCESSFUL: 7
[CodePush] Downloading update
[CodePush] Package download success
CODE PUSH SUCCESSFUL: 8
[CodePush] Installing update
[CodePush] Applying diff update
[CodePush] Verifying hash for folder path: /codepush/deploy/versions/d183f3ed36bd4c877009c18ae9a51d2e19cb0f0a9a8902606c14a419bb314f16/
[CodePush] The update contents succeeded the data integrity check.

But after closing and starting app again it shows me old content, but saying that App is up to date. In console I can see that this.codePush.getCurrentPackage() really shows the last and proper update description.

My update code is very simple:

    platform.ready().then(() => {
        ...
      this.checkCodePush();
    });
checkCodePush() {
      this.codePush.sync({
       updateDialog: {
        appendReleaseDescription: true,
        descriptionPrefix: "\n\nChange log:\n"

       },
       installMode: InstallMode.IMMEDIATE
    }).subscribe(
      (data) => {
       console.log('CODE PUSH SUCCESSFUL: ' + data);
      },
      (err) => {
       console.log('CODE PUSH ERROR: ' + err);
      }
    );
 }

For more, I can say that when I plug in my phone to Chrome Dev Tools and update app for the first time, then it is okay till I refresh the page. After refresh there is an information that page couldn't be loaded because of missing file:///data/user/0/io.ionic.starter/files/codepush/deploy/versions/d183f3ed36bd4c877009c18ae9a51d2e19cb0f0a9a8902606c14a419bb314f16/www/index.html

Also, there isn't any informations about rollback.

I will appreciate any help.

@alexandergoncharov-zz
Copy link
Contributor

Hi @krzyhub ,
Thanks for reporting!

Could you please clarify is it Android or Ios issue? or both?
And could you please provide dummy project?

Thanks,
Alexander

@khlewesamer
Copy link

I have the same issue
Platform android , I didn't try in ios yet

@krzyhub
Copy link
Author

krzyhub commented Sep 27, 2018

Hi @alexandergoncharov ,
For sure it is Android issue (tested on two different devices).
Here is a dummy project example: https://github.com/krzyhub/cpionic

@davec21
Copy link

davec21 commented Sep 28, 2018

I am having same issue with latest codepush.

iOS appears to work. That said, there is an issue with iOS and the latest ionic webkit webview. The issue is with the way the webview plugin handles content loading. There is a line in the .m file that needs to be tweaked.

Not sure if that's what is going on with android too, but with iOS it would just 404. Android will load it, but it doesn't seem to retain it after close.

@davec21
Copy link

davec21 commented Sep 28, 2018

Just a quick follow up, I tried looking into it. I can't figure out what's going on.. It's almost like the call to load the deployment url is being ignored. Paths are the same, everything is fine.. it just seems to want to load the index from the android_assets folder regardless.

@khlewesamer
Copy link

after tow day in searching i found the problem in webview plugin after i delete it it is work fine , what i noticed is the path was localhost in device put when i delete the plugin the path of app change to fill// in android , and try it in ios and work fine also . i hope that help any one

@davec21
Copy link

davec21 commented Sep 28, 2018

Did some even more digging. Looks like it's a race-condition with the ionic webview implementation.

Basically what happens is that it tries to load the local file:///android_assets index.html. The ionic webview captures that, stops the load, then tells it to load the https://localhost:8080 version of it. So while it's stopping the loading and trying to navigate to the new url, it is preventing the code-pushed page from loading.

@krzyhub
Copy link
Author

krzyhub commented Sep 29, 2018

I can confirm that without webview plugin update works, so, as davec21 said it would be a conflict between webview plugin and code-push plugin.

@alexandergoncharov-zz
Copy link
Contributor

Hi all,
Thanks all for investigating!

Yeah, issue in new version of cordova-plugin-ionic-webview.
Last working version of cordova-plugin-ionic-webview is 1.2.1
So, for workaround you can downgrade version of this plugin:

ionic cordova platform rm android
ionic cordova plugin rm cordova-plugin-ionic-webview
ionic cordova plugin add [email protected]
ionic cordova platform add android

@krzyhub
Copy link
Author

krzyhub commented Oct 1, 2018

Works for me 👍

@atftech-artyom
Copy link
Contributor

atftech-artyom commented Oct 9, 2018

This pull request solves issue with Android and iOS: #454

@vickydadhich
Copy link

It worked for me too.. thanks a lot @alexandergoncharov you saved my day

@lperezb
Copy link

lperezb commented Oct 19, 2018

@alexandergoncharov awesome! This works... wasted almost two days to this.... hope it gets fix

@alexandergoncharov-zz
Copy link
Contributor

Hi all, @krzyhub, @khlewesamer, @davec21, @vickydadhich, @perezb,
Could please some one helps to test this PR: #454 and please let me know if you found any issues.

Thanks,
Alexander

@alexandergoncharov-zz
Copy link
Contributor

Hi all,

Changes already in master and in new Cordova release. So, I'm going to close this issue for now but please feel free to reopen it if you have any issues.

Thanks,
Alexander

@349989153
Copy link

349989153 commented Jan 2, 2019

Ran in to the same issue. I didn't use cordova-plugin-ionic-webview but cordova-plugin-crosswalk-webview.

And it happened only on Android devices, not iOS.

All the related package versions are:

  • cordova-android: 6.4.0
  • cordova-plugin-crosswalk-webview: 2.4.0
  • cordova-plugin-code-push: 1.11.11

Any advice, please?


Alright, I think I have the same issue as davec21 found: cordova run the different index.html in the different path.

when the app was first installed: 01-02 19:30:19.719 15422-15422/? D/CordovaWebViewImpl: >>> loadUrl(file:///android_asset/www/index.html)

And then the update was installed and restarted: 01-02 19:31:55.424 15422-15422/? D/CordovaWebViewImpl: >>> loadUrl(file:/data/user/0/com.test.testApp/files/codepush/deploy/versions/62b60c3f481e89c83d5fd6d7f215133aa16bf800cde246f0453f073224e55e52/www/index.html)

Finally the app was resumed after we did see the changes: 01-02 19:32:18.029 15422-15422/? D/CordovaWebViewImpl: >>> loadUrl(file:///android_asset/www/index.html)


@alexandergoncharov Any downgrade advice about cordova-plugin-crosswalk-webview ? Please.

@349989153
Copy link

I update cordova-plugin-code-push to 1.11.16 but no working.

@349989153
Copy link

I rm the cordova-plugin-crosswalk-webview and add platform android again, but the issue is still there.Start to question if I miss any key steps of using codePush

@349989153
Copy link

349989153 commented Jan 3, 2019

OMG, I forget to call codePush.notifyApplicationReady() in the deviceready like document.addEventListener('deviceready', () => { window.codePush.notifyApplicationReady() }, false);

So stupid....

No issue anymore.

@metinjakupi
Copy link

Bump!

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

No branches or pull requests

9 participants