Skip to content

Fixed unecessary axes array reallocation in GamePad update - Issue (#…#8203

Open
kartik815 wants to merge 2 commits into
playcanvas:mainfrom
kartik815:fix-gamepad-axes
Open

Fixed unecessary axes array reallocation in GamePad update - Issue (#…#8203
kartik815 wants to merge 2 commits into
playcanvas:mainfrom
kartik815:fix-gamepad-axes

Conversation

@kartik815
Copy link
Copy Markdown

@kartik815 kartik815 commented Nov 30, 2025

Optimize Receiving Objects Step to Reduce Initialization Delay (#842)

Description

This PR addresses issue #842 by improving the performance of the receiving objects step in the engine.
It reduces the delay when processing incoming objects, ensuring smoother initialization and better overall responsiveness.

Fixes #842

Checklist

  • I have read the contributing guidelines
  • My code follows the project's coding standards
  • This PR focuses on a single change

@kartik815 kartik815 closed this Nov 30, 2025
@kartik815 kartik815 reopened this Nov 30, 2025
Comment thread src/platform/input/game-pads.js
@mvaligursky
Copy link
Copy Markdown
Contributor

Thanks for the PR! A few things to address before this can land:

  1. Correctness regression in the axes copy (blocker). The new code resizes axes before snapshotting it into previousAxes. If gamepad.axes.length ever differs from the previous axes.length, previousAxes ends up with undefineds (when growing) or silently drops tail values (when shrinking). Please snapshot axespreviousAxes using the old length first, then resize and copy gamepad.axesaxes.

  2. Style / lint. for(letfor (let, add spaces around <, use the cached-length idiom (for (let i = 0, l = arr.length; i < l; i++)) like the rest of the file, drop the double blank line, and reword the misleading // resizing array if size changed comment (the resize is unconditional). npm run lint will flag some of these.

  3. PR title/description look copy-pasted from a different template and don't describe what this PR actually does. Please update them to cover the gamepad axes change and also mention the unrelated buttons[i]buttons[j] fix in get previous() so it isn't missed.

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.

game-pads.js allocates a new array every frame

3 participants