Nabeel Posted March 19, 2023 Report Share Posted March 19, 2023 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. Link to comment Share on other sites More sharing options...
Nabeel Posted March 19, 2023 Author Report Share Posted March 19, 2023 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) Link to comment Share on other sites More sharing options...
Nabeel Posted March 19, 2023 Author Report Share Posted March 19, 2023 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. Link to comment Share on other sites More sharing options...
Paul Henty Posted March 19, 2023 Report Share Posted March 19, 2023 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 Link to comment Share on other sites More sharing options...
Nabeel Posted March 19, 2023 Author Report Share Posted March 19, 2023 Thanks, sounds good! Yeah, with multi-threading issues, I just wanted to rule out my own code which does the same thing. Link to comment Share on other sites More sharing options...
Paul Henty Posted March 20, 2023 Report Share Posted March 20, 2023 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 Link to comment Share on other sites More sharing options...
Nabeel Posted March 20, 2023 Author Report Share Posted March 20, 2023 Thanks for the quick turnaround, giving it a test now Link to comment Share on other sites More sharing options...
Nabeel Posted March 20, 2023 Author Report Share Posted March 20, 2023 It seems like it's working as expected now 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now