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

workaround for minecraft pointerevent bug on chromeos #10265

Merged
merged 2 commits into from
Nov 14, 2024

Conversation

riknoll
Copy link
Member

@riknoll riknoll commented Nov 13, 2024

fixes https://github.com/microsoft/pxt-minecraft/issues/2622

the issue here was that minecraft on chromeos was dropping pointerup events whenever a multitouch gesture was used on the trackpad. blockly tracks what pointers are currently still "down", so if a pointerup event goes missing then it will get stuck forever thinking that it is within a multitouch gesture even when there are no fingers still on the trackpad.

to fix this, i had to monkey patch blockly's gesture class to prevent it from tracking multiple pointers on chromeos. essentially, this patch filters all pointer events for all fingers except whichever went down first. all pointerup events are let through, however, which allows the user to get out of a stuck gesture by simply doing another click or drag on the workspace. hopefully that's the first thing they will intuitively try to do when the workspace gets stuck to the cursor.

a proper fix for this issue would be to investigate why the pointer events are being dropped by minecraft (or the android webview). but that would take longer and require a minecraft release, so this hack will have to do for now. blockly could also stand to be a little more fault-tolerant when it comes to gestures.

@riknoll riknoll requested a review from a team November 13, 2024 23:21
pxtlib/browserutils.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@thsparks thsparks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question, otherwise looks okay to me!

const syntheticEvent = new PointerEvent(e.type, {
...e,
clientX: e.clientX,
clientY: e.clientY,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why to clientX and clientY have to be respecified here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pointer events are native objects and i was seeing some strange behavior where certain properties weren't being assigned when using the spread operator. as a safety measure, i went ahead and directly specified everything that is used by Blockly's gesture implementation today

@riknoll riknoll merged commit 5513c79 into master Nov 14, 2024
6 checks passed
@riknoll riknoll deleted the dev/riknoll/minecraft-chromeos-gesture-fix branch November 14, 2024 19:10
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.

4 participants