Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix null pointer exceptions after resuming Unity from iOS #632

Closed

Conversation

MarquisMc
Copy link

@MarquisMc MarquisMc commented Oct 22, 2024

Fixes #597

Add null reference checks and reinitialize references after resuming Unity to prevent null pointer exceptions in UniTask code snippets.

  • AsyncUniTaskMethodBuilder.cs
    • Add null reference checks in SetResult, SetException, AwaitOnCompleted, and AwaitUnsafeOnCompleted methods.
  • PlayerLoopRunner.cs
    • Add code to reinitialize references after resuming in RunCore method.
  • PlayerLoopHelper.cs
    • Add code to ensure references are not lost after resuming in AddAction and AddContinuation methods.

For more details, open the Copilot Workspace session.

Fixes Cysharp#597

Add null reference checks and reinitialize references after resuming Unity to prevent null pointer exceptions in UniTask code snippets.

* **AsyncUniTaskMethodBuilder.cs**
  - Add null reference checks in `SetResult`, `SetException`, `AwaitOnCompleted`, and `AwaitUnsafeOnCompleted` methods.
* **PlayerLoopRunner.cs**
  - Add code to reinitialize references after resuming in `RunCore` method.
* **PlayerLoopHelper.cs**
  - Add code to ensure references are not lost after resuming in `AddAction` and `AddContinuation` methods.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/Cysharp/UniTask/issues/597?shareId=XXXX-XXXX-XXXX-XXXX).
@neuecc
Copy link
Member

neuecc commented Oct 23, 2024

Your null reference check is designed to double-check for null in this way.
At first glance, it seems pointless, but can you explain what it means?

if (runnerPromise == null)
{
    ex = exception;
}
else
{
    if (runnerPromise != null)
    {
        runnerPromise.SetException(exception);
    }
}

It says “open the Copilot Workspace session”, but is this fix being made using AI?

@neuecc neuecc closed this Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unityFramework?.pause(true) throw null pointer exceptions
2 participants