Client - Invalid ref call attempt

When i’m using client callbacks called from another client script sometimes i end up with this:


but sometimes it works perfectly fine without Invalid ref call attempt.

So here is how my create menu function look like:

bytium.menu.open = function (type, title, buttons)
    bytium.ui.close()
    bytium.menu.list[type] = buttons
    print()
    local _buttons = deepcopy(buttons)
    for k, v in pairs(_buttons) do
        _buttons[k].func = nil
    end
    bytium.ui.build(false, false, type)
    bytium.ui.send({
        name = type..":start",
        title = title,
        buttons = _buttons
    })
    bytium.menu.opened = true
end

Here is how i’m openning it

        bytium.menu.open('list', 'CARS', {
            {label = "Dodge", func = function() 
                SpawnCar('lspd18charger')
                bytium.ui.close()
            end}
        })

And here it’s function which is called right after the player will click the menu button

bytium.menu.run = function (type, button)
    print('Callbacking button '..json.encode(bytium.menu.list[type][(button + 1)]))
    bytium.menu.list[type][(button + 1)].func() -- This sometimes leave the player with Invalid ref call attempt
end
1 Like

No repro steps, looks more like a support topic. :confused:

Has the resource mentioned been restarted at all?

Yes, both bytium and bytium_police is started. Player have like 50/50 chance to get Invalid ref call attempt when clicking the menu button.


We’ve ended up working with events instead of callbacks but it’s a little problematic because we can’t keep everything in one function. Tested on both stable and canary release client.

restarted.

Without a repro this isn’t really a bug report though.

I found a repro for this specific bug, it seems like resources aren’t being unloaded properly after disconnecting from a server.

I have no idea if this is related to this issue but this does cause the above error and some other issues, like streaming continuing to download after disconnecting which causes them to be blocked by the filter.

I noticed players sometimes triggering events like esx:playerLoaded twice (this was being called once after IsNetworkSessionStarted() was true followed by a break so this should not be possible at all)

So a repro would be:

  1. Set up any reference calls in LUA (getting an ESX object would be an easy way to get a lot of refs)
    disconnect.
  2. connect to same server again.

I think what happens here is that it keeps the resource and as such triggers the RefCall in the wrong instance of the resource.

No, they definitely are.

Not a result of ‘resources not being unloaded properly’, but rather the game not being meant to see streaming assets suddenly pulled from existence.

This was an issue with resource dependencies and should’ve been fixed a week or so ago already.

Can you provide any code and steps that will certainly cause this? Tick execution of ‘old’ resources is highly unlikely as is event execution so both don’t really make sense in this context.

Ah alright, might’ve been going down the wrong thought path there then.

I’ll investigate this a bit further and see if I can get any simple code snippets to work to replicate this issue.

It also appears to only happen on b2189 and not on the default build.

Also is the “Invalid ref call attempt” and then simply returning an empty table the best solution if this happens? Cause some plugins expect a boolean from a Ref function and if this fails it would pass this boolean check since it gets an empty table.

“this” should simply not happen in the first place.

Managed to get any such?