Search Issue Tracker
Active
Under Consideration for 6000.7.X
Votes
0
Found in
6000.0.78f1
6000.3.19f1
6000.5.2f1
6000.6.0b2
6000.7.0a1
Issue ID
UUM-145821
Regression
No
NullReferenceException is outputted when using Awaitable.Cancel
Steps to reproduce:
1. Open the attached user's project "awaitable-cancel-repro.zip"
2. Open the "Assets/Scenes/SampleScene.unity" and enter play mode
3. Observe the console window:
The AwaitableCancel MonoBehaviour on the "AwaitableTest - Cancel with Cancel() => NullReferenceException" GameObject produces a NullReferenceException
The AwaitableCancel MonoBehaviour on the "AwaitableTest - Cancel with token => works" GameObject doesn't produce an error
Actual result: error from using `Awaitable.Cancel`, but not if cancellation is done with a CancellationTokenSource instead
Expected result: no error from using `Awaitable.Cancel` to cancel an Awaitable
Reproducible with: 6000.0.78f1, 6000.3.19f1, 6000.5.2f1, 6000.6.0b2, 6000.7.0a1
Testing Environment: Windows 11
Not reproducible on: no other environment tested
Notes:
-The documentation https://docs.unity3d.com/ScriptReference/Awaitable.Cancel.html states:
Cancels the awaitable. If the awaitable is being awaited, the awaiter receives a System.OperationCanceledException
Note: some methods returning an Awaitable also accept a CancellationToken. Both cancelation models are equivalent
-Both cancelation models are not equivalient in this scenario
-error:
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.Awaitable`1[T].SetResultAndRaiseContinuation (T result) (at <254a04541d1c4a7b9e9c9e594cf72b4c>:0)
UnityEngine.AwaitableCompletionSource`1[T].TrySetResult (T& value) (at <254a04541d1c4a7b9e9c9e594cf72b4c>:0)
AwaitableCancel.Update () (at Assets/AwaitableCancel.cs:46)
System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) (at <932fbe8ac5a946808aa5d7b95844e18c>:0)
UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at <254a04541d1c4a7b9e9c9e594cf72b4c>:0)
UnityEngine.UnitySynchronizationContext.Exec () (at <254a04541d1c4a7b9e9c9e594cf72b4c>:0)
UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at <254a04541d1c4a7b9e9c9e594cf72b4c>:0)
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Selected element is not visible in the hierarchy when picking a deeply nested element via Pick Element in the UI Toolkit Debugger
- NullReferenceException is outputted when using Awaitable.Cancel
- A GameObject that was parented to an inactive GameObject during Play mode stays visible in the Game and Scene views when GPU Resident Drawer is enabled
- UXML Style/Template/Instance tags are flagged as not allowed when validating against the generated XML schema
- Crash on Scripting::UnityEditor::SelectionProxy::Internal_NonSelectedObjectWasDestroyed when performing various Unity operations
Add comment