Random NUI Crash when restarting resource

For a good bug report you should probably include:

  1. Client (production/canary): Canary
  2. Category of bug (eg. client, server, weapons, peds, native): client/ui
  3. Reproducible steps, preferably with example script(s):
    Haven’t found a very reliable reproduction, it will sometimes just happen when restarting a resource that has a NUI

EDIT: Just realized that I didn’t attach the dump
CfxCrashDump_2023_02_06_04_55_57.zip (2.4 MB)

Looking at the dump some it doesn’t seem to be random, if a client-ui is sending a post request when the client-resource restarts it will cause this crash, although it isn’t consistent, sometimes it will crash and others it wont, maybe it depends on how long the resource takes to re-init?

Here’s a minimal repo
test-case.zip (1.3 KB)

The file that fails here has a fun comment:

I guess it’s finally time to do that (and maybe some other reworks around here) as that’ll probably fix the underlying issue as the component is shared per ResourceManager and doesn’t have a weird scoped lifetime.

1 Like

Ought to be fixed by tweak(nui/resources): NUI callback rework (5-in-1) · citizenfx/fivem@dfa66db · GitHub - at least the repro doesn’t fail anymore.

As a bonus, you can now implement test.js as follows:

RegisterNuiCallback("TEST", (data, cb) => {
	cb("ok");
});


setTick(() => {
    SendNUIMessage({
        some: "data",
    })
})
1 Like

Thanks for the new native, it improves ergonomics a lot :smile: