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

Fix: Android Multi touch interaction fixes #10151

Open
wants to merge 1 commit into
base: v6.x
Choose a base branch
from

Conversation

devyeshtandon
Copy link

@devyeshtandon devyeshtandon commented Jan 24, 2024

Description of change

Problem:
On Android devices, when a user interacts with a pinch zoom (multi-touch interaction), it works for the first time and then stops working subsequently. There were a couple of open issues in pixi-viewport that discuss this problem

  1. 2nd time you pinch on mobile it breaks davidfig/pixi-viewport#200
  2. Pinch zoom issues on firefox mobile davidfig/pixi-viewport#364

Demo:

WhatsApp.Video.2024-01-24.at.10.38.58.PM.mp4

Solution:
In @pixi/interaction package, we have interactionDataPool. When a tap occurs, we create an InteractionData object. And when it is released, we push this object to the array for future use in function getInteractionDataForPointerId

Now, if the pointerId == MOUSE_POINTER_ID,the interactionData is this.mouse. This gets pushed to the interaction pool on release. In future touches, this data gets manipulated and identifier gets to 0 because of the following code:

 private getInteractionDataForPointerId(event: PointerEvent): InteractionData
   ...
        else
        {
            interactionData = this.interactionDataPool.pop() || new InteractionData();
            interactionData.identifier = pointerId; // HERE this.mouse.identifier can be set to 0
            this.activeInteractionData[pointerId] = interactionData;
        }
        // copy properties from the event, so that we can make sure that touch/pointer specific
        // data is available
        interactionData.copyEvent(event);

        return interactionData;
    }

Solution:
If the interaction data is this.mouse, we do not push it to interactionDataPool. We check this by comparing the pointerId of the interaction data

Pre-Merge Checklist
  • Tests and/or benchmarks are included
  • Documentation is changed or added
  • Lint process passed (npm run lint)
  • Tests passed (npm run test)

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.

None yet

1 participant