Skip to content

When using Realtime, race conditions between browser and function loading can occur #3538

Closed

Description

@hiddenicon

When doing real-time in a new window, the graph does not render. Looks to be jquery based as there is a error in the console regarding "ImageOptionsChanged is not defined".

image

image

Chrome version 81
Edge version 81
Firefox - works in any version

I've tried clearing the cacti realtime cache directory.
I've tried clearing browser cache (all options, cleared for all time)
Realtime inline in the browser works fine, only affected from New Window realtime window.

Activity

  1. TheWitness commented on May 24, 2020

    @TheWitness
    Member

    You must have a problem with file permissions. Check the realtime.js is readable by the browser. You did not indicate your Cacti version as well. Suggest you update to 1.2.12 if that is not the version you are running.

  2. hiddenicon commented on May 26, 2020

    @hiddenicon
    Author

    Sorry, I did leave out the versioning. This started to happen after upgrading to 1.2.12. We were on 1.2.10 prior and it was working fine.

    It is only Chrome based browsers and it is happening across various OS platforms, users, and PCs. We use Cacti heavily for work and my entire team is having this issue. It is only on pop-out, not inline. It's happening on Win10, MacOS, and Ubuntu linux when using Chrome based browsers. Firefox works on all of the above. If it's a permissions thing, then it is happening at a common level like Chrome based browsers.

    Not sure what to check and how to check.

  3. netniV commented on May 26, 2020

    @netniV
    Member

    OK, so you are using realtime in popup mode and that experiences the above error in the console? I'll give it a try on my basic setup and see if I get the same.

  4. hiddenicon commented on May 26, 2020

    @hiddenicon
    Author

    Correct. Only appearing in Chrome based and only with popup mode. We get the spinner because nothing loads.

    Here's a screenshot showing both errors; same issue though.

    image

  5. netniV commented on May 27, 2020

    @netniV
    Member

    So here is the breakdown which concurs with what @TheWitness said earlier, something is blocking access to the realtime.js script. Whether that is file permissions or browser security, you'd have to investigate but basically realtime.js is included by html_common_header() which is in lib/html.php. That is called pretty much all the time... Can you check your page source to see if you can see a script tag for it?

  6. netniV commented on May 27, 2020

    @netniV
    Member

    Btw, just for reference, html_common_header() is included at line 337 in graph_realtime.php, so you should have it there as a source.

  7. hiddenicon commented on May 27, 2020

    @hiddenicon
    Author

    I think it has to be something else. Here are 3 things I've just tried.

    1. From a few PCs having the issue, they are working fine to our "lab" VM running cacti 1.2.8 using the same browsers.
    2. realtime.js is in the source as a script tag, and I see it loading in the network waterfall.

    image

    image

    1. I've put in a JS alert into realtime.js at the top, and I'm getting alerted on every page I go to (as you said it's included in everything) including the popup realtime window.

    image

    image

    I've scoured through our anti-virus and other security tools and disabled them and don't see anything in their logs. I see the same results on an Ubuntu 19.04 box, fresh OS install, running Chrome doesn't work; Firefox does.

    Some other weirdness I see is once the realtime popup window comes up, it doesn't load as we know. If I change any of the drop-downs or check the thumbnails checkbox it refreshes the window, I see the graph now with data but it's not not auto refreshing. If I check the thumbnails checkbox or change a drop down again, the graphs refreshes once again with new/good data, but doesn't auto refresh. It just sits there.

    image

    image

    So, I threw in an alert in the imageOptionsChanged() function to see when it was being fired.

    image

    The only time I get an alert is when I'm manually checking the dropdowns/thumbnails checkbox at the top. I don't see it firing when I first load the popup window.

    I'm not going against what you guys are saying, I'm just stumped and want to see what is needed to fix it even if it's something on my side.

  8. netniV commented on May 27, 2020

    @netniV
    Member

    Automatic refresh works off setTimeout so that should work unless chrome seems that the source is a long running script. Do you see any other errors or warning s?

  9. hiddenicon commented on May 27, 2020

    @hiddenicon
    Author

    The only errors I see are the jQuery errors in the console. Looks to be line 205 in the source, which is this section:

    image

    So if that is failing there and not completing, then the setTimeout function isn't running. Which explains why it's not auto refreshing.

  10. hiddenicon commented on May 27, 2020

    @hiddenicon
    Author

    Another quick update. I've commented out the imageOptionsChanged function in the jQuery onload function and now realtime is working in the popup for Chrome.

    image

    I don't get the graph initially, it does load after the first timer (5 seconds in this case). I'm assuming that's because the imageOptionsChanged('init') function didn't run.

  11. netniV commented on May 28, 2020

    @netniV
    Member

    Thanks I’ll take a look and see whether I can See why

  12. reopened this on May 28, 2020
  13. added
    confirmedBug is confirm by dev team
    and removed
    unverifiedSome days we don't have a clue
    on May 28, 2020
  14. netniV commented on May 28, 2020

    @netniV
    Member

    One of our other users has actually found a fix for this when they raised their own issue in #3580. Can you see if that fix works for you? If so, I will apply it to the code unless @ahouston wants to submit a PR with a CHANGELOG entry for it against this issue tracker.

  15. changed the title [-]Chromium based browser - realtime broken[/-] [+]Race condition exists between initialization of realtime and browser loading realtime javascript functions[/+] on May 29, 2020
  16. ahouston commented on May 29, 2020

    @ahouston
    Contributor

    One of our other users has actually found a fix for this when they raised their own issue in #3580. Can you see if that fix works for you? If so, I will apply it to the code unless @ahouston wants to submit a PR with a CHANGELOG entry for it against this issue tracker.

    Submitted Pull Request: #3587

  17. hiddenicon commented on May 29, 2020

    @hiddenicon
    Author

    Testing the code change for the window onload from #3587 is working for me now. Tested on a few of our 'troubled' PCs and all are good now.

    I had the thought that the jQuery onload was loading before realtime.js was fully loaded. Wasn't sure exactly how to test that.

  18. changed the title [-]Race condition exists between initialization of realtime and browser loading realtime javascript functions[/-] [+]When using Realtime, race conditions between browser and function loading can occur[/+] on Jul 12, 2020
  19. locked and limited conversation to collaborators on Oct 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUndesired behaviourconfirmedBug is confirm by dev team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions