You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The parameter CancellationToken cancellationToken = null
The conversion/packing of this parameter IL2CPP.il2cpp_object_unbox(IL2CPP.Il2CppObjectBaseToPtrNotNull(cancellationToken))
The parameter is of class type CancellationToken, extending Il2CppSystem.ValueType (unhollowed version of the struct CancellationToken)
In the source code for this method in the UniTask repository, this parameter is normally defined as CancellationToken cancellationToken = default(CancellationToken)
The unhollowed parameter being defined as null causes a problem when this method is called without filling out all parameters, because obviously Il2CppObjectBaseToPtrNotNull throws an exception when it is null.
This can be remedied on a per-method basis by prefixing the offending methods and replacing parameters, but this is manual and still represents a bug in the generated IL. A solution could be making the IL mirror IL2CPP.Il2CppObjectBaseToPtrNotNull(cancellationToken ?? new CancellationToken()), or keep a cached copy of a default CancellationToken and retrieving that field, to avoid recreating objects, but there's more complexity to keeping that field and possibly making sure it's not collected.
The text was updated successfully, but these errors were encountered:
As an example and for ease of demonstration, unhollowed code from BONELAB is provided:
The relevant portions are the following:
CancellationToken cancellationToken = null
IL2CPP.il2cpp_object_unbox(IL2CPP.Il2CppObjectBaseToPtrNotNull(cancellationToken))
The parameter is of class type
CancellationToken
, extendingIl2CppSystem.ValueType
(unhollowed version of the structCancellationToken
)In the source code for this method in the UniTask repository, this parameter is normally defined as
CancellationToken cancellationToken = default(CancellationToken)
The unhollowed parameter being defined as null causes a problem when this method is called without filling out all parameters, because obviously
Il2CppObjectBaseToPtrNotNull
throws an exception when it is null.This can be remedied on a per-method basis by prefixing the offending methods and replacing parameters, but this is manual and still represents a bug in the generated IL. A solution could be making the IL mirror
IL2CPP.Il2CppObjectBaseToPtrNotNull(cancellationToken ?? new CancellationToken())
, or keep a cached copy of a default CancellationToken and retrieving that field, to avoid recreating objects, but there's more complexity to keeping that field and possibly making sure it's not collected.The text was updated successfully, but these errors were encountered: