bevyengine / bevyengine/bevy

Touch events report coordinates relative to the phone screen itself in browser builds

Open
#9,071 3 comments 3 reactions 0 assignees View on GitHub
A-Input C-Bug O-Web
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version

0.10.1

## What you did

Compiled into wasm / attached to a specific canvas (but I think no explicit canvas will do as well)

## What went wrong

- what were you expecting?

touch events are relative to the canvas

- what actually happened?

touch events are reported relative to the screen (not even to the browser window!)

Other information that can be used to further reproduce or isolate the problem.

- screencast

https://github.com/bevyengine/bevy/assets/947595/835a338b-028b-436c-9d42-f258e221b68f

- workarounds that you used

explicitly send `canvas.getBoundingClientRect()` and use this data in your system to calculate the actual touch coords

- links to related bugs, PRs or discussions

probably https://github.com/bevyengine/bevy/issues/7528

- reproduction case deployed

https://touchies.apps.loskutoff.com/

- reproduction source code

https://github.com/Firfi/touchies

- notes

please note that the touch is being reported not even related to the browser window (which I could've worked around giving the app its canvas coordinates) bit the phone screen itself, as shown in the attached screencast

for mouse event comparison, the example deployed also has mouse event system; click couple times (to focus the element first, then to emit the actuan event)

Contributor guide

Open the contributing guide

Research direction

Start with the deployed reproduction at https://touchies.apps.loskutoff.com/ and compare its touch and mouse event systems, then inspect the reproduction source at https://github.com/Firfi/touchies. Verify the behavior for a canvas attached in a browser build; done means touch coordinates are relative to the canvas rather than the phone screen.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, wasm
Domain
frontend, game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.