Slow DUI init

For a good bug report you should probably include:

  1. Client (production/canary) and FXServer version: Canary b2372, FXServer 4359
  2. What you expected to happen
    SendDuiMessage to work earlier
  3. What actually happens
    SendDuiMessage only work after 5sec or more after IsDuiAvailable
  4. Category of bug (eg. client, server, weapons, peds, native)
    client
  5. Reproducible steps, preferably with example script(s)

Hello,

DUI became really slow before accepting messages.
Before, loading a page using CreateDui was way faster, now it can takes up to more than 5 seconds for the page to be ready (to be visible or accepting SendDuiMessage).

Not really a bug but there was definitely a regression there.

Here is a repro resource:

duiRepro.7z (873 Bytes)

Lua part:

local StartTime
local DuiObject

RegisterNUICallback('ready', function(data, cb)
	print("HTML Ready took "..(GetGameTimer() - StartTime).."ms")
    SendDuiMessage(DuiObject, json.encode({ message = "ready" }))
end)

Citizen.CreateThread(function()
    StartTime = GetGameTimer()
    DuiObject = CreateDui("https://bubblitobucket.s3.eu-central-1.amazonaws.com/dui.html", 1280, 720)
    while not IsDuiAvailable(DuiObject) do Citizen.Wait(0) end
    print("IsDuiAvailable took "..(GetGameTimer() - StartTime).."ms")
    SendDuiMessage(DuiObject, json.encode({ message = "IsDuiAvailable" }))
end)

Web part:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" crossorigin="anonymous"></script>
<script>
    $(window).on('message', function($event) {
        console.log(event.data.message);
    });
    
    $(document).ready(function() {
        $.post("https://duiRepro/ready", JSON.stringify({}));
    });
</script>
</body>
</html>

As you can see first SendDuiMessage is not processed and it takes 5 seconds before being ready to accept messages

1 Like

Before when? :stuck_out_tongue: Helpful to have a range of process startup slowness to look at.

1 Like

maybe 2 months, not really sure but quite some time already :zipper_mouth_face:

1 Like

… actually, I can’t replicate this:

image

and retrying it is even faster:

image

Can you do this on 1604 and make a .etl trace of starting this resource instead? :confused:

1 Like

Ok so I made 2 traces (without and with fast sampling since I was not sure what is needed)

Without fast sampling:

With fast sampling:

For me it takes about 4.5sec

For some users it is more than 10sec:

… how big did your citizen/hints.dat get?

(see this bug fix: fix(shared/patterns): don't save hints when out of exe · citizenfx/fivem@bdbfb32 · GitHub)

1 Like

1402KB
image

Is this normal? I don’t know what that is

1 Like

nope, this file should max out at ~100 kB or so

1 Like

Yes I deleted it and now it way faster

For me:

The user who had 10s delay had 2000KB hints.dat size and fixed it too by removing the file

So was this fixed by the linked commit and won’t happen again once this file is deleted and back to normal? Could there be a way to fix clients with a hints.dat in a bad shape?

1 Like

Fivem starts so fast now :sweat_smile:

Yeah.

See fix(core): mitigations for systems affected by bdbfb32b6eab7c5707882770bab123194c31384c by blattersturm · Pull Request #885 · citizenfx/fivem · GitHub.

1 Like

Perfect, I put my big file back and it did regenerate it and everything works as expected.
Thank you very much