TaskDriver - Improve Safety of JobData Query Operations #289
Labels
effort-medium
Standard - 2 to 4 hours
priority-medium
Standard task, plan as you see fit.
type-chore
Clean-up and optimization
In a job configured and run through
IJobConfig
/AbstractJobData
(usually a job in aTaskDriver
) it's currently on the developer to remember to add[ReadOnly]
attributes to anyNativeArray
's they are populating from a query when they don't plan to write to the elements. For example viaAbstractJobData.GetIComponentDataNativeArrayFromQuery
andAbstractJobData.GetEntityNativeArrayFromQuery
.Unity uses the prsence of a
[ReadOnly]
attribute on the field to determine if the component is read only even if the query only specified read only access (Ex:ComponentType.ReadOnly<MyComponent>
)If a developer forgets the attribute
NativeArray<T>.FailOutOfRangeErrror
will eventually trigger when two jobs go to get read access to the component at the same time.Ideally, the developer shouldn't have to remember to add the atribute. If they do have to remember then our safety system should let them know if the discrepency as soon as possible. Waiting until a race condition actually comes up at runtime is too late.
Some possible approaches:
[ReadOnly]
attribute on the field inside the wrapper will correctly inform Unity's safety system but this is ideal.Get*FromQuery<>
request check the destination field's attributes and ensure they align with the access type requested in the query.The text was updated successfully, but these errors were encountered: