ArgumentNullException: Value cannot be null - API_SignTextError

Getting this sometimes when I call  :  SignArtist.API_SignText( null, sign, text, fontSize, colorHex, bgColorHex );

ArgumentNullException: Value cannot be null.
Parameter name: source
at System.Linq.Enumerable.TryGetFirst[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Boolean& found) [0x0000d] in <351e49e2a5bf4fd6beabb458ce2255f3>:0
at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00000] in <351e49e2a5bf4fd6beabb458ce2255f3>:0
at Oxide.Plugins.SignArtist+PaintableSignage.TextureId () [0x00006] in <bc1ee35402bf48978ab2622916f7c93e>:0
at Oxide.Plugins.SignArtist+ImageDownloader+<DownloadImage>c__Iterator0.MoveNext () [0x003e5] in <bc1ee35402bf48978ab2622916f7c93e>:0
at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00026] in <745c4d442eef4e08b35b5975d62d89d1>:0

You are passing null to it, as the first arg; hence the error. ;)

The signature is:

void API_SignText(BasePlayer player, Signage sign, string message, int fontsize = 30, string color = "FFFFFF", string bgcolor = "000000")​

Passing null as the first argument works 99% of the time, I think there's a deeper problem at play. Reloading the plugin seems to fix this behaviour.  Still investigating!

I've narrowed down the issue to the call to this:

request.Sign.TextureId()

In the DownloadImage function.

Merged post

I surrounded this with a try / catch and it seems to have fixed the issue.

It's possible the try/catch is causing a memory leak.

                try
                {
                    // Check if the sign already has a texture assigned to it.
                    if (request.Sign.TextureId() > 0)
                    {
                        //singleton.Puts("SA: DownloadImage 4.5 ");

                        // A texture was already assigned, remove this file to make room for the new one.
                        FileStorage.server.Remove(request.Sign.TextureId(), FileStorage.Type.png, request.Sign.NetId);
                    }
                } catch (Exception e)
                {
                    //singleton.Puts($"SA: DownloadImage 4.5e {e.Message} << end error. ");

                }​


Merged post

can't say for sure though, I would image FileStorage only deals with long term storage

Merged post

I've added this instead of a try/catch and it seems to have fixed the issue properly

//line 703, add this after public uint TextureId()
                Sign.EnsureInitialized();