Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi,

 

I get the following exception when doing the following:

 

Public PlayerInfo CurrentLocation { get => FSUIPCConnection.AirportsDatabase.GetPlayerLocation(AirportComponents.All); }

 

Here is the error I get. Strangely enough, the airports database built without problems. How would I fix this? The only way I get the below is to run it through the debugger in Visual Studio 2022.

 

ProtoBuf.ProtoException
  HResult=0x80131500
  Message=Invalid wire-type (6); this usually means you have over-written a file without truncating or setting the length; see https://stackoverflow.com/q/2152978/23354
  Source=protobuf-net.Core
  StackTrace:
   at ProtoBuf.ProtoReader.State.ThrowProtoException(String message)
   at ProtoBuf.ProtoReader.State.ThrowWireTypeException()
   at ProtoBuf.Internal.Serializers.SimpleCompiledSerializer`1.ProtoBuf.Serializers.ISerializer<T>.Read(State& state, T value)
   at ProtoBuf.ProtoReader.State.ReadAsRoot[T](T value, ISerializer`1 serializer)
   at ProtoBuf.Internal.DynamicStub.ConcreteStub`1.TryDeserialize(ObjectScope scope, TypeModel model, State& state, Object& value)
   at ProtoBuf.Internal.DynamicStub.TryDeserialize(ObjectScope scope, Type type, TypeModel model, State& state, Object& value)
   at ProtoBuf.Meta.TypeModel.Deserialize(ObjectScope scope, State& state, Type type, Object value)
   at ProtoBuf.Meta.TypeModel.DeserializeWithLengthPrefix(Stream source, Object value, Type type, PrefixStyle style, Int32 expectedField, TypeResolver resolver, Int64& bytesRead, Boolean& haveObject, SerializationContext context)
   at ProtoBuf.Meta.TypeModel.DeserializeWithLengthPrefix(Stream source, Object value, Type type, PrefixStyle style, Int32 expectedField, TypeResolver resolver, Int64& bytesRead)
   at ProtoBuf.Meta.TypeModel.DeserializeWithLengthPrefix(Stream source, Object value, Type type, PrefixStyle style, Int32 fieldNumber)
   at ProtoBuf.Serializer.DeserializeWithLengthPrefix[T](Stream source, PrefixStyle style, Int32 fieldNumber)
   at FSUIPC.DataStore.ReadSelection[T](String fileName, List`1 collection, String ICAO)
   at FSUIPC.FsAirport.LoadComponents(Byte ClassInstance, AirportComponents Components)
   at FSUIPC.FsAirportCollection.GetPlayerLocation(Byte ClassInstance, AirportComponents Components)
   at FSUIPC.FsAirportCollection.GetPlayerLocation(AirportComponents Components)
   at tfm.Airplanes.Airplane.get_CurrentLocation() in C:\Users\a_bor\Documents\GitHub\talking-flight-monitor\source\Airplanes\Airplane.cs:line 155
   at tfm.Airplanes.Airplane.<DetectILS>d__191.MoveNext() in C:\Users\a_bor\Documents\GitHub\talking-flight-monitor\source\Airplanes\Airplane.cs:line 1403
 

 

The relevant line of code is:

 

if (tfm.Properties.Settings.Default.ReadILS && !this.CurrentLocation.OnGround)

 

Found in the method below:

 

protected async virtual void DetectILS()
{
    if (_isFirstRun) return;


    {
        if (tfm.Properties.Settings.Default.ReadILS && !this.CurrentLocation.OnGround)
        {

            // Detect the glide slope.                               
            if (_nav1GSOffset.Value == 1 && _glideSlopeDetected == false)
            {
                AudioManager.Output("Glide slope is alive");
                _glideSlopeDetected = true;
            }

            // Detect the localizer.
            if (NavRadios.RadioFlags[7] && _hasLocalizer == false)
            {
                AudioManager.Output("Nav1 has localizer");
                _hasLocalizer = true;
            }

            // The localizer is alive.
            if (NavRadios.Nav1Signal == 256 && NavRadios.RadioFlags[7] && _localizerDetected == false)
            {
                //double magvar = (double)_magneticVariationOffset.Value * 360d / 65536d;
                //double rwyHeading = (double)NavRadios.InverseRunwayHeading * 360d / 65536d + 180d - magvar;
                //rwyHeading = Math.Truncate(rwyHeading);

                if (FlightPlanning.FlightPlan.DestinationRunway != null)
                {
                    var course = NavRadios.Nav1Course;
                    AudioManager.Output($"Localizer is alive: Course {course}");
                    _localizerDetected = true;
                    _ilsTimer.AutoReset = true;
                    _ilsTimer.Enabled = true;

                }
                else
                {
                    AudioManager.Output("Warning! Destination runway not set.");
                }
            }

            // Has the glide slope.
            if (NavRadios.AutoPilotRadioFlags[6] && _hasGlideSlope == false)
            {
                AudioManager.Output("Nav1 has glide slope");
                _hasGlideSlope = true;
            }
        }
        else
        {
            _ilsTimer.Enabled = false;
            _hasGlideSlope = false;
            _hasLocalizer = false;
            _localizerDetected = false;
            _glideSlopeDetected = false;
        }
    }
}

 

 

Posted

Hi Andy,

I can't reproduce this here at the moment.

Does this only happen for you at a specific airport, or any airport?

If it's one airport do you have third-party scenery at the airport?

What sim is this? MSFS2020?

Are you using the latest version of my dll? (3.1.13)

Paul

Posted

Hi,

 

It happens with most airports, especially in the United States. A prime example that gives me this problem is KSFO, KLAX, or anything on the west coast. Sometimes KJFK and KBOS do it, but it is almost nonexistent. I also noticed that when I pull out if the player is on the runway, and what runway they are on, I get unpredictable results. A good example is runways 24 and 25 at KSFO. Going into KRNO last night to runway 17R, my PMDG738 had CMDA and CMDB on, landed on the runway, but the scenery extract from the airports database was telling me that I wasn't on a runway at all. Visually, the landing was perfect. I am running the newest library version. This is MSFS2020. We aren't using 3rd party scenery, only the MSFS2020 default.

Posted

Hi Andy,

I've checked out those airports and everything looks fine here.

I looked at my code that reads the protobuf files and found a couple of problems with the thread safety. My tests here are only on a single thread so maybe that's causing your problems.

Can you please try version 3.1.15-beta (now on NuGet) and see if that fixes the problems. You'll need to check the box marked "Include Pre-Release" to see the beta version.

If that doesn't help, please can you zip and attach your makerunways output files so I can test with the same data as you?

Runways.xml
F5.csv
R5.csv
G5.csv
Helipads.csv
T5.csv

Thanks,

Paul

Posted

I don't think this has anything to do with make runways, but this is what I get now. I never modified my code, so it is the same as before.

 

System.InvalidOperationException
  HResult=0x80131509
  Message=Collection was modified; enumeration operation may not execute.
  Source=System.Private.CoreLib
  StackTrace:
   at System.ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion()
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at FSUIPC.FsAirport.LoadComponents(Byte ClassInstance, AirportComponents Components)
   at FSUIPC.FsAirportCollection.GetPlayerLocation(Byte ClassInstance, AirportComponents Components)
   at FSUIPC.FsAirportCollection.GetPlayerLocation(AirportComponents Components)
   at tfm.Airplanes.Airplane.get_CurrentLocation() in C:\Users\a_bor\Documents\GitHub\talking-flight-monitor\source\Airplanes\Airplane.cs:line 155
   at tfm.Airplanes.Airplane.<DetectILS>d__191.MoveNext() in C:\Users\a_bor\Documents\GitHub\talking-flight-monitor\source\Airplanes\Airplane.cs:line 1403
 

Posted

Thanks, I'm pretty sure it's a multi-threading problem. Now the file reading is thread-safe, the problem is manifesting one layer up in the in-memory database code.

I'll go through all the database code in the next few days and make it thread-safe.

I'll let you know when there's a new version to try.

Paul

Posted

Yes, it appears to be stable. I tried it around 20 times in the debugger, and none of them threw the protobuf error. Out of interest, is the entire airports database thread safe, or only parts of it? Just wondering, because we use it in a multi threaded environment quite often.

Posted
Quote

Out of interest, is the entire airports database thread safe, or only parts of it?

I've have a quick look and there's probably more I can do. The airports collections might not behave well if the same collection is being accessed by two threads at the same time.

I'll go through the rest of the airports database code and make any improvements needed.

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.