Search Issue Tracker

By Design

Votes

0

Found in

6000.0.27f1

6000.1.0a4

Issue ID

UUM-87135

Regression

No

InsufficientMemoryException error appears after any assembly reload when await is used to execute a callback

--

-

How to reproduce:
1. Open the attached "IN-88507" project
2. Open the "SampleScene" and enter Play mode
3. Observe the Console window
4. Exit Play mode
5. Observe the Console window again

Expected result: Error message is printed during Play mode
Actual result: Error message only appears outside Play mode

Reproducible in: 6000.0.27f1, 6000.1.0a4
Could not test with: 2021.3.46f1, 2022.3.52f1 (Awaitable class only available from 2023.x onward)

Reproducible on: Windows 11, macOS 14.6.1 (M1 Pro), macOS 15.1 (M1 Max)
Not reproducible on: No other environments tested

  1. Resolution Note:

    When not monitored Tasks is reported is not something we are in control of that is done when the GC is collected. That will happen when there is a code reload when entering or exiting playmode.

    A better way of doing task like that is to monitor the completion of the task either by making the callback async

    public async void Start()
    {
    await AsyncTest();
    }

    or if you still want a fire and forget style setup a continuation that validates the success and failure of the task

    public void Start()
    {
    AsyncTest()
    .ContinueWith(FireForgetComplete);
    }

    private void FireForgetComplete(Task task)
    {
    if (task.IsFaulted)
    {
    Debug.LogException(obj.Exception?.InnerException);
    }
    }

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.