1. Trouble with the game?
    Try the troubleshooter!

    Dismiss Notice
  2. Issues with the game?
    Check the Known Issues list before reporting!

    Dismiss Notice
  3. Before reporting issues or bugs, please check the up-to-date Bug Reporting Thread for the current version.
    0.30 Bug Reporting thread
    Solutions and more information may already be available.

UI Javascript Resource Leak When Reloading Lua

Discussion in 'Troubleshooting: Bugs, Questions and Support' started by angelo234, Oct 20, 2021.

  1. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    539
    I noticed recently when I was working on a mod where I would find over time that the UI would become totally unusable and it was driving me crazy! :mad: So I wanted to know what was going on and from what I can tell reloading Lua (Ctrl + L) seems to generate new Javascript DOMs but doesn't remove the old DOMs. I found this out by opening the CEF console and seeing that the DOM Nodes, RAM Usage, Event Listeners, Documents, etc. kept growing as I reloaded Lua.

    And also because old DOMs aren't removed, they will keep on processing code. For example, I added a console.log function to an "update" function in a UI app to see how quickly the text would get printed and noticed the more I reloaded Lua, the more text would get printed over a time interval.

    Here's a video of me generating the resource leak. And at the end I press F5 which seems to release all the unused resources.


    If you are wondering how to open the CEF console, execute this Lua command in GE Lua console:
    Code:
    toggleCEFDevConsole()
     
    #1 angelo234, Oct 20, 2021
    Last edited: Oct 20, 2021
    • Agree Agree x 2
    • Like Like x 1
  2. _N_S_

    _N_S_
    Expand Collapse

    Joined:
    Oct 28, 2017
    Messages:
    66
    I really hope this will be fixed someday.
    This imposes a restriction on use of intervals.
     
    • Like Like x 2
    • Agree Agree x 1
  3. Camera2004

    Camera2004
    Expand Collapse

    Joined:
    Nov 8, 2018
    Messages:
    697
    Is this why the game would lag after a while of playing?
     
  4. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,053
    No this is only when using Ctrl+L, doesn't happen on normal gameplay
     
  5. _N_S_

    _N_S_
    Expand Collapse

    Joined:
    Oct 28, 2017
    Messages:
    66
    No, not only when using ctrl+L.
    This also happens simply when opening the game menu.

    Code from video

    Code:
        let Random = Math.random().toFixed(1)
    
        scope.RUN_Invisibility = function () {
            let Invisibility = setInterval( () => {
                console.log(Random)
                if (scope.Invisibility) {
                    bngApi.engineLua('be:getPlayerVehicle(0):setMeshAlpha(0, "")');
                } else {
                    bngApi.engineLua('be:getPlayerVehicle(0):setMeshAlpha(1, "")');
                    clearInterval(Invisibility)
                }
            }, 8)
        };
     

    Attached Files:

    • Like Like x 2
  6. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    539
    This was actually a bug report for the 0.23 version for a specific case and wouldn't happen in general gameplay. Although in the latest version apart from the UI having problems, I've found that repeatedly playing a time trial (probably also applies to regular scenarios) causes the game's FPS to drop and also results in less smooth gameplay overtime and it doesn't seem to have to do with the UI at all.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice