SimConnect ClientData Behavior Bug on P3D v4.1 (and back to v2.5)

adiemus
Posts: 115
Joined: Fri Mar 16, 2012 4:19 am
Contact:

SimConnect ClientData Behavior Bug on P3D v4.1 (and back to v2.5)

Postby adiemus » Mon Jan 08, 2018 11:39 pm

Seems I keep running into SimConnect bugs of late. See: http://www.prepar3d.com/forum/viewtopic ... 1&t=127917

This time, the issue is with ClientData. Long story short, on P3D v4.1 (and v3.4hf3, and v2.5) if you call SimConnect_RequestDataOnSimObject() after SimConnect_RequestClientData(), you'll never actually get called back for the ClientData you requested. If you move the RequestDataOnSimObject() call to before RequestClientData(), things work as expected. (I've also tested in on FSX:A and FSX:Steam, both of which do NOT have this bug)

I've created and uploaded a minimal VS2015 solution here that reproduces the behavior:
https://forums.vrsimulations.com/downlo ... taTest.zip

It contains two projects:
- ClientDataServer - Creates the ClientData area "ClientDataTest_Main" and monitors it for changes
- ClientDataReader - Reads (and writes) to "ClientDataTest_Main"
The project should be self-contained (but was only tested on VS2015) and can be built 32-bit or 64-bit. Get to the Aircraft Loading screen in whatever version of P3D you want to test with. First run ClientDataServer.exe, then run ClientDataReader.exe to observe the behavior.

If you build ClientDataReader.exe with the "BROKEN_BEHAVIOR" define (the default) you'll never see any SIMCONNECT_RECV_ID_CLIENT_DATA callbacks in ClientDataReader.exe. If you comment out that define, you'll see the callbacks arrive.

As an additional view, here are the relevant log snippets from two runs as described above, on P3D v4.1. The first is with BROKEN_BEHAVIOR set:
> 50.51838 [ 3, 1]Open: Version=0x0000001B Name="ClientDataServer"
> 50.51851 [ 3, 2]MapClientDataNameToID:szClientDataName="ClientDataTest_Main", ClientDataID=1
> 50.51859 [ 3, 3]CreateClientData:ClientDataID=1, dwSize=512, Flags=0
> 50.51860 [ 3, 4]AddToClientDataDefinition:DefineID=1, dwOffset=-1, dwSizeOrType=512, fEpsilon=0.000000, DatumID=-1
> 50.51861 [ 3, 5]RequestClientData:ClientDataID=1, RequestID=1, DefineID=1, Period=3, Flags=0, origin=0, interval=0, limit=0
> 50.51861 [ 3, 6]SubscribeToSystemEvent:EventID=1, SystemEventName="Sim"
< 50.51863 [3] Event: 1
> 54.64752 [ 4, 1]Open: Version=0x0000001B Name="ClientDataReader"
> 54.64755 [ 4, 2]AddToDataDefinition:DefineID=1, DatumName="PLANE LATITUDE", UnitsName="radians", DatumType=4, fEpsilon=0.000000, DatumID=-1
> 54.64760 [ 4, 3]AddToDataDefinition:DefineID=1, DatumName="PLANE LONGITUDE", UnitsName="radians", DatumType=4, fEpsilon=0.000000, DatumID=-1
> 54.64760 [ 4, 4]AddToDataDefinition:DefineID=1, DatumName="PLANE ALTITUDE", UnitsName="meters", DatumType=4, fEpsilon=0.000000, DatumID=-1
> 54.64764 [ 4, 5]MapClientDataNameToID:szClientDataName="ClientDataTest_Main", ClientDataID=1
> 54.64765 [ 4, 6]AddToClientDataDefinition:DefineID=1, dwOffset=-1, dwSizeOrType=512, fEpsilon=0.000000, DatumID=-1
> 54.64766 [ 4, 7]RequestClientData:ClientDataID=1, RequestID=1, DefineID=1, Period=3, Flags=0, origin=0, interval=0, limit=0
> 54.64766 [ 4, 8]SubscribeToSystemEvent:EventID=1, SystemEventName="Sim"
< 54.64767 [4] Event: 1
> 54.64767 [ 4, 9]RequestDataOnSimObject:RequestID=1, DefineID=1, ObjectID=0, Period=4, Flags=0, origin=0, interval=0, limit=0
> 58.69516 [ 4, 10]SetClientData:ClientDataID=1, DefineID=1, Flags=0, dwReserved=0, cbUnitSize=512, pDataSet=957726276
< 58.69520 [3] ClientData: RequestID=1 DefineID=1 dwSize=552
Note how ClientDataReader calls RequestDataOnSimObject() after RequestClientData(). Note also how the ClientData events only go to ClientDataServer [3], not ClientDataReader. [4]

And here's the exact same code, only this time with the call to RequestDataOnSimObject() moved to before RequestClientData():
> 5.01455 [ 3, 1]Open: Version=0x0000001B Name="ClientDataServer"
> 5.01458 [ 3, 2]MapClientDataNameToID:szClientDataName="ClientDataTest_Main", ClientDataID=1
> 5.01459 [ 3, 3]CreateClientData:ClientDataID=1, dwSize=512, Flags=0
> 5.01459 [ 3, 4]AddToClientDataDefinition:DefineID=1, dwOffset=-1, dwSizeOrType=512, fEpsilon=0.000000, DatumID=-1
> 5.01460 [ 3, 5]RequestClientData:ClientDataID=1, RequestID=1, DefineID=1, Period=3, Flags=0, origin=0, interval=0, limit=0
> 5.01461 [ 3, 6]SubscribeToSystemEvent:EventID=1, SystemEventName="Sim"
< 5.01462 [3] Event: 1
> 10.18849 [ 4, 1]Open: Version=0x0000001B Name="ClientDataReader"
> 10.18856 [ 4, 2]AddToDataDefinition:DefineID=1, DatumName="PLANE LATITUDE", UnitsName="radians", DatumType=4, fEpsilon=0.000000, DatumID=-1
> 10.18858 [ 4, 3]AddToDataDefinition:DefineID=1, DatumName="PLANE LONGITUDE", UnitsName="radians", DatumType=4, fEpsilon=0.000000, DatumID=-1
> 10.18859 [ 4, 4]AddToDataDefinition:DefineID=1, DatumName="PLANE ALTITUDE", UnitsName="meters", DatumType=4, fEpsilon=0.000000, DatumID=-1
> 10.18860 [ 4, 5]RequestDataOnSimObject:RequestID=1, DefineID=1, ObjectID=0, Period=4, Flags=0, origin=0, interval=0, limit=0
> 10.18861 [ 4, 6]MapClientDataNameToID:szClientDataName="ClientDataTest_Main", ClientDataID=1
> 10.18861 [ 4, 7]AddToClientDataDefinition:DefineID=1, dwOffset=-1, dwSizeOrType=512, fEpsilon=0.000000, DatumID=-1
> 10.18862 [ 4, 8]RequestClientData:ClientDataID=1, RequestID=1, DefineID=1, Period=3, Flags=0, origin=0, interval=0, limit=0
> 10.18864 [ 4, 9]SubscribeToSystemEvent:EventID=1, SystemEventName="Sim"
< 10.18865 [4] Event: 1
> 14.23168 [ 4, 10]SetClientData:ClientDataID=1, DefineID=1, Flags=0, dwReserved=0, cbUnitSize=512, pDataSet=960942228
< 14.23172 [4] ClientData: RequestID=1 DefineID=1 dwSize=552
< 14.23174 [3] ClientData: RequestID=1 DefineID=1 dwSize=552
Note how now SimConnect sends ClientData events to both ClientDataServer [3] and ClientDataReader. [4]

adiemus
Posts: 115
Joined: Fri Mar 16, 2012 4:19 am
Contact:

Re: SimConnect ClientData Behavior Bug on P3D v4.1 (and back to v2.5)

Postby adiemus » Tue Jan 09, 2018 12:19 am

And actually, it's worse than I realized. Moving the call to SimConnect_RequestDataOnSimObject() before SimConnect_RequestClientData() does fix the SIMCONNECT_RECV_ID_CLIENT_DATA callbacks, but breaks the SIMCONNECT_RECV_ID_SIMOBJECT_DATA callbacks expected from RequestDataOnSimObject(). So either you can get your ClientData callbacks or your RequestDataOnSimObject() callbacks, but not both.

As far as I can see, the only real workaround for this on P3D (it doesn't happen on FSX, remember) is to create a dedicated SimConnect connection for ClientData use, and not to do anything else with it.

User avatar
Rob McCarthy
Lockheed Martin
Posts: 1056
Joined: Wed Aug 24, 2011 1:37 pm

Re: SimConnect ClientData Behavior Bug on P3D v4.1 (and back to v2.5)

Postby Rob McCarthy » Wed Jan 10, 2018 2:36 pm

Thanks for the detailed report. We'll investigate this issue on our end and get back to you.

Regards,
Rob McCarthy
Rob McCarthy
Prepar3D® Core Lead


Return to “SimConnect Interface Questions”

Who is online

Users browsing this forum: No registered users and 4 guests