fivem icon indicating copy to clipboard operation
fivem copied to clipboard

Rage input hook stops updating keyboard key states after CEF userMedia output stream for audio is created

Open Explooosion-code opened this issue 1 year ago • 1 comments

What happened?

Whenever you create a CEF userMedia output stream in a NUI resource ex:

navigator.mediaDevices
    .getUserMedia({ video: false, audio: {} })
    .then((stream) => {
        const source = this.audioCtx.createMediaStreamSource(stream);
        console.log(source);
    })
    .catch((err) => {
        console.log(err)
    });

It freezes the GlobalInputHandlerLocal::WndProc and so no GlobalInputHandlerLocal::KeyboardMessage is ever fired. code/components/rage-input-five/src/GlobalInput.cpp

This could mean that FiveM thinks that some keys are pressed when they are not or vice versa. Especially because mumble checks for that control usage for either in-game controls or the InputHook controls and your voice will get stuck if the stream is created after you start talking.

I've done some debugging myself and traces show that:

Windows API call received
Key 32 is now UP
Windows API call received
Key 68 is now DOWN
Windows API call received
Key 68 is now DOWN
Windows API call received
Key 68 is now UP
Windows API call received
Key 68 is now DOWN
Windows API call received
Key 68 is now UP
Windows API call received
Key 68 is now DOWN
Windows API call received
Key 68 is now UP
Windows API call received
Key 87 is now UP
Windows API call received
Key 160 is now UP
Windows API call received
Keyboard message for voice: true
Key 222 is now DOWN 

vKey 222 is my bind for push to talk and I create the stream at the first PTT usage. After 222 key is pressed down - userMedia stream is created - its never lifted UP and no further events are passed by windows.

I have not done enough audio programming to have an intuition as to why that may be. Maybe two sources - mumble and NUI trying to get the same data and corrupting something? Maybe something is eternally waiting for some mutex to unlock?

Maybe someone that knows the codebase a little better can find/give me ideas where to find problems and solutions?

Expected result

The rage input hook should keep updating states

Reproduction steps

  1. Create userMedia output for audio when clicking the Push to talk button

Importancy

Slight inconvenience

Area(s)

FiveM

Specific version(s)

3258, 3095 FIVEM

Additional information

No response

Explooosion-code avatar Sep 24 '24 23:09 Explooosion-code

Adding to this, my server uses lb-phone, Onx and NoPixel use their in-house phones. The same issue occurs in all 3 servers.

Report from my users: Image

Apparently this has been going on for a while. How can we get some more visibility into this to confirm the cause?

jnccloud avatar Nov 17 '25 19:11 jnccloud