Jump to content

Main thread stalling: Write queue at capacity, waiting for write thread...

Fixed 1.6.1 1.6.2

hid333
hid333

Posted (edited)

I would like to report a possible issue with **AdvanceVehicle v1.6.1**.

My server occasionally produces a very large number of:

Main thread stalling: Write queue at capacity, waiting for write thread...

When checking the logs, these stalls very frequently occur immediately after this AdvanceVehicle exception:

InvalidCastException: Specified cast is not valid.

at Oxide.Plugins.AdvanceVehicle+VehicleUI.Awake()
at Oxide.Plugins.AdvanceVehicle.AddComponent(BaseEntity)
at Oxide.Plugins.AdvanceVehicle.SetupVehicles(BaseMountable, BasePlayer)
at Oxide.Plugins.AdvanceVehicle.OnEntityMounted(BaseMountable, BasePlayer)
...
at RustHelicopterController.AttemptMount(...)
at VehicleMount.AttemptMount(...)

In the latest log, most Write Queue bursts were associated with this same exception.
After checking the source, this line in `VehicleUI.Awake()` looks particularly suspicious:

fuelsys = (EntityFuelSystem)_vehicle.GetFuelSystem();

This is a direct cast. If `GetFuelSystem()` returns a different fuel-system type, it would produce exactly this `InvalidCastException`.
The same direct cast also exists in:

getfuelcolor()
VehicleUI.UpdateUI()

Since AdvanceVehicle supports many vehicle types, including helicopters, boats, submarines, cars, snowmobiles, bikes, trains, etc., could you please check whether every supported vehicle is guaranteed to return an `EntityFuelSystem`?

It may be safer to use type checking such as:

var fuelSystem = _vehicle.GetFuelSystem();
var entityFuelSystem = fuelSystem as EntityFuelSystem;

if (entityFuelSystem == null)
    return;

There is also another small issue in `VehicleUI.Awake()`:

if (_vehicle == null)
{
    ...
    DoDestroy();
}

There is no `return` after `DoDestroy()`, so execution may continue while `_vehicle` is null.
I cannot confirm that AdvanceVehicle is responsible for every Write Queue stall, but the correlation between `VehicleUI.Awake()` exceptions and the large stall bursts is very consistent.
Could you please investigate the `EntityFuelSystem` casts and vehicle compatibility, especially when used together with `VehicleMount` / `RustHelicopterController`?
I can provide the full server logs if needed.

Thank you.

Edited by hid333
NooBlet

Posted

Changed Status from Pending to Fixed

Changed Fixed In to 1.6.2

About Us

Codefling is the largest marketplace for plugins, maps, tools, and more, making it easy for customers to discover new content and for creators to monetize their work.

Downloads
3.1m
Total downloads
Customers
12.1k
Customers served
Files Sold
171.7k
Total sales
Payments
3.7m
Processed total
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.