Skip to content

NUI Callbacks significantly slower in JS compared to Lua #3066

Open
@william-des

Description

@william-des

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

  1. Start the provided resource
  2. Execute the command luaCallback followed by the number of callbacks to send (e.g., luaCallback 10) with profiler recording
  3. Execute the command jsCallback followed by the number of callbacks to send (e.g., jsCallback 10) with profiler recording
  4. Observe the execution time for both Lua and JS callbacks.
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ScRT: JSIssues/PRs related to the JavaScript scripting runtimebugtriageNeeds a preliminary assessment to determine the urgency and required action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions