MP.TextLabels.New causes segfault
Stricted opened this issue · comments
when using MP.TextLabels.New
the server crashes with a segfault afterwards
[Command("test")]
public async Task test(IPlayer player)
{
MP.TextLabels.New(player.GetPosition(), "test", 0, Color.White);
}
using MP.TextLabels.NewAsync
words fine
nevertheless it shouldnt crash when using the non async method
#
# Fatal error in HandleScope::HandleScope
# Entering the V8 API without proper locking in place
#
Segmentation fault
Which branch are you using? Its quite interesting because the async method uses the sync method.
im using the latest release (V1.2.0) on windows
Try wrapping the sync New
call inside a MP.Schedule
call. Rage requires mostly everything to happen in the main thread. The async method wrapps the synced method inside a MP.Schedule
call.
wrapping MP.Utility.Schedule
around it works fine
await MP.Utility.Schedule(() => MP.TextLabels.New(player.GetPosition(), "test", 0, Color.White));
This seems to be affecting the entire sync API, not just textlabels.
To give you a general rule regarding async/sync calls:
Async API: Directly and always safely usable. Those calls are already with MP.Utility.Schedule
wrapped sync API calls.
Sync API: Must be used within MP.Utility.Schedule
. We offer those sync methods to reduce overhead on your side and to group batches of calls together.