Search Issue Tracker

Fixed in 1.1.0.-pre.5

Votes

8

Found in [Package]

1.1.0-pre.5

Issue ID

1347311

Regression

No

[WebGL] Mouse position is not relative to the canvas when using the new input system

Package: Input System

-

There are two issues in this bug report:

This error was seen when calling InputSystem.RegisterBindingComposite function with RuntimeInitializeOnLoadMethod attribute:
"InvalidOperationException while resolving binding 'point:PointerInput' in action map 'PointerControls"

This was occurring not because of a bug, but because the script was missing the [RuntimeInitializeLoadType.BeforeSceneLoad] attribute before calling the register function:
Example:
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void Register()
{
InputSystem.RegisterBindingComposite<PointerInputComposite>();
}

The documentation was updated to clarify this: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/ActionBindings.html#writing-custom-composites

Once you add that, the error goes away, but then there is a bug in the WebGL new input system code where the mouse position returned was relative to the browser window, and not the Unity canvas.

How to reproduce:
1. Open the attached project
2. Make a WebGL build
3. Host the built WebGL Player locally
4. Open the built Player in a browser
5. Wait for the Player to load
6. Check the Developer Console (shortcut F12)

Expected result: No exceptions are thrown
Actual result: "RuntimeError: memory access out of bounds" error are thrown

Reproducible with: 1.1.0-pre.5 (2021.2.0b4, 2022.1.0a2)
Not reproducible with: 1.1.0-pre.5 (2019.4.29f1, 2020.3.14f1,, 2021.1.15f1) (Player doesn't crash but Input errors are still thrown)

Note:
- There are also additional "InvalidOperationException while resolving binding" errors thrown

Workaround:
- Adding a 'RuntimeInitializeLoadType.BeforeSceneLoad' parameter to the RuntimeInitializeOnLoadMethod Attribute used on the Register function (to call InputSystem.RegisterBindingComposite<PointerInputComposite>();) seems to resolve the crash and errors. Function is inside the PointerInput.cs file

  1. Resolution Note (fix version 1.1.0.-pre.5):

    Fixed in 2022.1.0a7

  2. Resolution Note (fix version 1.1.0.-pre.5):

    Fixed in 2020.3.29f1

  3. Resolution Note:

    Fixed in 2021.1.21f1

  4. Resolution Note:

    Fixed in 2021.2.0b12

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.