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

Calling async ServerRpc that returns value crashes the server on 2021.2 #997

Closed
Jobus0 opened this issue Nov 30, 2021 · 5 comments · Fixed by #1000
Closed

Calling async ServerRpc that returns value crashes the server on 2021.2 #997

Jobus0 opened this issue Nov 30, 2021 · 5 comments · Fixed by #1000
Labels
bug Something isn't working released Weaver

Comments

@Jobus0
Copy link
Contributor

Jobus0 commented Nov 30, 2021

Describe the bug
Simply calling an async UniTask ServerRpc from a client instantly crashes the server, whether it be in the editor or on a build, with Unity 2021.2. Also tested on 2021.1.13, but there was no issue there.

Repro project
Tiny project with a simple Player script that calls an async rpc to get randomized X position when spacebar is pressed.
Mirage Async RPC Test.zip

To Reproduce
Steps to reproduce the behavior:

  1. Open the attached project.
  2. Open the 'Scene' scene.
  3. Build a player or duplicate the project so multiplayer can be tested.
  4. Play game, host. Join with other client.
  5. Press Spacebar key on the joined client to call the async rpc, instantly crashing the server process.

Desktop (please complete the following information):

  • OS: Windows 10
  • Build target: Editor/Windows
  • Unity version: 2021.2.4
  • Mirage version: v113.0.0

Additional context
The calling code looks like this:

public class Player : NetworkBehaviour
{
    private void Update()
    {
        if (IsLocalPlayer && Input.GetKeyUp(KeyCode.Space))
            StrafeByRandomValueFromServer().Forget();
    }

    private async UniTaskVoid StrafeByRandomValueFromServer()
    {
        float value = await RequestRandomValue();
        transform.position = new Vector3(value, 0f, 0f);
    }

    [ServerRpc]
    public UniTask<float> RequestRandomValue()
    {
        return UniTask.FromResult(Random.Range(-2, 2f));
    }
}

Crash log:
Player.log

@dragonslaya84
Copy link
Member

We will try have look at this a resolve soon as possible. Thank you for the report and project to replicate it in.

@James-Frowen James-Frowen added bug Something isn't working Weaver labels Dec 3, 2021
James-Frowen added a commit that referenced this issue Dec 4, 2021
@James-Frowen
Copy link
Member

I can't seem to replicate the crash using the Player script.

I've also added extra tests to make sure it works for other return types.

@James-Frowen
Copy link
Member

seems to be an issue that is effecting unity 2021.2.4

@Jobus0
Copy link
Contributor Author

Jobus0 commented Dec 4, 2021

Yeah, 2021.1.x works fine. I haven't tested previous 2021.2.x versions, but 2021.2.5 is also broken.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2021

🎉 This issue has been resolved in version 113.0.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released Weaver
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants