hi,
i am implementing hot update where i don’t restart immediately after downloading the files but wait for the player to restart the game. in method “updateCb” of “HotUpdate.js”, the eventCode is :
jsb.EventAssetsManager.UPDATE_FINISHED:
however when we transition between scenes, the files get updated. is this a bug or is this a feature of hot update?
also, when this transition takes place, the scene gets updated, but the new files that were introduced in this patch, that were downloaded in the patch, don’t get reflected in the game, causing a bug. Log :
[WARN]: Can not find class ‘2cadfp1Oc1DDr4G0kvzfiA3’
this is a class that was introduced in this patch but the scene is updated on transition(which is why it looks for the file), but the file is missing in the build.
First, one thing about the builded project, all the code is compiled into a single file.
So, when you hot update stuff, it adds the new files into the search path, for missing files it’s fine, because before you didn’t had it, now you have it, so the search finds it. For modified files, it will get the old ones, specially code, that is already loaded in the memory and will not be modified.
Before you restart, you add the new files in the beginning of the search paths, so when the app restarts and will load your code, it’s the new one that it finds. This problem will also occur if you don’t add the new search paths in the beginning of the array (the .unshift part of the code), or if you don’t load it in the main.js part that you modify on the build folder.
Did it answer, or is another problem that I didn’t catch?
My question was: should the copying of the files happen only on restart, or also on scene changes. I gave an example of a warning that I get on scene transition, which can happen only if the scene was copied from the temp folder to the main build but the new script files were not copied (effectively meaning my scene2.fire was copied but index.js was not copied). Now, I want to understand why this is happening and how to fix it.
Note that I don’t restart my game immediately after downloading the files, but wait for the player to restart the Android app(game).
I would like one of the engine developers to comment on this. (No offense @Randomzord. In fact you have always been helpful).
Thanks!
hi,
i would like to also know how to specify a new search path in project.manifest. also, i am not specifying a search path there and it is empty…so can this be an issue? i am including my version of hotupdate.js and the main.js after the restart. for_CocosTeam.zip (9.3 KB)
thanks!
Thank you @Randomzord , @huanxinyin ,
I have another question… I don’t specify a search path, so the default search path is used. Now let’s say I am on version 1 of my game and am downloading files of version 2 through hot update but all the files of version 2 don’t get downloaded(due to slow internet connection or maybe because the player kills the app). Then let’s say we turn off hot update from the server. Then, after the player restarts the game, will the downloaded files of version 2 get copied to the storage path of the app, or will the player still have a complete version 1 of the game to play.
It is important to note three points:
Hot update didn’t finish.
We didn’t specify a search path, so the first string in localstorage in “hotupdatesearchpaths” is the hot update folder in the app’s writable path. So whatever files of version 2 that were downloaded, will be there(I am assuming).
After restart there is no hot update. By that time it has been turned off from the server.
Now, after the player restarts the game, will he be playing version 1 of the game or will he have an incomplete version 2 of the game?
Keep in mind that the player will always have the version 1, or better saying, the base app. In Android, you can clear the downloaded content, that includes hot update assets, but the base app assets are never deleted;
So, answering your question, the player will only have the base app (version 1).
Assuming that you didn’t change the flux on the hot update tutorial, you will only set the new assets after all of them are downloaded correctly. In case of an interrupted update, the new files will be keep in storage, but will not be used.
Hi @Randomzord ,. @huanxinyin ,
I am talking about the scenario where the player doesn’t clear the app data.
In localstorage, the hotupdatesearchpaths already contains the hot update folder path in the app’s writable path (I had printed it out before adding the new search path and can confirm it), and in main.js there is no check on whether hot update completed successfully, before the files are copied to the storage path. So this much should be clear that the incomplete download will be copied to the storage path.
Now, the question is : whether the files will be reflected in the game. So, does another transfer take place after a successful hot update to a place inside the build folder? If so, why are scenes/textures/assets copied before the restart? Also, are scenes/textures/assets copied only after a successful hot update but before the restart?
Thank you!
Hi @huanxinyin ,
I read the documentation. However, what I want to know is this:
Let’s say the download is incomplete.
(I have printed out the search path before restart and know that the localstorage search path already contains the local cache folder, maybe from the previous hot update).
Now, let’s say we turn off hot update after the incomplete download. So there is no download retry. I want to know what is stopping main.js from copying the downloaded files (whose list is incomplete) to the local cache and making the local cache the first priority search path? I think the files will become a part of the package and cause an error. That is, unless the function in main.js that does the copying, and makes the local cache the first priority search path, doesn’t get called in the first place.
See where the UPDATE_FAILED and UPDATE_FINISHED flags are raised.
The files when are being downloaded will go into a temp folder, until all the files are downloaded.
Only after all the files are downloaded, it will run a sanity check to see if there is any error in those files. If not, only then the new files overwrite the old ones.
So, if your download is interrupted before all the files are downloaded, the overwrite step will never occur, so your previous version is intact.