thorium-cfx/mono_v2_get_started

Crash caused by AddStateBagChangeHandler

Marky-S opened this issue · 2 comments

Hi!

Client-side.

Commands:

[Command("test1")]
private void RegisterStateBagChangeSingleHandler_Ok()
{
    Natives.AddStateBagChangeHandler("abc", null, new Action<string, string, object, int, bool>(StateBagChanged));
}

[Command("test2")]
private void RegisterStateBagChangeHandlers_InstantCrash()
{
    Natives.AddStateBagChangeHandler("abc", null, new Action<string, string, object, int, bool>(StateBagChanged));
    Natives.AddStateBagChangeHandler("abc_2", null, new Action<string, string, object, int, bool>(StateBagChanged2));
}

[Command("test3")]
private async void RegisterStateBagChangeHandlers_CrashAfterHotReload()
{
    Natives.AddStateBagChangeHandler("abc", null, new Action<string, string, object, int, bool>(StateBagChanged));

    await WaitUntilNextFrame();

    Natives.AddStateBagChangeHandler("abc_2", null, new Action<string, string, object, int, bool>(StateBagChanged2));
}

private void StateBagChanged2(string bagName, string key, object value, int reserved, bool replicated)
{
    Debug.WriteLine($"{bagName} {key} {value} {reserved} {replicated}");
}

private void StateBagChanged(string bagName, string key, object value, int reserved, bool replicated)
{
    Debug.WriteLine($"{bagName} {key} {value} {reserved} {replicated}");
}

This was an interesting one and may even solve another issue we couldn't solve 🤞 Fix will come with the next bug-fix update as well!

Repro steps were great, loved it, had no issues replicating them.

Repro steps were great, loved it, had no issues replicating them.

I, as a developer who has much worked with a young, dumby, but muuuuuch loved testers team, understand what information is needed for understanding the context and fast solve 😂