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

Infinite loop when handling 'pointermove' events. #8396

Closed
1 task done
mikeharv opened this issue Jul 18, 2024 · 8 comments · Fixed by #8470
Closed
1 task done

Infinite loop when handling 'pointermove' events. #8396

mikeharv opened this issue Jul 18, 2024 · 8 comments · Fixed by #8470
Assignees
Labels
issue: bug Describes why the code or behaviour is wrong

Comments

@mikeharv
Copy link
Contributor

mikeharv commented Jul 18, 2024

Check for duplicates

  • I have searched for similar issues before opening a new one.

Description

Users get RangeError: Maximum call stack size exceeded if they attempt to drag a block with multiple fingers on a workspace where zoom controls/wheel are disabled.

My understanding of these two functions is as follow:

  1. handleMove Function:

    • Checks if the gesture is a drag or a multi-touch event
    • If it's a multi-touch event, it calls handleTouchMove.
  2. handleTouchMove Function:

    • Updates cached touch points and checks for pinch zoom conditions.
    • If the conditions for pinch zoom are not met, it calls handleMove again.

If there's a multi-touch event that doesn't meet the conditions for a pinch zoom, an infinite loop is created.

Code.org use NewRelic to detect JS errors like this. Since migrating two more labs to Google Blockly this week (:tada:), the errors have been above our threshold causing an alarm. This alarm pages our on-call engineer.

In order to fix this, I was able to monkey-patch handleMoveTouch to independently handle the touch events without needing to call handleMove again: code-dot-org/code-dot-org#59864

Reproduction steps

  1. On a touch device, go to the advanced playground.
  2. Disable zoom wheel and controls
  3. Add block to the workspace.
  4. Using two fingers, attempt to drag the block.
  5. Observe the range error in the console.

Stack trace

[Error] RangeError: Maximum call stack size exceeded.
	handleTouchMove (blockly_compressed.js:733)
	handleMove (blockly_compressed.js:730:349)

...repeats infinitely...

Screenshots

image

Browsers

No response

@mikeharv mikeharv added issue: bug Describes why the code or behaviour is wrong issue: triage Issues awaiting triage by a Blockly team member labels Jul 18, 2024
@mikeharv mikeharv changed the title nfinite loop when handling 'pointermove' events. Infinite loop when handling 'pointermove' events. Jul 18, 2024
@cpcallen
Copy link
Contributor

Hi @mikeharv. Thanks for finding this. We'd take a patch for it, if you would be so kind as to submit one.

@cpcallen cpcallen removed the issue: triage Issues awaiting triage by a Blockly team member label Jul 22, 2024
@AbhinavKRN
Copy link
Contributor

@mikeharv can you assign this issue to me?

@mikeharv
Copy link
Contributor Author

@cpcallen We've been running this patch for a couple weeks without any reported issues: https://github.com/code-dot-org/code-dot-org/blob/189a4fd5e223ffebcaf19677d0d9788e13a52625/apps/src/blockly/addons/cdoGesture.js

It does repeat some code shared by handleMove, but if you like the approach I'm happy to find a time to submit.

@AbhinavKRN I do not have permissions to assign issues from this repository, sorry!

@AbhinavKRN
Copy link
Contributor

@mikeharv whom to contact then?

@BeksOmega
Copy link
Collaborator

Hiya @AbhinavKRN if you're still interested feel free to give this a shot!

@AbhinavKRN
Copy link
Contributor

@BeksOmega On it!

@AbhinavKRN
Copy link
Contributor

@BeksOmega Can you let me know in which typeScript file do I get to read the code of handleTouch function and handleMoveTouch function

@BeksOmega
Copy link
Collaborator

@BeksOmega Can you let me know in which typeScript file do I get to read the code of handleTouch function and handleMoveTouch function

Did you try searching for those strings in this repo? https://github.com/search?q=repo%3Agoogle%2Fblockly%20handleTouchMove&type=code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Describes why the code or behaviour is wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants