[REL] KO Deferred or: lightspeed UI ahead

Discussion in 'Released Mods' started by cola_colin, March 27, 2014.

  1. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Changes: see edits at the end
    ====

    So the UI in PA in some scenarios lags. At least some of them are caused by tooooo many Knockout updates happening. The way knockout works in some cases creates a substantial amount of unecessary duplicate updates, or updates that are invalidated mere nanoseconds after they came to be.
    There is a Knockout extending library called "Knockout deferred updates" that fixes this by introducing asynchronous processing. That's dangerous, as it may change the way some stuff works out, so this may create hard to reproduce bugs that are not easy to fix.
    However a few quick tests I did showed nothing wrong and ... well see for yourself. In the following video I try to select a ton of engineers and place a turret as quickly as possible.
    First it has ko deferred updates enabled:



    then I disabled it and suddenly I cannot instant press x anymore and place the turret because I am faster than the UI can process the select.

    The mod is on pamm. It shadows the knockout library and just appends ko deferred at the end of it. I don't think this can break in a bad way from patches. Unless maybe Uber adds ko deferred into the base game, in that case it would be loaded twice. No idea what that would do.

    EDIT:
    Forgot to link the github of the lib:
    https://github.com/mbest/knockout-deferred-updates

    So as a reminder: I am not the author of the actual magic. I just added it to PA


    EDIT 2:
    So this seems to work out pretty well, let's call this a [REL] instead.
    Reports so far all go like: "no lag at all anymore, no new bugs". So it seems to be more or less save to use.


    EDIT 3:
    Updates the mod (version 3 now):
    - Fixed some horrible bugs in the lobby by simply only loading the magic in the actual ingame scene. This should also fix all potential issues in any other scene. Only ingame is now affected.
    - Fixed the chat not going downwards ingame via a bit of UI mod code
    - additionally include https://github.com/NobleJS/setImmediate, it is used by ko deferred to speed up processing even more and at least in this demo it has a pretty noticeable effect: http://jphpsf.github.io/setImmediate-shim-demo/
    - This mod now also fixes the unclickable area in the top of the ingame view. That is unrelated to ko deferred, but I am too lazy to do an extra mod for it and I wanted it fixed.
    Last edited: March 30, 2014
  2. lostmekka

    lostmekka Member

    Messages:
    69
    Likes Received:
    96
    You sir, are my hero :D
    reptarking and nateious like this.
  3. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Go test and report back. People with extreme UI lags issues are the best testers for this.
  4. Corang

    Corang Well-Known Member

    Messages:
    772
    Likes Received:
    313
    Gonna try this later, but

    What mod changes icon colors when selected?!?!? I've been looking for soooooo long
  5. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    same here!
  6. Clopse

    Clopse Post Master General

    Messages:
    2,535
    Likes Received:
    2,865
    That's not a mid, in game ui settings since early beta. :D
  7. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    REALLY!? I guess that's no surprise, my settings list is so long with all the mods I have that I could have easily missed it.
  8. lostmekka

    lostmekka Member

    Messages:
    69
    Likes Received:
    96
    Tried the mod and it looks very promising. No lags AT ALL. And no [new] bugs encountered so far.

    With this I can finally work on raising my APM :D

    Edit: woah left pa open and got 600 air fabbers, and its smooth as hell
    cola_colin likes this.
  9. Fr33Lancer

    Fr33Lancer Well-Known Member

    Messages:
    595
    Likes Received:
    288
    Just made a test with more than 1k fabber (mix of T1/T2 air/bot/vehicle) and selection is swift, without that mod I used to hang 5 to 10 seconds when selecting a mix of approximately 20 T1 + 1 T2.
    Awesome job !
  10. Quitch

    Quitch Post Master General

    Messages:
    5,853
    Likes Received:
    6,045
    Cola_Colin for president!
  11. LetsOne

    LetsOne Active Member

    Messages:
    101
    Likes Received:
    39
    Can someone ELI5?
  12. cptconundrum

    cptconundrum Post Master General

    Messages:
    4,186
    Likes Received:
    4,900
    It's magic. :D
    totalannihilation and reptarking like this.
  13. Dementiurge

    Dementiurge Post Master General

    Messages:
    1,094
    Likes Received:
    693
    PA tries to eat 10 cookies at once, and then PA chokes on cookies.
    Mod feeds PA one cookie at a time so that PA doesn't choke on cookies.
  14. Corang

    Corang Well-Known Member

    Messages:
    772
    Likes Received:
    313
    ELI5? What does that mean?
  15. Corang

    Corang Well-Known Member

    Messages:
    772
    Likes Received:
    313
    lol'ed at this explanation but it is perfect
  16. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    Explain Like I'm 5.
  17. Trippett

    Trippett New Member

    Messages:
    7
    Likes Received:
    0
    Hi, at the risk of sounding like a total newb at javascript I seem to be having the same issues. I have tried to add this mod the PA without success can anyone give some quick and dirty instructions on installing this I have added the new knockout 3.1.0.js and knockout-deferred-updates.min.js to ui_mod_list.js. and i have tried to activate it via the ko.computed.deferupdates = true but i don't seem to come up with the same result as you guys, there is no change.

    Thank You

    Ryan Trippett
  18. ORFJackal

    ORFJackal Active Member

    Messages:
    287
    Likes Received:
    248
    Is the use of boot.json required - i.e. does the script have to be loaded before KO is used? If not, the normal way for mods to include scripts would break less easily.

    Another way would be to append kodef.js to the end of knockout-2.2.1.js - because the KO library has version number in its name, shadowing it should cause no problems, because if Uber updates the file they will create a new file under a different name.
    cola_colin and Clopse like this.
  19. LetsOne

    LetsOne Active Member

    Messages:
    101
    Likes Received:
    39
    Oh I get it. Thanks
  20. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    @orfjackal I did put in roughly 3 minutes into thinking how to make this a mod. There may be better ways for sure. ;) I assumed the ko deferred needs to be loaded before any ko code is used because I doubt the library would have a chance to change anything of the behavior on an already created ko.computed. I may be wrong. I guess after this breaks due to a patch I'll look into it more. Appending it to the knockout file sounds like a very good idea.
    EDIT: Actually I have time now, while after patches ... ah gonna add it to the end of the knockout file.

    @Trippet: There is a sticky topic with a mod manager. Download it, open the available mods tab and search ko. Click install. You're done.

    That's actually not correct. It's more like:
    PA tries to eat 10 cookies at once, but having only 2 hands they drop to the floor and it takes a while to gather them all and eat them.
    The mod crunches the 10 cookies in a mixer, adds water and serves PA a cookie shake that's very easy to drink and hopefully just as tasty.
    Last edited: March 28, 2014

Share This Page