Open
Description
What happened?
NUI callbacks in JS are much slower than in Lua, causing severe frame drops and freezes when handling heavy data. A previous commit (dfa66db) aimed to improve this situation, but the performance difference remains very significant.
Expected result
NUI callbacks in JS should have performance similar to Lua, avoiding freezes and frame drops.
Reproduction steps
Reproduction resource repro-nui-callbacks.zip
- Start the provided resource
- Execute the command luaCallback followed by the number of callbacks to send (e.g., luaCallback 10) with profiler recording
- Execute the command jsCallback followed by the number of callbacks to send (e.g., jsCallback 10) with profiler recording
- Observe the execution time for both Lua and JS callbacks.
- Compare the results.
Importancy
Unknown
Area(s)
FiveM, ScRT: JS
Specific version(s)
Fivem 12295
Additional information
My use case involves using NUI to fetch images and return them as base64-encoded strings to the client to create runtime textures.
In Lua, 10 callbacks took 100ms; in JS, the same took 900ms.