Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi,

I'm getting a lot of crashes with errors like these:

Quote
System.ArgumentException: An item with the same key has already been added. Key: A320_Audio:Relay_1
  ?, in bool Dictionary<TKey, TValue>.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
  ?, in void LVarCollection.add(FsLVar lvar)
  ?, in void WAPI.fsuipcw_getLvarList(ReceiveListCallback ReceiveFunction)
  ?, in void MSFSVariableServices.refreshData()
  ?, in void MSFSVariableServices.lvarsValueChanged(IntPtr id, IntPtr Value)

With various keys. I'm not sure if there's an issue in my code; here is the init code (with simconnect):

 try {
   VS.LogLevel = LOGLEVEL.LOG_LEVEL_INFO;
   VS.OnValuesChanged += VS_OnValuesChanged;
   VS.OnLogEntryReceived += VS_OnLogEntryReceived;

   VS.Init();

   VS.Start();
 } catch (Exception e) {
   Log.Error($"Error initializing WASM module ${e.Message}");
 }

And then the stripped down code which checks, but I'm not sure there's anything here that I'm doing incorrectly.

lock (_lvarUpdateLock) {
            bool anyChanged = false;
            foreach (var fvd in AircraftFeatures.FeatureLVarIterator()) {
                if (fvd == null || string.IsNullOrEmpty(fvd.LookupKey)) {
                    continue;
                }

                if (!VS.LVars.Exists(fvd.LookupKey)) {
                    continue;
                }

                var value = VS.LVars[fvd.LookupKey].Value;

                if (fvd.Value != value) {
                    Log.Trace($"LVar {fvd.LookupKey} found changed, value={value}, old={fvd.Value}");
                }

                fvd.Value = VS.LVars[fvd.LookupKey].Value;
                anyChanged = true;
            }
...

The client DLL version is 3.3.5.405. But it doesn't seem like there's anything in my code I can update. I'm removing the VS_OnValuesChanged handler on a stop, bit I'm reorganizing this code just in case there's the callback being registered multiple times. But I don't think that'd matter in this context.

Posted

Dug another one out of error reporting

 

Quote
System.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
  ?, in ref TValue Dictionary<TKey, TValue>.FindValue(TKey key)
  ?, in void MSFSVariableServices.receiveValuesCallback(string name, double value)
  ?, in void WAPI.fsuipcw_getLvarValues(ReceiveValuesCallback ReceiveFunction)
  ?, in void MSFSVariableServices.refreshData()
  ?, in void MSFSVariableServices.lvarsValueChanged(IntPtr id, IntPtr Value)

 

Posted

Looks like they started showing up two weeks ago, not sure if that corresponds to a release. I'm just getting back into the swing of things, I've been out of touch.

Posted

HI Nabeel,

Quote

I'm getting a lot of crashes with errors like these:

It looks like a threading issue. It seems like my DLL is receiving simultaneous callbacks from the WASM library on different threads.

It nothing to do with your code. 

Quote

Looks like they started showing up two weeks ago,

John did change the WASM library to automatically report new LVar discoveries about two weeks ago. It could be related to that.

I'll add some thread-safety to this part of my DLL tomorrow. Hopefully that will fix it.

Paul 

Posted

Version 3.3.6-beta is now on NuGet. You'll need to tick "Show Pre-Release" in the Nuget package manager to see it.

Please try with this version and see if it fixes the exceptions. 

Paul

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy 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.