tnentwig/WebVisu

visu doesn't get updated after changes

Opened this issue · 20 comments

It is frustrating. With every change of the programme the variables get more and more mixed up in the javascript visu. If I look in the visu of codesys everything shows up right.
The old variables, which I didn't touch are still displayed correctly, but variables, that I recently changed get mixed up. Even dump lables, which I added just for testing, are not shown.
It seams like webvisu.js uses still the old visu. But the plc_visu.xml is defenitely updated in the controller. I also tried to clear the cache of firefox (ctrl+F5). Without success.
I opened the visu in chrome for the first time, and there everything was displayed correct. But the next changes are lost again (I deletet the dump label, which I added just earlier for testing, and it is still there)

Got the solution, but it is not satisfying. If I delete all data for the website of the visualisation in preferences-> Privacy & Security -> Manage Data, the visu works again in the newest version.
There should be an easy and more intuitive way to achieve this (like F5 or ctrl+F5). If it is not possible, there should at least be a hint in the readme file. It took me hours to solve this issue.

is it ok to for a full reload only when closing and opening the tab again ?
or do you prefers to reload everything on a normal reload ?

Could you test with this version:
https://github.com/Ekristoffe/WebVisu/tree/Dev/dist
It should reload from scratch the whole visu on a browser reopen or tab reopen.

Closing the tab and opening a new one works. Even just opening a new one without closing the old one works.
Answering your question above. I would prefer CTRL+F5 to reload the visu, I think it is most intuitive, as normally CTRL+F5 reloads and clears the cache. Most computer affine people know that, and do it if something wired happens during a normal reload. But I don't know javascript and have no idea, whether it is possible to achieve with moderate effort.
Reopening the tab is ok for me, but you should make a notice about it in the readme file.

The loaded visu files are stored in the local storage intentionally. This was implemented to reduce the load time for big sized visualisations, like Wago own facility solutions. They are quit heavy, so the storaging should be kept in my opinion. It improves the user experience.
Actually the process should be:
Has the XML changed?
No -> Load from storage
Yes -> Reload
I thought the <download-id></download-id> tag in the visu_ini.xml changes with an application change. But this is apparently not the case. Maybe the <time-stamp></time-stamp> tag in the xml file would be accurate?

I see the advantage of storing the visu locally. But there should definitely be an easy, intuitive way to reload the visu like CTRL+F5, as long, as the automatic reload doesn't work reliable. If it works, it would be of course the best solution.
In my visu there is no <download-id> tag at all. Maybe this is the problem. The <time-stamp> tag may be more suitable. In my visu the actual tag is <time-stamp>1610038976,1586465552</time-stamp> which doesn't seam to be a typical unix like time-stamp, but if it changes with each new version, that doesn't matter. In a first test, the part left from the comma changed after a new upload of the visu, in the right part there was no change <time-stamp>1610053743,1586465552</time-stamp>

Okay, thanks for your help. We have to include the functionality of a CTRL+F5 hard reload.

I see the advantage of storing the visu locally. But there should definitely be an easy, intuitive way to reload the visu like CTRL+F5, as long, as the automatic reload doesn't work reliable. If it works, it would be of course the best solution.
In my visu there is no <download-id> tag at all. Maybe this is the problem. The <time-stamp> tag may be more suitable. In my visu the actual tag is <time-stamp>1610038976,1586465552</time-stamp> which doesn't seam to be a typical unix like time-stamp, but if it changes with each new version, that doesn't matter. In a first test, the part left from the comma changed after a new upload of the visu, in the right part there was no change <time-stamp>1610053743,1586465552</time-stamp>

The <download-id> tag is in the visu_ini.xml file.
The <time-stamp> tag is in each visu pages and can only be accessed by reloading the page again.
I will see what can be done.

Edit: I may have found a way to keep the local storage and having the update file without reloading everything.
I need more time to test it.

I made a new system which check the file "last modified" parameter to determined if we need to download it again or not.
Could you check it and tell me if it work fine with your application ?
Thanks you.

The visu_ini.xml file isn't updated every time, I change the visu. Till now, I wasn't able to find out, what kind of changes in the program or visu result in a change of the visu_ini.xml (and so maybe a change of the <download-id>). Where is the last modified parameter? I can't find it in visu_ini.xml and in plc_visu.xml.

Indeed there is no information.
That’s why now I am using the last modified parameter (you can find it for example in windows when you right click a file ans select property)
On a internet file it is in the header of the file when you download it.
I just request the header without the file every time I need to load a file.

I have tested it. The problem should be solved. Every change will be trigger a reload of the visu.

Yes after a page refresh just the changed page is redownload and updated.

great, sounds good. I'm out of office for one week now and can't test this (and the other issues) till I'm back end of next week.
Nevertheless, thanks for your work, it is really amazing, how fast the two of you are responding to my questions and solving my issues.

yes, works for me too. Just a F5 in the browser and the page gets reloaded. Maybe Ctrl+F5 would be better, so that the long loading time for complex visus can be avoided for a normal reload (like mentioned earlier from tnentwig), but I have no idea, whether it is possible with javascript.

unfortunately it doesn't also the page reloading is automatic even on page change (no need to reload normally).
I have selected this just in case there is a pointer change in the webvisu,
If we don't reload and the pointer has change the webvisu could write on another variable which is unwanted.

I made a reworking with sessionstorage who is cleared on page reload. This will be the best option in my opinion, a revisit of a site inside a session is faster then.
Your idea with last-modified is not working on currently available controller like 750-884. They return always the actual timestamp.
@Ekristoffe Do you made the same experience with the 880?

For me it is a good solution now. It works like a normal user would expect it. Thanks for your solution.

Does not update the visu on a 750-841 controler. I changed the plx_visu.xml file manually (changed the text tag of a rectangle), made a reload, and it doesn't show the new text. Even after closing an reopening the tab it doesn't show the change.
Reason for this change was an error in the format string. I forgot to double the %. So it was not shown in the javascript visu (which I think is a correct behaviour), but it is shown in the java version (which is incorrect in my opinion, and the reason, why I didn't realize this error earlier).

Hopefully should be fixed now in the latest release. We will use only the sessionStorage now. A F5 will clear all prefetched visus.