Default chat delay when typing

I’ve noticed that there’s a delay when I open the chat and start typing immediately, so the first letter I type is not captured. For example, if I press “t” to open chat and then immediately type “/command”, the “/” character is not captured. However, if I open chat and wait for about 0.5s before typing, it is captured.

What could be causing this issue with the chat, and where can I find the source of the problem?

Try enabling the ‘in-process NUI’ option in the main menu settings. There is a Windows bug involving GPU priority that to our knowledge is only getting fixed for Windows 12.

Unfortunately, that didn’t help.
I’ve seen on different server that this gta online style chat doesn’t have the delay

Seems like GPU overload causing UI lag.

Unfortunately, I don’t know any solution then. This isn’t a common issue and any investigation would need access to a machine on which it occurs, or a consistent set of reproduction steps.

‘this gta online style chat’ is some custom implementation not using NUI so that doesn’t discount that UI-related concern at all.

Do other in-game UI things using NUI also behave slowly on your system?

Problem solved.

The issue was caused by:

  1. enabling chat input after the chat input key is realased, to fix this I moved SetNuiFocus(true) into the function called once the chat input key is pressed (not released)

cl_chat.lua

    if not chatInputActive then
      if IsControlPressed(0, isRDR and `INPUT_MP_TEXT_CHAT_ALL` or 245) --[[ INPUT_MP_TEXT_CHAT_ALL ]] then
      SetNuiFocus(true)
        chatInputActive = true
        chatInputActivating = true

        SendNUIMessage({
          type = 'ON_OPEN'
        })
      end
    end

    if chatInputActivating then
      if not IsControlPressed(0, isRDR and `INPUT_MP_TEXT_CHAT_ALL` or 245) then

        chatInputActivating = false
      end
    end

Secondly, I made the refresh interval more frequent by reducing the number of delay in App.ts in ON_OPEN method by changing 100ms to 35 ms.

chat/html/App.ts

    ON_OPEN() {
      this.showInput = true;
      this.showWindow = true;
      if (this.showWindowTimer) {
        clearTimeout(this.showWindowTimer);
      }
      this.focusTimer = window.setInterval(() => {
        if (this.$refs.input) {
          (this.$refs.input as HTMLInputElement).focus();
        } else {
          clearInterval(this.focusTimer);
        }
      }, 35);
    },

Ah, you actually didn’t mean the usual persistent visual delay but just responsiveness expectations (perhaps more noticeable due to a high-polling-rate gaming keyboard), this was a bit hard to tell from what you posted. :stuck_out_tongue:

Will take this into account when next doing a maintenance pass on the bundled chat resource, the use of setInterval itself already seems questionable as well as this should just be an immediate callout from somewhere once the element is created.

I also recall focus being set on release instead of press because of some bug where keys would remain ‘stuck’ if setting focus with any keys held, but it might be that got fixed since.